All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] hw/dma: sifive_pdma: Fix Control.claim bit detection
@ 2021-09-27  7:21 Bin Meng
  2021-09-27  7:21 ` [PATCH v2 2/2] hw/dma: sifive_pdma: Don't run DMA when channel is disclaimed Bin Meng
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Bin Meng @ 2021-09-27  7:21 UTC (permalink / raw)
  To: Alistair Francis, qemu-devel, qemu-riscv
  Cc: Frank Chang, Philippe Mathieu-Daudé, Markus Armbruster

At present the codes detect whether the DMA channel is claimed by:

  claimed = !!s->chan[ch].control & CONTROL_CLAIM;

As ! has higher precedence over & (bitwise and), this is essentially

  claimed = (!!s->chan[ch].control) & CONTROL_CLAIM;

which is wrong, as any non-zero bit set in the control register will
produce a result of a claimed channel.

Fixes: de7c7988d25d ("hw/dma: sifive_pdma: reset Next* registers when Control.claim is set")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v2:
- reword the commit message

 hw/dma/sifive_pdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/dma/sifive_pdma.c b/hw/dma/sifive_pdma.c
index b4fd40573a..b8ec7621f3 100644
--- a/hw/dma/sifive_pdma.c
+++ b/hw/dma/sifive_pdma.c
@@ -243,7 +243,7 @@ static void sifive_pdma_write(void *opaque, hwaddr offset,
     offset &= 0xfff;
     switch (offset) {
     case DMA_CONTROL:
-        claimed = !!s->chan[ch].control & CONTROL_CLAIM;
+        claimed = !!(s->chan[ch].control & CONTROL_CLAIM);
 
         if (!claimed && (value & CONTROL_CLAIM)) {
             /* reset Next* registers */
-- 
2.25.1



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

end of thread, other threads:[~2021-09-28 23:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27  7:21 [PATCH v2 1/2] hw/dma: sifive_pdma: Fix Control.claim bit detection Bin Meng
2021-09-27  7:21 ` [PATCH v2 2/2] hw/dma: sifive_pdma: Don't run DMA when channel is disclaimed Bin Meng
2021-09-28 22:46   ` Alistair Francis
2021-09-28 22:46     ` Alistair Francis
2021-09-28 23:15   ` Alistair Francis
2021-09-28 23:15     ` Alistair Francis
2021-09-27 12:56 ` [PATCH v2 1/2] hw/dma: sifive_pdma: Fix Control.claim bit detection Philippe Mathieu-Daudé
2021-09-27 13:14   ` Bin Meng
2021-09-27 13:14     ` Bin Meng
2021-09-28 22:45 ` Alistair Francis
2021-09-28 22:45   ` Alistair Francis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.