ftgmac100: fix dblac write test
PATCH v2 1/1 ftgmac100: fix dblac write test
The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.
---
Changes since v1:
Changed %ld to HWADDR_PRIx to fix building on mingw
hw/net/ftgmac100.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
hw/net/ftgmac100.c +8 -6
@@ -810,16 +810,18 @@ static void ftgmac100_write(void *opaque, hwaddr addr, s->phydata = value &0xffff ;break ;case FTGMAC100_DBLAC :/* DMA Burst Length and Arbitration Control */ -if (FTGMAC100_DBLAC_TXDES_SIZE (s->dblac) <sizeof (FTGMAC100Desc)) { +if (FTGMAC100_DBLAC_TXDES_SIZE (value) <sizeof (FTGMAC100Desc)) {qemu_log_mask (LOG_GUEST_ERROR , -"%s: transmit descriptor too small : %d bytes\n" , - __func__,FTGMAC100_DBLAC_TXDES_SIZE (s->dblac)); +"%s: transmit descriptor too small: %" HWADDR_PRIx +" bytes\n" , __func__, +FTGMAC100_DBLAC_TXDES_SIZE (value));break ; } -if (FTGMAC100_DBLAC_RXDES_SIZE (s->dblac) <sizeof (FTGMAC100Desc)) { +if (FTGMAC100_DBLAC_RXDES_SIZE (value) <sizeof (FTGMAC100Desc)) {qemu_log_mask (LOG_GUEST_ERROR , -"%s: receive descriptor too small : %d bytes\n" , - __func__,FTGMAC100_DBLAC_RXDES_SIZE (s->dblac)); +"%s: receive descriptor too small : %" HWADDR_PRIx +" bytes\n" , __func__, +FTGMAC100_DBLAC_RXDES_SIZE (value));break ; } s->dblac = value;
Signature · 1 line
2.25.1
Quoted 9 lines · erik-smit
The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.
Signed-off-by erik-smit <[email protected]>---
Changes since v1:Changed %ld to
HWADDR_PRIxto fix building on mingw
Bit of a nitpick, but the type of the value argument is uint64_t, so shouldn't the result of the expression captured by FTGMAC100_DBLAC_TXDES_SIZE() and FTGMAC100_DBLAC_RXDES_SIZE() be printed with a straight PRIx64 rather than HWADDR_PRIx?
Otherwise the change seems sensible, so:
Hi Andrew,
Quoted 9 lines · Andrew Jeffery
Quoted 8 lines · erik-smit
The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.
Signed-off-by erik-smit <[email protected]>---
Changes since v1:
Quoted 6 lines
Quoted 1 line
Changed %ld to
HWADDR_PRIxto fix building on mingwBit of a nitpick, but the type of the value argument is
uint64_t, so shouldn't the result of the expression captured byFTGMAC100_DBLAC_TXDES_SIZE()andFTGMAC100_DBLAC_RXDES_SIZE()be printed with a straight PRIx64 rather thanHWADDR_PRIx?
You are correct. I didn't understand the meaning of the PRI macros and just grabbed the other PRI macro I saw getting used in the file.
Signature · 3 lines
Best regards, Erik Smit
Cédric Le Goater
Reviewed-byQuoted 14 lines · Erik Smit
Hi Andrew,
Quoted 11 lines · Andrew Jeffery
Quoted 9 lines · erik-smit
The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.
Signed-off-by erik-smit <[email protected]>---
Changes since v1:Changed %ld to
HWADDR_PRIxto fix building on mingw
Quoted 7 lines
Quoted 4 lines
Bit of a nitpick, but the type of the value argument is
uint64_t, so shouldn't the result of the expression captured byFTGMAC100_DBLAC_TXDES_SIZE()andFTGMAC100_DBLAC_RXDES_SIZE()be printed with a straight PRIx64 rather thanHWADDR_PRIx?You are correct. I didn't understand the meaning of the PRI macros and just grabbed the other PRI macro I saw getting used in the file.
With that fixed,
Thanks,
C.
Quoted 20 lines · Cédric Le Goater
Quoted 12 lines · Erik Smit
Hi Andrew,
Quoted 9 lines · Andrew Jeffery
Quoted 8 lines · erik-smit
The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.
Signed-off-by erik-smit <[email protected]>---
Changes since v1:Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Changed %ld to
HWADDR_PRIxto fix building on mingwBit of a nitpick, but the type of the value argument is
uint64_t, so shouldn't the result of the expression captured byFTGMAC100_DBLAC_TXDES_SIZE()andFTGMAC100_DBLAC_RXDES_SIZE()be printed with a straight PRIx64 rather thanHWADDR_PRIx?You are correct. I didn't understand the meaning of the PRI macros and just grabbed the other PRI macro I saw getting used in the file.
Quoted 7 lines
With that fixed,
Reviewed-by Cédric Le Goater <[email protected]>Thanks,
C.
Applied by switching to use PRIx64.
Thanks