diff mbox series

[v3,1/3] hw/pci: Introduce pci_dma_memory_region() helper

Message ID 20210826200720.2196827-2-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series hw/usb: Always expect 'dma' link property to be set to simplify | expand

Commit Message

Philippe Mathieu-Daudé Aug. 26, 2021, 8:07 p.m. UTC
pci_get_address_space() returns an AddressSpace. In some
cases we want a MemoryRegion. Add the pci_dma_memory_region()
equivalent helper.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/hw/pci/pci.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Mark Cave-Ayland Aug. 26, 2021, 8:45 p.m. UTC | #1
On 26/08/2021 21:07, Philippe Mathieu-Daudé wrote:

> pci_get_address_space() returns an AddressSpace. In some
> cases we want a MemoryRegion. Add the pci_dma_memory_region()
> equivalent helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   include/hw/pci/pci.h | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index d0f4266e372..5860f42e400 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -786,6 +786,11 @@ static inline AddressSpace *pci_get_address_space(PCIDevice *dev)
>       return &dev->bus_master_as;
>   }
>   
> +static inline MemoryRegion *pci_dma_memory_region(PCIDevice *dev)
> +{
> +    return &dev->bus_master_container_region;
> +}
> +
>   /**
>    * pci_dma_rw: Read from or write to an address space from PCI device.
>    *

This patch doesn't quite feel right: there are already a number of devices that have 
been using pci_get_address_space() for some time without requiring access to the 
underlying MemoryRegion. So then the first question I ask myself when I see this 
patch is why do we suddenly need it now?


ATB,

Mark.
diff mbox series

Patch

diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index d0f4266e372..5860f42e400 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -786,6 +786,11 @@  static inline AddressSpace *pci_get_address_space(PCIDevice *dev)
     return &dev->bus_master_as;
 }
 
+static inline MemoryRegion *pci_dma_memory_region(PCIDevice *dev)
+{
+    return &dev->bus_master_container_region;
+}
+
 /**
  * pci_dma_rw: Read from or write to an address space from PCI device.
  *