Skip to contentSkip to conversation

hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write()

PATCH Applied Chen Qun 3 participants 5 messages Feb 25, 2020 – Feb 26, 2020 Arm i.MX and Layerscape

v1 of 4 Applied Latest is v4 →

lore
Share & tools
lore

Chen Qun

author
#0 lore raw

PATCH 1/1 hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write()

The current code causes clang static code analyzer generate warning:
hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read

        value = value & 0x0000000f;
        ^       ~~~~~~~~~~~~~~~~~~
hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read
        value = value & 0x000000fd;
        ^       ~~~~~~~~~~~~~~~~~~

According to the definition of the function, the two “value” assignments
should be written to registers.

---
I'm not sure if this modification is correct, just from the function
definition, it is correct.

---
 hw/net/imx_fec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/imx_fec.c +2 -2
index 6a124a154a..92f6215712 100644
@@ -855,13 +855,13 @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value)
         break;
     case ENET_TGSR:
         /* implement clear timer flag */
-        value = value & 0x0000000f;
+        s->regs[index] = value & 0x0000000f;
         break;
     case ENET_TCSR0:
     case ENET_TCSR1:
     case ENET_TCSR2:
     case ENET_TCSR3:
-        value = value & 0x000000fd;
+        s->regs[index] = value & 0x000000fd;
         break;
     case ENET_TCCR0:
     case ENET_TCCR1:
Signature · 1 line
2.23.0
Applied
#1 lore raw
Quoted 30 lines · Chen Qun

The current code causes clang static code analyzer generate warning:
hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read

         value = value & 0x0000000f;
         ^       ~~~~~~~~~~~~~~~~~~
hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read
         value = value & 0x000000fd;
         ^       ~~~~~~~~~~~~~~~~~~

According to the definition of the function, the two “value” assignments
should be written to registers.

---
I'm not sure if this modification is correct, just from the function
definition, it is correct.

---
  hw/net/imx_fec.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/imx_fec.c +1 -1
index 6a124a154a..92f6215712 100644
@@ -855,13 +855,13 @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value)
          break;
      case ENET_TGSR:
          /* implement clear timer flag */
-        value = value & 0x0000000f;
+        s->regs[index] = value & 0x0000000f;

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 867

Quoted 10 lines
hw/net/imx_fec.c +1 -1
          break;
      case ENET_TCSR0:
      case ENET_TCSR1:
      case ENET_TCSR2:
      case ENET_TCSR3:
-        value = value & 0x000000fd;
+        s->regs[index] = value & 0x000000fd;
          break;
      case ENET_TCCR0:
      case ENET_TCCR1:

Applied.

Thanks

#2 lore raw
Quoted 23 lines · Jason Wang
Quoted 20 lines · Chen Qun

The current code causes clang static code analyzer generate warning:
hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read

         value = value & 0x0000000f;
         ^       ~~~~~~~~~~~~~~~~~~
hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read
         value = value & 0x000000fd;
         ^       ~~~~~~~~~~~~~~~~~~

According to the definition of the function, the two “value” assignments
should be written to registers.

---
I'm not sure if this modification is correct, just from the function
definition, it is correct.

---
  hw/net/imx_fec.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 11 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 859

Quoted 11 lines
hw/net/imx_fec.c +1 -1
index 6a124a154a..92f6215712 100644
@@ -855,13 +855,13 @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value)
          break;
      case ENET_TGSR:
          /* implement clear timer flag */
-        value = value & 0x0000000f;
+        s->regs[index] = value & 0x0000000f;
          break;

Hi; the datasheet for this SoC says that these bits of the register are write-1-to-clear, so while this is definitely a bug I don't think this is the right fix.

Quoted 7 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 865

Quoted 7 lines
hw/net/imx_fec.c +1 -1
      case ENET_TCSR0:
      case ENET_TCSR1:
      case ENET_TCSR2:
      case ENET_TCSR3:
-        value = value & 0x000000fd;
+        s->regs[index] = value & 0x000000fd;
          break;

Here bit 7 is write-1-to-clear, though bits 0 and 2..5 are simple write-the-value.

Quoted 5 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 867

Quoted 2 lines
hw/net/imx_fec.c +0 -0
      case ENET_TCCR0:
      case ENET_TCCR1:

Applied.

Could you drop this from your queue, please?

thanks
-- PMM

#3 lore raw
Quoted 48 lines · Peter Maydell
Quoted 22 lines · Jason Wang
Quoted 20 lines · Chen Qun

The current code causes clang static code analyzer generate warning:
hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read

          value = value & 0x0000000f;
          ^       ~~~~~~~~~~~~~~~~~~
hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read
          value = value & 0x000000fd;
          ^       ~~~~~~~~~~~~~~~~~~

According to the definition of the function, the two “value” assignments
should be written to registers.

---
I'm not sure if this modification is correct, just from the function
definition, it is correct.

---
   hw/net/imx_fec.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 11 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 859

Quoted 11 lines
hw/net/imx_fec.c +1 -1
index 6a124a154a..92f6215712 100644
@@ -855,13 +855,13 @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value)
           break;
       case ENET_TGSR:
           /* implement clear timer flag */
-        value = value & 0x0000000f;
+        s->regs[index] = value & 0x0000000f;
           break;

Hi; the datasheet for this SoC says that these bits of the register are write-1-to-clear, so while this is definitely a bug I don't think this is the right fix.

Quoted 7 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 865

Quoted 7 lines
hw/net/imx_fec.c +1 -1
       case ENET_TCSR0:
       case ENET_TCSR1:
       case ENET_TCSR2:
       case ENET_TCSR3:
-        value = value & 0x000000fd;
+        s->regs[index] = value & 0x000000fd;
           break;

Here bit 7 is write-1-to-clear, though bits 0 and 2..5 are simple write-the-value.

Quoted 8 lines
Quoted 4 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 867

Quoted 2 lines
hw/net/imx_fec.c +0 -0
       case ENET_TCCR0:
       case ENET_TCCR1:

Applied.

Could you drop this from your queue, please?

thanks
-- PMM

Sure, Chen please send V2 to address Peter's comment.

Thanks

#4 lore raw
Quoted 66 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 11:03 AM
To: Peter Maydell <[email protected]>
Cc: Chenqun (kuhn) <[email protected]>; QEMU Developers <[email protected]>; QEMU Trivial <[email protected]>; Zhanghailiang <[email protected]>; Peter Chubb <[email protected]>; qemu-arm <[email protected]>
Subject: Re: [PATCH] hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write()

Quoted 23 lines · Peter Maydell
Quoted 22 lines · Jason Wang
Quoted 20 lines · Chen Qun

The current code causes clang static code analyzer generate warning:
hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read

          value = value & 0x0000000f;
          ^       ~~~~~~~~~~~~~~~~~~
hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read
          value = value & 0x000000fd;
          ^       ~~~~~~~~~~~~~~~~~~

According to the definition of the function, the two “value” assignments
should be written to registers.

---
I'm not sure if this modification is correct, just from the function
definition, it is correct.

---
   hw/net/imx_fec.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s,

Quoted 5 lines
hw/net/imx_fec.c index renamed from hw/net/imx_fec.c +0 -0

6a124a154a..92f6215712 100644

hw/net/imx_fec.c +0 -0
@@ -855,13 +855,13 @@ static void imx_enet_write(IMXFECState *s,

uint32_t index, uint32_t value)

Quoted 23 lines
Quoted 6 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 859

Quoted 6 lines
hw/net/imx_fec.c +1 -1
           break;
       case ENET_TGSR:
           /* implement clear timer flag */
-        value = value & 0x0000000f;
+        s->regs[index] = value & 0x0000000f;
           break;

Hi; the datasheet for this SoC says that these bits of the register are write-1-to-clear, so while this is definitely a bug I don't think this is the right fix.

Quoted 7 lines

hw/net/imx_fec.c static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) · line 865

Quoted 7 lines
hw/net/imx_fec.c +1 -1
       case ENET_TCSR0:
       case ENET_TCSR1:
       case ENET_TCSR2:
       case ENET_TCSR3:
-        value = value & 0x000000fd;
+        s->regs[index] = value & 0x000000fd;
           break;

Here bit 7 is write-1-to-clear, though bits 0 and
2..5 are simple write-the-value.

Quoted 3 lines
Quoted 2 lines
hw/net/imx_fec.c +0 -0
       case ENET_TCCR0:
       case ENET_TCCR1:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Applied.

Could you drop this from your queue, please?

thanks
-- PMM

Sure, Chen please send V2 to address Peter's comment.

OK, but I didn't find the datasheet that contains these two registers description. Could someone provide me with a connection for the datasheet ?