Skip to contentSkip to conversation

net: cadence_gem: Remove incorrect assert()

PATCH In review Edgar E. Iglesias 4 participants 10 messages Nov 23, 2018 – Nov 26, 2018

lore
Share & tools
lore
#0 lore raw

cover net: cadence_gem: Remove incorrect assert()

From: "Edgar E. Iglesias" <[email protected]>

This fixes an issue with the GEM models reported by Bilal. If a GEM's receiver is disabled, we shouldn't be asserting on descriptor processing.

Cheers,
Edgar

Edgar E. Iglesias (1):
net: cadence_gem: Remove incorrect assert()

 hw/net/cadence_gem.c | 1 -
 1 file changed, 1 deletion(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 net: cadence_gem: Remove incorrect assert()

From: "Edgar E. Iglesias" <[email protected]>

Don't assert on RX descriptor settings when the receiver is disabled. This fixes an issue with incoming packets on an unused GEM.

---
 hw/net/cadence_gem.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/cadence_gem.c +0 -1
index d95cc27f58..7f63411430 100644
@@ -979,7 +979,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 
         /* Do nothing if receive is not enabled. */
         if (!gem_can_receive(nc)) {
-            assert(!first_desc);
             return -1;
         }
 
Signature · 1 line
2.17.1
#2 lore raw

Hi Edgar,

Quoted 17 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Don't assert on RX descriptor settings when the receiver is disabled. This fixes an issue with incoming packets on an unused GEM.

---
 hw/net/cadence_gem.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/cadence_gem.c +0 -0
index d95cc27f58..7f63411430 100644

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 4 lines
hw/net/cadence_gem.c +0 -1
@@ -979,7 +979,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 
         /* Do nothing if receive is not enabled. */
         if (!gem_can_receive(nc)) {
-            assert(!first_desc);

Maybe worth:

               trace_gem_receive_packet_drop(size);

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 1 line
hw/net/cadence_gem.c +0 -0
             return -1;

Shouldn't this be 'return 0'?

The "net/net.h" doc is scarce...

Regards,

Phil.

Quoted 3 lines
hw/net/cadence_gem.c +0 -0
         }
 
#3 lore raw
Quoted 1 line · Philippe Mathieu-Daudé

Hi Edgar,

Hi Philippe,

Quoted 20 lines · Edgar E. Iglesias
Quoted 18 lines

From: "Edgar E. Iglesias" <[email protected]>

Don't assert on RX descriptor settings when the receiver is disabled. This fixes an issue with incoming packets on an unused GEM.

---
 hw/net/cadence_gem.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/cadence_gem.c +0 -0
index d95cc27f58..7f63411430 100644
@@ -979,7 +979,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 
Quoted 7 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 3 lines
hw/net/cadence_gem.c +0 -1
         /* Do nothing if receive is not enabled. */
         if (!gem_can_receive(nc)) {
-            assert(!first_desc);

Maybe worth:

               trace_gem_receive_packet_drop(size);

Or perhaps a generic tracepoint on packet drops for any device. Anyway this is probably something for after the release.

Not sure if it's too late to even get the removal of the assert into this release? Peter?

Quoted 6 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 2 lines
hw/net/cadence_gem.c +0 -0
             return -1;

Shouldn't this be 'return 0'?

The "net/net.h" doc is scarce...

If we return 0 my understanding is that we later need to actively call qemu_flush_or_purge_queued_packets() to renable the rx path which the GEM model doesn't do. So that would mean refactoring the model a bit.

Cheers,
Edgar

Quoted 8 lines

Regards,

Phil.

Quoted 3 lines
hw/net/cadence_gem.c +0 -0
         }
 
#4 lore raw
Quoted 41 lines · Edgar E. Iglesias
Quoted 1 line · Philippe Mathieu-Daudé

Hi Edgar,

Hi Philippe,

Quoted 20 lines · Edgar E. Iglesias
Quoted 18 lines

From: "Edgar E. Iglesias" <[email protected]>

Don't assert on RX descriptor settings when the receiver is disabled. This fixes an issue with incoming packets on an unused GEM.

---
 hw/net/cadence_gem.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/cadence_gem.c +0 -0
index d95cc27f58..7f63411430 100644
@@ -979,7 +979,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 
Quoted 7 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 3 lines
hw/net/cadence_gem.c +0 -1
         /* Do nothing if receive is not enabled. */
         if (!gem_can_receive(nc)) {
-            assert(!first_desc);

Maybe worth:

               trace_gem_receive_packet_drop(size);

Or perhaps a generic tracepoint on packet drops for any device. Anyway this is probably something for after the release.

Not sure if it's too late to even get the removal of the assert into this release? Peter?

Quoted 3 lines
Quoted 2 lines
hw/net/cadence_gem.c +0 -0
             return -1;
Quoted 8 lines
Quoted 3 lines

Shouldn't this be 'return 0'?

The "net/net.h" doc is scarce...

If we return 0 my understanding is that we later need to actively call qemu_flush_or_purge_queued_packets() to renable the rx path which the GEM model doesn't do. So that would mean refactoring the model a bit.

Actually, the GEM model does do that, my bad, so yes return 0 seems to be the right thing to do here.

Thanks,
Edgar

Quoted 13 lines

Cheers,
Edgar

Quoted 8 lines

Regards,

Phil.

Quoted 3 lines
hw/net/cadence_gem.c +0 -0
         }
 
#5 lore raw
Quoted 44 lines · Edgar E. Iglesias
Quoted 43 lines · Edgar E. Iglesias
Quoted 1 line · Philippe Mathieu-Daudé

Hi Edgar,

Hi Philippe,

Quoted 20 lines · Edgar E. Iglesias
Quoted 18 lines

From: "Edgar E. Iglesias" <[email protected]>

Don't assert on RX descriptor settings when the receiver is disabled. This fixes an issue with incoming packets on an unused GEM.

---
 hw/net/cadence_gem.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/cadence_gem.c +0 -0
index d95cc27f58..7f63411430 100644
@@ -979,7 +979,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 
Quoted 7 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 3 lines
hw/net/cadence_gem.c +0 -1
         /* Do nothing if receive is not enabled. */
         if (!gem_can_receive(nc)) {
-            assert(!first_desc);

Maybe worth:

               trace_gem_receive_packet_drop(size);

Or perhaps a generic tracepoint on packet drops for any device. Anyway this is probably something for after the release.

Not sure if it's too late to even get the removal of the assert into this release? Peter?

Quoted 5 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 2 lines
hw/net/cadence_gem.c +0 -0
             return -1;

Shouldn't this be 'return 0'?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

The "net/net.h" doc is scarce...

If we return 0 my understanding is that we later need to actively call qemu_flush_or_purge_queued_packets() to renable the rx path which the GEM model doesn't do. So that would mean refactoring the model a bit.

Actually, the GEM model does do that, my bad, so yes return 0 seems to be the right thing to do here.

I take that back, the GEM model only handles some of the !can_receive cases with qemu_flush_queued_packets(). Not all, so return -1 is correct I think.

Cheers,
Edgar

#6 lore raw
Quoted 52 lines · Edgar E. Iglesias
Quoted 51 lines · Edgar E. Iglesias
Quoted 49 lines · Edgar E. Iglesias
Quoted 1 line · Philippe Mathieu-Daudé

Hi Edgar,

Hi Philippe,

Quoted 20 lines · Edgar E. Iglesias
Quoted 18 lines

From: "Edgar E. Iglesias" <[email protected]>

Don't assert on RX descriptor settings when the receiver is disabled. This fixes an issue with incoming packets on an unused GEM.

---
 hw/net/cadence_gem.c | 1 -
 1 file changed, 1 deletion(-)
hw/net/cadence_gem.c +0 -0
index d95cc27f58..7f63411430 100644
@@ -979,7 +979,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 
Quoted 7 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 3 lines
hw/net/cadence_gem.c +0 -1
         /* Do nothing if receive is not enabled. */
         if (!gem_can_receive(nc)) {
-            assert(!first_desc);

Maybe worth:

               trace_gem_receive_packet_drop(size);

Or perhaps a generic tracepoint on packet drops for any device. Anyway this is probably something for after the release.

Not sure if it's too late to even get the removal of the assert into this release? Peter?

Quoted 6 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 982

Quoted 2 lines
hw/net/cadence_gem.c +0 -0
             return -1;

Shouldn't this be 'return 0'?

The "net/net.h" doc is scarce...

If we return 0 my understanding is that we later need to actively call qemu_flush_or_purge_queued_packets() to renable the rx path which the GEM model doesn't do. So that would mean refactoring the model a bit.

Quoted 4 lines
Quoted 1 line

Actually, the GEM model does do that, my bad, so yes return 0 seems to be the right thing to do here.

I take that back, the GEM model only handles some of the !can_receive cases with qemu_flush_queued_packets(). Not all, so return -1 is correct I think.

OK, thanks for checking this.

Regards,

Phil.

#7 lore raw
In reply to Edgar E. Iglesias
Quoted 1 line · Edgar E. Iglesias

Not sure if it's too late to even get the removal of the assert into this release? Peter?

If you're happy that removing the assert is the correct fix, yes, this could go in before rc3 next week.

thanks
-- PMM

#8 lore raw
Quoted 6 lines · Peter Maydell
Quoted 1 line · Edgar E. Iglesias

Not sure if it's too late to even get the removal of the assert into this release? Peter?

If you're happy that removing the assert is the correct fix, yes, this could go in before rc3 next week.

Yes, I think removing the assert is a suitable fix for the release.

Thanks!
Edgar

#9 lore raw
Quoted 11 lines · Edgar E. Iglesias
Quoted 6 lines · Peter Maydell
Quoted 1 line · Edgar E. Iglesias

Not sure if it's too late to even get the removal of the assert into this release? Peter?

If you're happy that removing the assert is the correct fix, yes, this could go in before rc3 next week.

Yes, I think removing the assert is a suitable fix for the release.

OK, I have applied this to target-arm.next for rc3.

thanks
-- PMM