WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: "Wei Wang" <wei.wang2@xxxxxxx>
Subject: Re: [Xen-devel] [PATCH 4 of 6] Add new ATS helper functions
From: "Jan Beulich" <JBeulich@xxxxxxxx>
Date: Fri, 21 Oct 2011 14:11:38 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 21 Oct 2011 06:21:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <f2fbc041f4a710b66f98.1319201723@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1319201719@xxxxxxxxxxxx> <f2fbc041f4a710b66f98.1319201723@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
>>> 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