diff mbox

[v2,2/8] pci: provide a way to reserve some specific devfn

Message ID 1400237624-8505-3-git-send-email-tiejun.chen@intel.com
State New
Headers show

Commit Message

Tiejun Chen May 16, 2014, 10:53 a.m. UTC
Sometime we may need to reserve some specific devfn since
some vgabios or drivers have to work well with a fixed bdf.

Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
---
v2:

* New patch

 hw/pci/pci.c         | 11 +++++++++++
 include/hw/pci/pci.h |  1 +
 2 files changed, 12 insertions(+)

Comments

Konrad Rzeszutek Wilk May 16, 2014, 2:07 p.m. UTC | #1
On Fri, May 16, 2014 at 06:53:38PM +0800, Tiejun Chen wrote:
> Sometime we may need to reserve some specific devfn since
> some vgabios or drivers have to work well with a fixed bdf.
> 
> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> ---
> v2:
> 
> * New patch
> 
>  hw/pci/pci.c         | 11 +++++++++++
>  include/hw/pci/pci.h |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index ef944cf..06b0c92 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -813,6 +813,17 @@ static void do_pci_unregister_device(PCIDevice *pci_dev)
>      memory_region_destroy(&pci_dev->bus_master_enable_region);
>  }
>  
> +
> +void pci_reserve_pci_devfn(PCIBus *bus, uint8_t devfn)
> +{
> +    int ret = test_and_set_bit(devfn, bus->pci_bdf_bitmap);

unsigned int please.
> +    if (ret) {
> +        error_report("PCI: %02x:%02x:%02x is not available to reserve.",
> +                    pci_bus_num(bus), PCI_SLOT(devfn), PCI_FUNC(devfn));
> +        return;
> +    }
> +}

Don't we want to return whether we are failed or not?

> +
>  /* -1 for devfn means auto assign */
>  static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
>                                           const char *name, int devfn)
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 8c25ae5..cbb174e 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -342,6 +342,7 @@ void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
>                           MemoryRegion *address_space_mem,
>                           MemoryRegion *address_space_io,
>                           uint8_t devfn_min, const char *typename);
> +void pci_reserve_pci_devfn(PCIBus *bus, uint8_t devfn);
>  PCIBus *pci_bus_new(DeviceState *parent, const char *name,
>                      MemoryRegion *address_space_mem,
>                      MemoryRegion *address_space_io,
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
Tiejun Chen May 19, 2014, 9:43 a.m. UTC | #2
> -----Original Message-----
> From: Konrad Rzeszutek Wilk [mailto:konrad.wilk@oracle.com]
> Sent: Friday, May 16, 2014 10:07 PM
> To: Chen, Tiejun
> Cc: anthony.perard@citrix.com; stefano.stabellini@eu.citrix.com;
> mst@redhat.com; Kelly.Zytaruk@amd.com; peter.maydell@linaro.org;
> xen-devel@lists.xensource.com; weidong.han@intel.com; Kay, Allen M;
> qemu-devel@nongnu.org; jean.guyader@eu.citrix.com;
> anthony@codemonkey.ws; Zhang, Yang Z
> Subject: Re: [Xen-devel] [v2][PATCH 2/8] pci: provide a way to reserve some
> specific devfn
> 
> On Fri, May 16, 2014 at 06:53:38PM +0800, Tiejun Chen wrote:
> > Sometime we may need to reserve some specific devfn since some vgabios
> > or drivers have to work well with a fixed bdf.
> >
> > Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> > ---
> > v2:
> >
> > * New patch
> >
> >  hw/pci/pci.c         | 11 +++++++++++
> >  include/hw/pci/pci.h |  1 +
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/hw/pci/pci.c b/hw/pci/pci.c index ef944cf..06b0c92 100644
> > --- a/hw/pci/pci.c
> > +++ b/hw/pci/pci.c
> > @@ -813,6 +813,17 @@ static void do_pci_unregister_device(PCIDevice
> *pci_dev)
> >      memory_region_destroy(&pci_dev->bus_master_enable_region);
> >  }
> >
> > +
> > +void pci_reserve_pci_devfn(PCIBus *bus, uint8_t devfn) {
> > +    int ret = test_and_set_bit(devfn, bus->pci_bdf_bitmap);
> 
> unsigned int please.

Fixed.

> > +    if (ret) {
> > +        error_report("PCI: %02x:%02x:%02x is not available to reserve.",
> > +                    pci_bus_num(bus), PCI_SLOT(devfn),
> PCI_FUNC(devfn));
> > +        return;
> > +    }
> > +}
> 
> Don't we want to return whether we are failed or not?

Its my typo so I will remove that "return" simply.

Thanks
Tiejun
diff mbox

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index ef944cf..06b0c92 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -813,6 +813,17 @@  static void do_pci_unregister_device(PCIDevice *pci_dev)
     memory_region_destroy(&pci_dev->bus_master_enable_region);
 }
 
+
+void pci_reserve_pci_devfn(PCIBus *bus, uint8_t devfn)
+{
+    int ret = test_and_set_bit(devfn, bus->pci_bdf_bitmap);
+    if (ret) {
+        error_report("PCI: %02x:%02x:%02x is not available to reserve.",
+                    pci_bus_num(bus), PCI_SLOT(devfn), PCI_FUNC(devfn));
+        return;
+    }
+}
+
 /* -1 for devfn means auto assign */
 static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
                                          const char *name, int devfn)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 8c25ae5..cbb174e 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -342,6 +342,7 @@  void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
                          MemoryRegion *address_space_mem,
                          MemoryRegion *address_space_io,
                          uint8_t devfn_min, const char *typename);
+void pci_reserve_pci_devfn(PCIBus *bus, uint8_t devfn);
 PCIBus *pci_bus_new(DeviceState *parent, const char *name,
                     MemoryRegion *address_space_mem,
                     MemoryRegion *address_space_io,