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

Re: [Xen-devel] [PATCH 4 of 6] Add new ATS helper functions



>>> On 21.10.11 at 14:55, Wei Wang <wei.wang2@xxxxxxx> wrote:
> # HG changeset patch
> # User Wei Wang <wei.wang2@xxxxxxx>
> # Date 1319201422 -7200
> # Node ID f2fbc041f4a710b66f98e76ad8905dcac7920c18
> # Parent  bb1330a1f8c7149fb39578382d9f5dfeef13ffa9
> Add new ATS helper functions
> 
> Signed-off-by Wei Wang <wei.wang2@xxxxxxx>
> 
> diff -r bb1330a1f8c7 -r f2fbc041f4a7 xen/drivers/passthrough/pci.c
> --- a/xen/drivers/passthrough/pci.c   Fri Oct 21 14:50:21 2011 +0200
> +++ b/xen/drivers/passthrough/pci.c   Fri Oct 21 14:50:22 2011 +0200
> @@ -838,6 +838,74 @@ void disable_ats_device(int seg, int bus
>                  seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
>  }
>  
> +int pci_ats_enabled(int seg, int bus, int devfn)
> +{
> +    u32 value;
> +    int pos;
> +
> +    pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
> +    BUG_ON(!pos);
> +
> +    value = pci_conf_read16(seg, bus, PCI_SLOT(devfn),
> +                            PCI_FUNC(devfn), pos + ATS_REG_CTL);
> +    return value & ATS_ENABLE;
> +}
> +
> +static void parse_ats_param(char *s);
> +custom_param("ats", parse_ats_param);
> +
> +bool_t __read_mostly ats_enabled = 1;
> +
> +static void __init parse_ats_param(char *s)
> +{
> +    char *ss;
> +
> +    do {
> +        ss = strchr(s, ',');
> +        if ( ss )
> +            *ss = '\0';
> +
> +        switch ( parse_bool(s) )
> +        {
> +        case 0:
> +            ats_enabled = 0;
> +            break;
> +        case 1:
> +            ats_enabled = 1;
> +            break;
> +        }
> +
> +        s = ss + 1;
> +    } while ( ss );
> +}
> +
> +int pci_ats_device(int seg, int bus, int devfn)
> +{
> +    if ( !ats_enabled )
> +        return 0;
> +
> +    if ( !pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS) )
> +        return 0;
> +
> +    return 1;
> +}
> +
> +struct pci_ats_dev* get_ats_device(int seg, int bus, int devfn)
> +{
> +    struct pci_ats_dev *pdev;
> +
> +    if ( !pci_ats_device(seg, bus, devfn) )
> +        return NULL;
> +
> +    list_for_each_entry ( pdev, &ats_devices, list )
> +    {
> +        if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
> +            return pdev;
> +    }
> +
> +    return NULL;
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff -r bb1330a1f8c7 -r f2fbc041f4a7 xen/drivers/passthrough/vtd/x86/ats.c
> --- a/xen/drivers/passthrough/vtd/x86/ats.c   Fri Oct 21 14:50:21 2011 +0200
> +++ b/xen/drivers/passthrough/vtd/x86/ats.c   Fri Oct 21 14:50:22 2011 +0200
> @@ -29,35 +29,6 @@
>  #include "../extern.h"
>  
>  static LIST_HEAD(ats_dev_drhd_units);
> -
> -static void parse_ats_param(char *s);
> -custom_param("ats", parse_ats_param);
> -
> -bool_t __read_mostly ats_enabled = 1;
> -
> -static void __init parse_ats_param(char *s)
> -{
> -    char *ss;
> -
> -    do {
> -        ss = strchr(s, ',');
> -        if ( ss )
> -            *ss = '\0';
> -
> -        switch ( parse_bool(s) )
> -        {
> -        case 0:
> -            ats_enabled = 0;
> -            break;
> -        case 1:
> -            ats_enabled = 1;
> -            break;
> -        }
> -
> -        s = ss + 1;
> -    } while ( ss );
> -}
> -

Why don't you move this chunk together with the other movement you
do?

Jan

>  struct acpi_drhd_unit * find_ats_dev_drhd(struct iommu *iommu)
>  {
>      struct acpi_drhd_unit *drhd;
> diff -r bb1330a1f8c7 -r f2fbc041f4a7 xen/include/xen/pci.h
> --- a/xen/include/xen/pci.h   Fri Oct 21 14:50:21 2011 +0200
> +++ b/xen/include/xen/pci.h   Fri Oct 21 14:50:22 2011 +0200
> @@ -152,5 +152,8 @@ void pci_enable_acs(struct pci_dev *pdev
>  
>  int enable_ats_device(int seg, int bus, int devfn);
>  void disable_ats_device(int seg, int bus, int devfn);
> +int pci_ats_enabled(int seg, int bus, int devfn);
> +int pci_ats_device(int seg, int bus, int devfn);
> +struct pci_ats_dev* get_ats_device(int seg, int bus, int devfn);
>  
>  #endif /* __XEN_PCI_H__ */
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx 
> http://lists.xensource.com/xen-devel 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.