* [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
@ 2019-06-11 14:55 Ramon Fried
2019-06-11 16:21 ` Laurent Vivier
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Ramon Fried @ 2019-06-11 14:55 UTC (permalink / raw)
To: qemu-devel, qemu-trivial
Cc: Peter Maydell, Jason Wang, Alistair Francis,
open list:Xilinx Zynq, Ramon Fried, Edgar E. Iglesias
defining CADENCE_GEM_ERR_DEBUG causes compilation
errors, fix that.
Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
---
v2: change %lx to HWADDR_PRIx and %lx to %zdx
hw/net/cadence_gem.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 7f63411430..e9b1b1e2eb 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
return -1;
}
- DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize),
- rx_desc_get_buffer(s->rx_desc[q]));
+ DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n", MIN(bytes_to_copy, rxbufsize),
+ rx_desc_get_buffer(s, s->rx_desc[q]));
/* Copy packet data to emulated DMA buffer */
address_space_write(&s->dma_as, rx_desc_get_buffer(s, s->rx_desc[q]) +
@@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
if (tx_desc_get_length(desc) > sizeof(tx_packet) -
(p - tx_packet)) {
DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space " \
- "0x%x\n", (unsigned)packet_desc_addr,
+ "0x%zdx\n", (unsigned)packet_desc_addr,
(unsigned)tx_desc_get_length(desc),
sizeof(tx_packet) - (p - tx_packet));
break;
--
2.21.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
2019-06-11 14:55 [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on Ramon Fried
@ 2019-06-11 16:21 ` Laurent Vivier
2019-06-12 4:27 ` Ramon Fried
2019-06-12 8:59 ` Philippe Mathieu-Daudé
2019-06-12 18:03 ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2 siblings, 1 reply; 8+ messages in thread
From: Laurent Vivier @ 2019-06-11 16:21 UTC (permalink / raw)
To: Ramon Fried, qemu-devel, qemu-trivial
Cc: Peter Maydell, Jason Wang, Alistair Francis,
open list:Xilinx Zynq, Edgar E. Iglesias,
Philippe Mathieu-Daudé
Le 11/06/2019 à 16:55, Ramon Fried a écrit :
> defining CADENCE_GEM_ERR_DEBUG causes compilation
> errors, fix that.
>
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> ---
> v2: change %lx to HWADDR_PRIx and %lx to %zdx
HWADDR_PRIx is to use with hwaddr type (packet_desc_addr).
rx_desc_get_buffer() is uint64_t, you must use PRIx64.
It may be better to remove also the cast to unsigned.
Thanks,
Laurent
>
> hw/net/cadence_gem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index 7f63411430..e9b1b1e2eb 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
> return -1;
> }
>
> - DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize),
> - rx_desc_get_buffer(s->rx_desc[q]));
> + DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n", MIN(bytes_to_copy, rxbufsize),
> + rx_desc_get_buffer(s, s->rx_desc[q]));
>
> /* Copy packet data to emulated DMA buffer */
> address_space_write(&s->dma_as, rx_desc_get_buffer(s, s->rx_desc[q]) +
> @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
> if (tx_desc_get_length(desc) > sizeof(tx_packet) -
> (p - tx_packet)) {
> DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space " \
> - "0x%x\n", (unsigned)packet_desc_addr,
> + "0x%zdx\n", (unsigned)packet_desc_addr,
> (unsigned)tx_desc_get_length(desc),
> sizeof(tx_packet) - (p - tx_packet));
> break;
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
2019-06-11 16:21 ` Laurent Vivier
@ 2019-06-12 4:27 ` Ramon Fried
2019-06-12 7:40 ` Laurent Vivier
0 siblings, 1 reply; 8+ messages in thread
From: Ramon Fried @ 2019-06-12 4:27 UTC (permalink / raw)
To: Laurent Vivier
Cc: Peter Maydell, qemu-trivial, Jason Wang, Alistair Francis,
qemu-devel, open list:Xilinx Zynq, Edgar E. Iglesias,
Philippe Mathieu-Daudé
On Tue, Jun 11, 2019 at 7:21 PM Laurent Vivier <laurent@vivier.eu> wrote:
> Le 11/06/2019 à 16:55, Ramon Fried a écrit :
> > defining CADENCE_GEM_ERR_DEBUG causes compilation
> > errors, fix that.
> >
> > Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> > ---
> > v2: change %lx to HWADDR_PRIx and %lx to %zdx
>
> HWADDR_PRIx is to use with hwaddr type (packet_desc_addr).
> rx_desc_get_buffer() is uint64_t, you must use PRIx64.
> It may be better to remove also the cast to unsigned.
>
Other places in the code also use HWADDR_PRIx with rx_desc_get_buffer().
Should I change them also ?
>
> Thanks,
> Laurent
> >
> > hw/net/cadence_gem.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> > index 7f63411430..e9b1b1e2eb 100644
> > --- a/hw/net/cadence_gem.c
> > +++ b/hw/net/cadence_gem.c
> > @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc, const
> uint8_t *buf, size_t size)
> > return -1;
> > }
> >
> > - DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy,
> rxbufsize),
> > - rx_desc_get_buffer(s->rx_desc[q]));
> > + DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n",
> MIN(bytes_to_copy, rxbufsize),
> > + rx_desc_get_buffer(s, s->rx_desc[q]));
> >
> > /* Copy packet data to emulated DMA buffer */
> > address_space_write(&s->dma_as, rx_desc_get_buffer(s,
> s->rx_desc[q]) +
> > @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
> > if (tx_desc_get_length(desc) > sizeof(tx_packet) -
> > (p - tx_packet)) {
> > DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x
> space " \
> > - "0x%x\n", (unsigned)packet_desc_addr,
> > + "0x%zdx\n", (unsigned)packet_desc_addr,
> > (unsigned)tx_desc_get_length(desc),
> > sizeof(tx_packet) - (p - tx_packet));
> > break;
> >
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
2019-06-12 4:27 ` Ramon Fried
@ 2019-06-12 7:40 ` Laurent Vivier
2019-06-15 5:10 ` Ramon Fried
0 siblings, 1 reply; 8+ messages in thread
From: Laurent Vivier @ 2019-06-12 7:40 UTC (permalink / raw)
To: Ramon Fried
Cc: Peter Maydell, qemu-trivial, Jason Wang, Alistair Francis,
qemu-devel, open list:Xilinx Zynq, Edgar E. Iglesias,
Philippe Mathieu-Daudé
Le 12/06/2019 à 06:27, Ramon Fried a écrit :
>
>
> On Tue, Jun 11, 2019 at 7:21 PM Laurent Vivier <laurent@vivier.eu
> <mailto:laurent@vivier.eu>> wrote:
>
> Le 11/06/2019 à 16:55, Ramon Fried a écrit :
> > defining CADENCE_GEM_ERR_DEBUG causes compilation
> > errors, fix that.
> >
> > Signed-off-by: Ramon Fried <rfried.dev@gmail.com
> <mailto:rfried.dev@gmail.com>>
> > ---
> > v2: change %lx to HWADDR_PRIx and %lx to %zdx
>
> HWADDR_PRIx is to use with hwaddr type (packet_desc_addr).
> rx_desc_get_buffer() is uint64_t, you must use PRIx64.
> It may be better to remove also the cast to unsigned.
>
> Other places in the code also use HWADDR_PRIx with rx_desc_get_buffer().
> Should I change them also ?
No, in fact you should change the return type of rx_desc_get_buffer() to
hwaddr.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
2019-06-11 14:55 [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on Ramon Fried
2019-06-11 16:21 ` Laurent Vivier
@ 2019-06-12 8:59 ` Philippe Mathieu-Daudé
2019-06-12 18:03 ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-06-12 8:59 UTC (permalink / raw)
To: Ramon Fried, qemu-devel, qemu-trivial
Cc: Peter Maydell, Jason Wang, Alistair Francis,
open list:Xilinx Zynq, Edgar E. Iglesias
On 6/11/19 4:55 PM, Ramon Fried wrote:
> defining CADENCE_GEM_ERR_DEBUG causes compilation
> errors, fix that.
>
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> ---
> v2: change %lx to HWADDR_PRIx and %lx to %zdx
>
> hw/net/cadence_gem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index 7f63411430..e9b1b1e2eb 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
> return -1;
> }
>
> - DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize),
> - rx_desc_get_buffer(s->rx_desc[q]));
> + DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n", MIN(bytes_to_copy, rxbufsize),
> + rx_desc_get_buffer(s, s->rx_desc[q]));
>
> /* Copy packet data to emulated DMA buffer */
> address_space_write(&s->dma_as, rx_desc_get_buffer(s, s->rx_desc[q]) +
> @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
> if (tx_desc_get_length(desc) > sizeof(tx_packet) -
> (p - tx_packet)) {
> DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space " \
> - "0x%x\n", (unsigned)packet_desc_addr,
> + "0x%zdx\n", (unsigned)packet_desc_addr,
The format is either "zd" or "zx". I misunderstood how you want to print
it, if you want hexadecimal, it should be "zx" then.
> (unsigned)tx_desc_get_length(desc),
> sizeof(tx_packet) - (p - tx_packet));
> break;
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
2019-06-11 14:55 [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on Ramon Fried
2019-06-11 16:21 ` Laurent Vivier
2019-06-12 8:59 ` Philippe Mathieu-Daudé
@ 2019-06-12 18:03 ` Alex Bennée
2019-06-12 19:28 ` Eric Blake
2 siblings, 1 reply; 8+ messages in thread
From: Alex Bennée @ 2019-06-12 18:03 UTC (permalink / raw)
To: qemu-arm
Cc: Peter Maydell, qemu-trivial, Jason Wang, Alistair Francis,
qemu-devel, Ramon Fried
Ramon Fried <rfried.dev@gmail.com> writes:
> defining CADENCE_GEM_ERR_DEBUG causes compilation
> errors, fix that.
It would be worth doing something like:
#ifdef CADENCE_GEM_ERR_DEBUG
#define CADENCE_GEM_GATE 1
#else
#define CADENCE_GEM_GATE 0
#endif
#define DB_PRINT(...) do { \
if (CADENCE_GEM_GATE) { \
fprintf(stderr, ": %s: ", __func__); \
fprintf(stderr, ## __VA_ARGS__); \
} \
} while (0)
So these format strings don't go stale in and only get detected on
--debug builds.
While your at it I suspect the fprintf debug would be better of as:
qemu_log("%s: " fmt, __func__, ## args);
>
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> ---
> v2: change %lx to HWADDR_PRIx and %lx to %zdx
>
> hw/net/cadence_gem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index 7f63411430..e9b1b1e2eb 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -982,8 +982,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
> return -1;
> }
>
> - DB_PRINT("copy %d bytes to 0x%x\n", MIN(bytes_to_copy, rxbufsize),
> - rx_desc_get_buffer(s->rx_desc[q]));
> + DB_PRINT("copy %d bytes to 0x%" HWADDR_PRIx "\n", MIN(bytes_to_copy, rxbufsize),
> + rx_desc_get_buffer(s, s->rx_desc[q]));
>
> /* Copy packet data to emulated DMA buffer */
> address_space_write(&s->dma_as, rx_desc_get_buffer(s, s->rx_desc[q]) +
> @@ -1156,7 +1156,7 @@ static void gem_transmit(CadenceGEMState *s)
> if (tx_desc_get_length(desc) > sizeof(tx_packet) -
> (p - tx_packet)) {
> DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space " \
> - "0x%x\n", (unsigned)packet_desc_addr,
> + "0x%zdx\n", (unsigned)packet_desc_addr,
> (unsigned)tx_desc_get_length(desc),
> sizeof(tx_packet) - (p - tx_packet));
> break;
--
Alex Bennée
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Qemu-arm] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
2019-06-12 18:03 ` [Qemu-devel] [Qemu-arm] " Alex Bennée
@ 2019-06-12 19:28 ` Eric Blake
0 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2019-06-12 19:28 UTC (permalink / raw)
To: Alex Bennée, qemu-arm
Cc: Peter Maydell, qemu-trivial, Jason Wang, Alistair Francis,
qemu-devel, Ramon Fried
[-- Attachment #1.1: Type: text/plain, Size: 1048 bytes --]
On 6/12/19 1:03 PM, Alex Bennée wrote:
>
> Ramon Fried <rfried.dev@gmail.com> writes:
>
>> defining CADENCE_GEM_ERR_DEBUG causes compilation
>> errors, fix that.
>
> It would be worth doing something like:
>
> #ifdef CADENCE_GEM_ERR_DEBUG
> #define CADENCE_GEM_GATE 1
> #else
> #define CADENCE_GEM_GATE 0
> #endif
>
> #define DB_PRINT(...) do { \
> if (CADENCE_GEM_GATE) { \
> fprintf(stderr, ": %s: ", __func__); \
> fprintf(stderr, ## __VA_ARGS__); \
> } \
> } while (0)
>
> So these format strings don't go stale in and only get detected on
> --debug builds.
>
> While your at it I suspect the fprintf debug would be better of as:
>
> qemu_log("%s: " fmt, __func__, ## args);
Indeed, or even see if it is worth converting to full-on trace points
for dynamic control of whether to catch these things without having to
recompile debug on or off.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on
2019-06-12 7:40 ` Laurent Vivier
@ 2019-06-15 5:10 ` Ramon Fried
0 siblings, 0 replies; 8+ messages in thread
From: Ramon Fried @ 2019-06-15 5:10 UTC (permalink / raw)
To: Laurent Vivier
Cc: Peter Maydell, qemu-trivial, Jason Wang, Alistair Francis,
qemu-devel, open list:Xilinx Zynq, Edgar E. Iglesias,
Philippe Mathieu-Daudé
On Wed, Jun 12, 2019 at 10:40 AM Laurent Vivier <laurent@vivier.eu> wrote:
> Le 12/06/2019 à 06:27, Ramon Fried a écrit :
> >
> >
> > On Tue, Jun 11, 2019 at 7:21 PM Laurent Vivier <laurent@vivier.eu
> > <mailto:laurent@vivier.eu>> wrote:
> >
> > Le 11/06/2019 à 16:55, Ramon Fried a écrit :
> > > defining CADENCE_GEM_ERR_DEBUG causes compilation
> > > errors, fix that.
> > >
> > > Signed-off-by: Ramon Fried <rfried.dev@gmail.com
> > <mailto:rfried.dev@gmail.com>>
> > > ---
> > > v2: change %lx to HWADDR_PRIx and %lx to %zdx
> >
> > HWADDR_PRIx is to use with hwaddr type (packet_desc_addr).
> > rx_desc_get_buffer() is uint64_t, you must use PRIx64.
> > It may be better to remove also the cast to unsigned.
> >
> > Other places in the code also use HWADDR_PRIx with rx_desc_get_buffer().
> > Should I change them also ?
>
> No, in fact you should change the return type of rx_desc_get_buffer() to
> hwaddr.
>
Make sense.
I'll do it in a different patch.
>
> Thanks,
> Laurent
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-06-15 5:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11 14:55 [Qemu-devel] [PATCH v2] net: cadence_gem: fix compilation error when debug is on Ramon Fried
2019-06-11 16:21 ` Laurent Vivier
2019-06-12 4:27 ` Ramon Fried
2019-06-12 7:40 ` Laurent Vivier
2019-06-15 5:10 ` Ramon Fried
2019-06-12 8:59 ` Philippe Mathieu-Daudé
2019-06-12 18:03 ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2019-06-12 19:28 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).