Re: [PATCH kvm-unit-tests 10/17] pci: provide pci_set_master()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 26, 2016 at 03:47:13PM +0800, Peter Xu wrote:
> We need to call this whenever we want to do DMA with a device.
> 
> Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> ---
>  lib/pci.c | 7 +++++++
>  lib/pci.h | 1 +
>  2 files changed, 8 insertions(+)
> 
> diff --git a/lib/pci.c b/lib/pci.c
> index 95a6581..1495f61 100644
> --- a/lib/pci.c
> +++ b/lib/pci.c
> @@ -7,6 +7,13 @@
>  #include "pci.h"
>  #include "asm/pci.h"
>  
> +void pci_set_master(struct pci_dev *dev, int master)

Why take pci_dev instead of just the devid/bdf here?
What is the 'master' argument (which is unused and at least
needs an __unused to compile) here for?

> +{
> +	uint32_t val = pci_config_readw(dev->pci_bdf, PCI_COMMAND);
> +	val |= PCI_COMMAND_MASTER;
> +	pci_config_writew(dev->pci_bdf, PCI_COMMAND, val);

Hmm... Alex uses pci_config_writel for the PCI_COMMAND register.
I see writew is correct. Need to go back his series and make another
comment...

> +}
> +
>  bool pci_dev_exists(pcidevaddr_t dev)
>  {
>  	return (pci_config_readw(dev, PCI_VENDOR_ID) != 0xffff &&
> diff --git a/lib/pci.h b/lib/pci.h
> index e48045c..46657f4 100644
> --- a/lib/pci.h
> +++ b/lib/pci.h
> @@ -25,6 +25,7 @@ struct pci_dev {
>  
>  void pci_dev_init(struct pci_dev *dev, pcidevaddr_t bdf);
>  void pci_scan_bars(struct pci_dev *dev);
> +void pci_set_master(struct pci_dev *dev, int master);
>  
>  extern bool pci_probe(void);
>  extern void pci_print(void);
> -- 
> 2.7.4
>

drew
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux