qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/misc/edu: Rename macros indicating the direction of DMA operations
@ 2025-02-27  7:30 Jason Chien
  2025-03-11 11:15 ` Jason Chien
  2025-03-11 18:40 ` Peter Maydell
  0 siblings, 2 replies; 4+ messages in thread
From: Jason Chien @ 2025-02-27  7:30 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv; +Cc: Jiri Slaby, Jason Chien

This commit renames the macros to accurately reflect the direction of
DMA operations.

EDU_DMA_TO_PCI now represents reading memory content into the EDU buffer,
while EDU_DMA_FROM_PCI represents writing EDU buffer content to memory.

The previous naming was misleading, as the definitions were reversed.

Signed-off-by: Jason Chien <jason.chien@sifive.com>
---
 hw/misc/edu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 504178b4a2..1353c67dc2 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -63,8 +63,8 @@ struct EduState {
 
 #define EDU_DMA_RUN             0x1
 #define EDU_DMA_DIR(cmd)        (((cmd) & 0x2) >> 1)
-# define EDU_DMA_FROM_PCI       0
-# define EDU_DMA_TO_PCI         1
+# define EDU_DMA_TO_PCI         0
+# define EDU_DMA_FROM_PCI       1
 #define EDU_DMA_IRQ             0x4
     struct dma_state {
         dma_addr_t src;
@@ -146,7 +146,7 @@ static void edu_dma_timer(void *opaque)
         return;
     }
 
-    if (EDU_DMA_DIR(edu->dma.cmd) == EDU_DMA_FROM_PCI) {
+    if (EDU_DMA_DIR(edu->dma.cmd) == EDU_DMA_TO_PCI) {
         uint64_t dst = edu->dma.dst;
         edu_check_range(dst, edu->dma.cnt, DMA_START, DMA_SIZE);
         dst -= DMA_START;
-- 
2.43.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/misc/edu: Rename macros indicating the direction of DMA operations
  2025-02-27  7:30 [PATCH] hw/misc/edu: Rename macros indicating the direction of DMA operations Jason Chien
@ 2025-03-11 11:15 ` Jason Chien
  2025-03-11 18:40 ` Peter Maydell
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Chien @ 2025-03-11 11:15 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv; +Cc: Jiri Slaby

[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]

ping

Jason Chien <jason.chien@sifive.com> 於 2025年2月27日 週四 下午3:30寫道:

> This commit renames the macros to accurately reflect the direction of
> DMA operations.
>
> EDU_DMA_TO_PCI now represents reading memory content into the EDU buffer,
> while EDU_DMA_FROM_PCI represents writing EDU buffer content to memory.
>
> The previous naming was misleading, as the definitions were reversed.
>
> Signed-off-by: Jason Chien <jason.chien@sifive.com>
> ---
>  hw/misc/edu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/misc/edu.c b/hw/misc/edu.c
> index 504178b4a2..1353c67dc2 100644
> --- a/hw/misc/edu.c
> +++ b/hw/misc/edu.c
> @@ -63,8 +63,8 @@ struct EduState {
>
>  #define EDU_DMA_RUN             0x1
>  #define EDU_DMA_DIR(cmd)        (((cmd) & 0x2) >> 1)
> -# define EDU_DMA_FROM_PCI       0
> -# define EDU_DMA_TO_PCI         1
> +# define EDU_DMA_TO_PCI         0
> +# define EDU_DMA_FROM_PCI       1
>  #define EDU_DMA_IRQ             0x4
>      struct dma_state {
>          dma_addr_t src;
> @@ -146,7 +146,7 @@ static void edu_dma_timer(void *opaque)
>          return;
>      }
>
> -    if (EDU_DMA_DIR(edu->dma.cmd) == EDU_DMA_FROM_PCI) {
> +    if (EDU_DMA_DIR(edu->dma.cmd) == EDU_DMA_TO_PCI) {
>          uint64_t dst = edu->dma.dst;
>          edu_check_range(dst, edu->dma.cnt, DMA_START, DMA_SIZE);
>          dst -= DMA_START;
> --
> 2.43.2
>
>

[-- Attachment #2: Type: text/html, Size: 2012 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/misc/edu: Rename macros indicating the direction of DMA operations
  2025-02-27  7:30 [PATCH] hw/misc/edu: Rename macros indicating the direction of DMA operations Jason Chien
  2025-03-11 11:15 ` Jason Chien
@ 2025-03-11 18:40 ` Peter Maydell
  2025-03-19 17:15   ` Jason Chien
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2025-03-11 18:40 UTC (permalink / raw)
  To: Jason Chien; +Cc: qemu-devel, qemu-riscv, Jiri Slaby

On Thu, 27 Feb 2025 at 07:32, Jason Chien <jason.chien@sifive.com> wrote:
>
> This commit renames the macros to accurately reflect the direction of
> DMA operations.
>
> EDU_DMA_TO_PCI now represents reading memory content into the EDU buffer,
> while EDU_DMA_FROM_PCI represents writing EDU buffer content to memory.

The EDU device is a PCI device, so if it is reading
then it is reading data from the PCI bus, and if it is
writing then it is writing data to the PCI bus. So I
think there's an argument that the current names make
sense.

Plus, presumably this device model is implementing the hardware
half of a defined specification. The authoritative source for
what names the 0 and 1 values of the DIR bit should be named
would be that specification.

Where is that spec, and what does it say? If it says 0 for
FROM and 1 for TO, that's what we should use. If it's the
other way around, that's an error in our device implementation
that we should correct.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/misc/edu: Rename macros indicating the direction of DMA operations
  2025-03-11 18:40 ` Peter Maydell
@ 2025-03-19 17:15   ` Jason Chien
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Chien @ 2025-03-19 17:15 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, qemu-riscv, Jiri Slaby

[-- Attachment #1: Type: text/plain, Size: 1607 bytes --]

This is a virtual device designed for educational purposes. The only spec I
found is in QEMU documentation:
https://github.com/qemu/qemu/blob/master/docs/specs/edu.rst
According to the documentation:
direction (0: from RAM to EDU, 1: from EDU to RAM)
The macros confused me and my goal is to make the direction easier to
differentiate. Something like EDU_DMA_TO_PCI_BUS and EDU_DMA_FROM_PCI_BUS
would also work. Do you have any suggestions?

thanks

Peter Maydell <peter.maydell@linaro.org> 於 2025年3月12日 週三 上午2:41寫道:

> On Thu, 27 Feb 2025 at 07:32, Jason Chien <jason.chien@sifive.com> wrote:
> >
> > This commit renames the macros to accurately reflect the direction of
> > DMA operations.
> >
> > EDU_DMA_TO_PCI now represents reading memory content into the EDU buffer,
> > while EDU_DMA_FROM_PCI represents writing EDU buffer content to memory.
>
> The EDU device is a PCI device, so if it is reading
> then it is reading data from the PCI bus, and if it is
> writing then it is writing data to the PCI bus. So I
> think there's an argument that the current names make
> sense.
>
> Plus, presumably this device model is implementing the hardware
> half of a defined specification. The authoritative source for
> what names the 0 and 1 values of the DIR bit should be named
> would be that specification.
>
> Where is that spec, and what does it say? If it says 0 for
> FROM and 1 for TO, that's what we should use. If it's the
> other way around, that's an error in our device implementation
> that we should correct.
>
> thanks
> -- PMM
>

[-- Attachment #2: Type: text/html, Size: 2967 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-19 17:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27  7:30 [PATCH] hw/misc/edu: Rename macros indicating the direction of DMA operations Jason Chien
2025-03-11 11:15 ` Jason Chien
2025-03-11 18:40 ` Peter Maydell
2025-03-19 17:15   ` Jason Chien

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).