Re: [PATCH 2/5] dma: Let st*_pci_dma() take MemTxAttrs argument

2021-12-21 Thread Richard Henderson

On 12/18/21 7:10 AM, Philippe Mathieu-Daudé wrote:

Let devices specify transaction attributes when calling st*_pci_dma().

Keep the default MEMTXATTRS_UNSPECIFIED in the few callers.

Signed-off-by: Philippe Mathieu-Daudé
---
  include/hw/pci/pci.h | 11 ++-
  hw/audio/intel-hda.c | 10 ++
  hw/net/eepro100.c| 29 ++---
  hw/net/tulip.c   | 18 ++
  hw/scsi/megasas.c| 15 ++-
  hw/scsi/vmw_pvscsi.c |  3 ++-
  6 files changed, 52 insertions(+), 34 deletions(-)


Reviewed-by: Richard Henderson 

r~



[PATCH 2/5] dma: Let st*_pci_dma() take MemTxAttrs argument

2021-12-18 Thread Philippe Mathieu-Daudé
Let devices specify transaction attributes when calling st*_pci_dma().

Keep the default MEMTXATTRS_UNSPECIFIED in the few callers.

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/pci/pci.h | 11 ++-
 hw/audio/intel-hda.c | 10 ++
 hw/net/eepro100.c| 29 ++---
 hw/net/tulip.c   | 18 ++
 hw/scsi/megasas.c| 15 ++-
 hw/scsi/vmw_pvscsi.c |  3 ++-
 6 files changed, 52 insertions(+), 34 deletions(-)

diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 8c5f2ed5054..9f51ef2c3c2 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -859,11 +859,12 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, 
dma_addr_t addr,
  MEMTXATTRS_UNSPECIFIED); \
 return val; \
 }   \
-static inline void st##_s##_pci_dma(PCIDevice *dev, \
-dma_addr_t addr, uint##_bits##_t val) \
-{   \
-st##_s##_dma(pci_get_address_space(dev), addr, val, \
- MEMTXATTRS_UNSPECIFIED); \
+static inline void st##_s##_pci_dma(PCIDevice *dev, \
+dma_addr_t addr, \
+uint##_bits##_t val, \
+MemTxAttrs attrs) \
+{ \
+st##_s##_dma(pci_get_address_space(dev), addr, val, attrs); \
 }
 
 PCI_DMA_DEFINE_LDST(ub, b, 8);
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index fb3d34a4a0c..3309ae0ea18 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -345,6 +345,7 @@ static void intel_hda_corb_run(IntelHDAState *d)
 
 static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t 
response)
 {
+const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
 HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus);
 IntelHDAState *d = container_of(bus, IntelHDAState, codecs);
 hwaddr addr;
@@ -367,8 +368,8 @@ static void intel_hda_response(HDACodecDevice *dev, bool 
solicited, uint32_t res
 ex = (solicited ? 0 : (1 << 4)) | dev->cad;
 wp = (d->rirb_wp + 1) & 0xff;
 addr = intel_hda_addr(d->rirb_lbase, d->rirb_ubase);
-stl_le_pci_dma(&d->pci, addr + 8*wp, response);
-stl_le_pci_dma(&d->pci, addr + 8*wp + 4, ex);
+stl_le_pci_dma(&d->pci, addr + 8 * wp, response, attrs);
+stl_le_pci_dma(&d->pci, addr + 8 * wp + 4, ex, attrs);
 d->rirb_wp = wp;
 
 dprint(d, 2, "%s: [wp 0x%x] response 0x%x, extra 0x%x\n",
@@ -394,6 +395,7 @@ static void intel_hda_response(HDACodecDevice *dev, bool 
solicited, uint32_t res
 static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output,
uint8_t *buf, uint32_t len)
 {
+const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
 HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus);
 IntelHDAState *d = container_of(bus, IntelHDAState, codecs);
 hwaddr addr;
@@ -428,7 +430,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t 
stnr, bool output,
st->be, st->bp, st->bpl[st->be].len, copy);
 
 pci_dma_rw(&d->pci, st->bpl[st->be].addr + st->bp, buf, copy, !output,
-   MEMTXATTRS_UNSPECIFIED);
+   attrs);
 st->lpib += copy;
 st->bp += copy;
 buf += copy;
@@ -451,7 +453,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t 
stnr, bool output,
 if (d->dp_lbase & 0x01) {
 s = st - d->st;
 addr = intel_hda_addr(d->dp_lbase & ~0x01, d->dp_ubase);
-stl_le_pci_dma(&d->pci, addr + 8*s, st->lpib);
+stl_le_pci_dma(&d->pci, addr + 8 * s, st->lpib, attrs);
 }
 dprint(d, 3, "dma: --\n");
 
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 16e95ef9cc9..83c4431b1ad 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -700,6 +700,8 @@ static void set_ru_state(EEPRO100State * s, ru_state_t 
state)
 
 static void dump_statistics(EEPRO100State * s)
 {
+const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
+
 /* Dump statistical data. Most data is never changed by the emulation
  * and always 0, so we first just copy the whole block and then those
  * values which really matter.
@@ -707,16 +709,18 @@ static void dump_statistics(EEPRO100State * s)
  */
 pci_dma_write(&s->dev, s->statsaddr, &s->statistics, s->stats_size);
 stl_le_pci_dma(&s->dev, s->statsaddr + 0,
-   s->statistics.tx_good_frames);
+   s->statistics.tx_good_frames, attrs);
 stl_le_pci_dma(&s->dev, s->statsaddr + 36,
-   s->statistics.rx_good_frames);
+   s->statistics.rx_good_frames, attrs);
 stl_le_pci_dma(&s->dev, s->statsaddr + 48,
-   s->statistics.rx_resource_errors);
+   s->statistics.rx_resource_errors, attrs);
 stl_le