Patch "net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-ethernet-ti-cpsw_ale-fix-cpsw_ale_get_field.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d807b9a7220f57ca96ef9055492443dbc8cfdfd3
Author: Sudheer Kumar Doredla <s-doredla@xxxxxx>
Date:   Wed Jan 8 22:54:33 2025 +0530

    net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()
    
    [ Upstream commit 03d120f27d050336f7e7d21879891542c4741f81 ]
    
    CPSW ALE has 75-bit ALE entries stored across three 32-bit words.
    The cpsw_ale_get_field() and cpsw_ale_set_field() functions support
    ALE field entries spanning up to two words at the most.
    
    The cpsw_ale_get_field() and cpsw_ale_set_field() functions work as
    expected when ALE field spanned across word1 and word2, but fails when
    ALE field spanned across word2 and word3.
    
    For example, while reading the ALE field spanned across word2 and word3
    (i.e. bits 62 to 64), the word3 data shifted to an incorrect position
    due to the index becoming zero while flipping.
    The same issue occurred when setting an ALE entry.
    
    This issue has not been seen in practice but will be an issue in the future
    if the driver supports accessing ALE fields spanning word2 and word3
    
    Fix the methods to handle getting/setting fields spanning up to two words.
    
    Fixes: b685f1a58956 ("net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field()")
    Signed-off-by: Sudheer Kumar Doredla <s-doredla@xxxxxx>
    Reviewed-by: Simon Horman <horms@xxxxxxxxxx>
    Reviewed-by: Roger Quadros <rogerq@xxxxxxxxxx>
    Reviewed-by: Siddharth Vadapalli <s-vadapalli@xxxxxx>
    Link: https://patch.msgid.link/20250108172433.311694-1-s-doredla@xxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 64bf22cd860c9..9eccc7064c2b0 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -106,15 +106,15 @@ struct cpsw_ale_dev_id {
 
 static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
 {
-	int idx, idx2;
+	int idx, idx2, index;
 	u32 hi_val = 0;
 
 	idx    = start / 32;
 	idx2 = (start + bits - 1) / 32;
 	/* Check if bits to be fetched exceed a word */
 	if (idx != idx2) {
-		idx2 = 2 - idx2; /* flip */
-		hi_val = ale_entry[idx2] << ((idx2 * 32) - start);
+		index = 2 - idx2; /* flip */
+		hi_val = ale_entry[index] << ((idx2 * 32) - start);
 	}
 	start -= idx * 32;
 	idx    = 2 - idx; /* flip */
@@ -124,16 +124,16 @@ static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
 static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits,
 				      u32 value)
 {
-	int idx, idx2;
+	int idx, idx2, index;
 
 	value &= BITMASK(bits);
 	idx = start / 32;
 	idx2 = (start + bits - 1) / 32;
 	/* Check if bits to be set exceed a word */
 	if (idx != idx2) {
-		idx2 = 2 - idx2; /* flip */
-		ale_entry[idx2] &= ~(BITMASK(bits + start - (idx2 * 32)));
-		ale_entry[idx2] |= (value >> ((idx2 * 32) - start));
+		index = 2 - idx2; /* flip */
+		ale_entry[index] &= ~(BITMASK(bits + start - (idx2 * 32)));
+		ale_entry[index] |= (value >> ((idx2 * 32) - start));
 	}
 	start -= idx * 32;
 	idx = 2 - idx; /* flip */




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux