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

Re: [Xen-devel] [PATCH 1 of 6] ats: Move some ats functions to a new directory



>>> On 25.10.11 at 15:07, Wei Wang <wei.wang2@xxxxxxx> wrote:
> # HG changeset patch
> # User Wei Wang <wei.wang2@xxxxxxx>
> # Date 1319472683 -7200
> # Node ID 217c4a82b202975c2fdff9ae499f065471e5c87b
> # Parent  121af976b2988de389db139231103ceedd11bb8a
> ats: Move some ats functions to a new directory.
> passhrough/x86 holds vendor neutral codes for x86 architecture.
> 
> Signed-off-by: Wei Wang <wei.wang2@xxxxxxx>
>
> diff -r 121af976b298 -r 217c4a82b202 xen/drivers/passthrough/Makefile
> --- a/xen/drivers/passthrough/Makefile        Fri Oct 14 10:17:22 2011 +0200
> +++ b/xen/drivers/passthrough/Makefile        Mon Oct 24 18:11:23 2011 +0200
> @@ -1,6 +1,7 @@
>  subdir-$(x86) += vtd
>  subdir-$(ia64) += vtd
>  subdir-$(x86) += amd
> +subdir-$(x86) += x86
>  
>  obj-y += iommu.o
>  obj-y += io.o
> diff -r 121af976b298 -r 217c4a82b202 xen/drivers/passthrough/vtd/extern.h
> --- a/xen/drivers/passthrough/vtd/extern.h    Fri Oct 14 10:17:22 2011 +0200
> +++ b/xen/drivers/passthrough/vtd/extern.h    Mon Oct 24 18:11:23 2011 +0200
> @@ -57,13 +57,9 @@ struct acpi_drhd_unit * iommu_to_drhd(st
>  struct acpi_rhsa_unit * drhd_to_rhsa(struct acpi_drhd_unit *drhd);
>  
>  #ifdef CONFIG_X86_64
> -extern bool_t ats_enabled;
> -
>  struct acpi_drhd_unit * find_ats_dev_drhd(struct iommu *iommu);
>  
>  int ats_device(int seg, int bus, int devfn);
> -int enable_ats_device(int seg, int bus, int devfn);
> -void disable_ats_device(int seg, int bus, int devfn);
>  int invalidate_ats_tcs(struct iommu *iommu);
>  
>  int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
> diff -r 121af976b298 -r 217c4a82b202 xen/drivers/passthrough/vtd/iommu.c
> --- a/xen/drivers/passthrough/vtd/iommu.c     Fri Oct 14 10:17:22 2011 +0200
> +++ b/xen/drivers/passthrough/vtd/iommu.c     Mon Oct 24 18:11:23 2011 +0200
> @@ -40,6 +40,7 @@
>  #include "dmar.h"
>  #include "extern.h"
>  #include "vtd.h"
> +#include "../x86/ats.h"

#include <asm/ats.h>

which would imply that ia64 needs such a header, too, so perhaps even

#include <xen/ats.h>

or maybe

#include "../ats.h"

But there's no way you can include x86-only headers here.

Beyond that, this patch looks fine to me.

Jan

>  #ifdef __ia64__
>  #define nr_ioapics              iosapic_get_nr_iosapics()
> diff -r 121af976b298 -r 217c4a82b202 xen/drivers/passthrough/vtd/x86/ats.c
> --- a/xen/drivers/passthrough/vtd/x86/ats.c   Fri Oct 14 10:17:22 2011 +0200
> +++ b/xen/drivers/passthrough/vtd/x86/ats.c   Mon Oct 24 18:11:23 2011 +0200
> @@ -27,51 +27,10 @@
>  #include "../dmar.h"
>  #include "../vtd.h"
>  #include "../extern.h"
> +#include "../../x86/ats.h"
>  
>  static LIST_HEAD(ats_dev_drhd_units);
>  
> -#define ATS_REG_CAP    4
> -#define ATS_REG_CTL    6
> -#define ATS_QUEUE_DEPTH_MASK     0xF
> -#define ATS_ENABLE               (1<<15)
> -
> -struct pci_ats_dev {
> -    struct list_head list;
> -    u16 seg;
> -    u8 bus;
> -    u8 devfn;
> -    u16 ats_queue_depth;    /* ATS device invalidation queue depth */
> -};
> -static LIST_HEAD(ats_devices);
> -
> -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 );
> -}
> -
>  struct acpi_drhd_unit * find_ats_dev_drhd(struct iommu *iommu)
>  {
>      struct acpi_drhd_unit *drhd;
> @@ -121,97 +80,6 @@ int ats_device(int seg, int bus, int dev
>      return pos;
>  }
>  
> -int enable_ats_device(int seg, int bus, int devfn)
> -{
> -    struct pci_ats_dev *pdev = NULL;
> -    u32 value;
> -    int pos;
> -
> -    pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
> -    BUG_ON(!pos);
> -
> -    if ( iommu_verbose )
> -        dprintk(XENLOG_INFO VTDPREFIX,
> -                "%04x:%02x:%02x.%u: ATS capability found\n",
> -                seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
> -
> -    value = pci_conf_read16(seg, bus, PCI_SLOT(devfn),
> -                            PCI_FUNC(devfn), pos + ATS_REG_CTL);
> -    if ( value & ATS_ENABLE )
> -    {
> -        list_for_each_entry ( pdev, &ats_devices, list )
> -        {
> -            if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == 
> devfn )
> -            {
> -                pos = 0;
> -                break;
> -            }
> -        }
> -    }
> -    if ( pos )
> -        pdev = xmalloc(struct pci_ats_dev);
> -    if ( !pdev )
> -        return -ENOMEM;
> -
> -    if ( !(value & ATS_ENABLE) )
> -    {
> -        value |= ATS_ENABLE;
> -        pci_conf_write16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
> -                         pos + ATS_REG_CTL, value);
> -    }
> -
> -    if ( pos )
> -    {
> -        pdev->seg = seg;
> -        pdev->bus = bus;
> -        pdev->devfn = devfn;
> -        value = pci_conf_read16(seg, bus, PCI_SLOT(devfn),
> -                                PCI_FUNC(devfn), pos + ATS_REG_CAP);
> -        pdev->ats_queue_depth = value & ATS_QUEUE_DEPTH_MASK;
> -        list_add(&pdev->list, &ats_devices);
> -    }
> -
> -    if ( iommu_verbose )
> -        dprintk(XENLOG_INFO VTDPREFIX,
> -                "%04x:%02x:%02x.%u: ATS %s enabled\n",
> -                seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
> -                pos ? "is" : "was");
> -
> -    return pos;
> -}
> -
> -void disable_ats_device(int seg, int bus, int devfn)
> -{
> -    struct pci_ats_dev *pdev;
> -    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);
> -    value &= ~ATS_ENABLE;
> -    pci_conf_write16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
> -                     pos + ATS_REG_CTL, value);
> -
> -    list_for_each_entry ( pdev, &ats_devices, list )
> -    {
> -        if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
> -        {
> -            list_del(&pdev->list);
> -            xfree(pdev);
> -            break;
> -        }
> -    }
> -
> -    if ( iommu_verbose )
> -        dprintk(XENLOG_INFO VTDPREFIX,
> -                "%04x:%02x:%02x.%u: ATS is disabled\n",
> -                seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
> -}
> -
> -
>  static int device_in_domain(struct iommu *iommu, struct pci_ats_dev *pdev, 
> u16 did)
>  {
>      struct root_entry *root_entry = NULL;
> diff -r 121af976b298 -r 217c4a82b202 xen/drivers/passthrough/x86/Makefile
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/xen/drivers/passthrough/x86/Makefile    Mon Oct 24 18:11:23 2011 +0200
> @@ -0,0 +1,1 @@
> +obj-y += ats.o
> \ No newline at end of file
> diff -r 121af976b298 -r 217c4a82b202 xen/drivers/passthrough/x86/ats.c
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/xen/drivers/passthrough/x86/ats.c       Mon Oct 24 18:11:23 2011 +0200
> @@ -0,0 +1,139 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
> for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program; if not, write to the Free Software Foundation, Inc., 59 
> Temple
> + * Place - Suite 330, Boston, MA 02111-1307 USA.
> + */
> +
> +#include <xen/sched.h>
> +#include <xen/pci.h>
> +#include <xen/pci_regs.h>
> +#include "ats.h"
> +
> +LIST_HEAD(ats_devices);
> +
> +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 enable_ats_device(int seg, int bus, int devfn)
> +{
> +    struct pci_ats_dev *pdev = NULL;
> +    u32 value;
> +    int pos;
> +
> +    pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
> +    BUG_ON(!pos);
> +
> +    if ( iommu_verbose )
> +        dprintk(XENLOG_INFO VTDPREFIX,
> +                "%04x:%02x:%02x.%u: ATS capability found\n",
> +                seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
> +
> +    value = pci_conf_read16(seg, bus, PCI_SLOT(devfn),
> +                            PCI_FUNC(devfn), pos + ATS_REG_CTL);
> +    if ( value & ATS_ENABLE )
> +    {
> +        list_for_each_entry ( pdev, &ats_devices, list )
> +        {
> +            if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == 
> devfn )
> +            {
> +                pos = 0;
> +                break;
> +            }
> +        }
> +    }
> +    if ( pos )
> +        pdev = xmalloc(struct pci_ats_dev);
> +    if ( !pdev )
> +        return -ENOMEM;
> +
> +    if ( !(value & ATS_ENABLE) )
> +    {
> +        value |= ATS_ENABLE;
> +        pci_conf_write16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
> +                         pos + ATS_REG_CTL, value);
> +    }
> +
> +    if ( pos )
> +    {
> +        pdev->seg = seg;
> +        pdev->bus = bus;
> +        pdev->devfn = devfn;
> +        value = pci_conf_read16(seg, bus, PCI_SLOT(devfn),
> +                                PCI_FUNC(devfn), pos + ATS_REG_CAP);
> +        pdev->ats_queue_depth = value & ATS_QUEUE_DEPTH_MASK;
> +        list_add(&pdev->list, &ats_devices);
> +    }
> +
> +    if ( iommu_verbose )
> +        dprintk(XENLOG_INFO VTDPREFIX,
> +                "%04x:%02x:%02x.%u: ATS %s enabled\n",
> +                seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
> +                pos ? "is" : "was");
> +
> +    return pos;
> +}
> +
> +void disable_ats_device(int seg, int bus, int devfn)
> +{
> +    struct pci_ats_dev *pdev;
> +    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);
> +    value &= ~ATS_ENABLE;
> +    pci_conf_write16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
> +                     pos + ATS_REG_CTL, value);
> +
> +    list_for_each_entry ( pdev, &ats_devices, list )
> +    {
> +        if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
> +        {
> +            list_del(&pdev->list);
> +            xfree(pdev);
> +            break;
> +        }
> +    }
> +
> +    if ( iommu_verbose )
> +        dprintk(XENLOG_INFO VTDPREFIX,
> +                "%04x:%02x:%02x.%u: ATS is disabled\n",
> +                seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
> +}
> diff -r 121af976b298 -r 217c4a82b202 xen/drivers/passthrough/x86/ats.h
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/xen/drivers/passthrough/x86/ats.h       Mon Oct 24 18:11:23 2011 +0200
> @@ -0,0 +1,38 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
> for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program; if not, write to the Free Software Foundation, Inc., 59 
> Temple
> + * Place - Suite 330, Boston, MA 02111-1307 USA.
> + */
> +
> +#ifndef _X86_ATS_H_
> +#define _X86_ATS_H_
> +
> +#define ATS_REG_CAP    4
> +#define ATS_REG_CTL    6
> +#define ATS_QUEUE_DEPTH_MASK     0xF
> +#define ATS_ENABLE               (1<<15)
> +
> +struct pci_ats_dev {
> +    struct list_head list;
> +    u16 seg;
> +    u8 bus;
> +    u8 devfn;
> +    u16 ats_queue_depth;    /* ATS device invalidation queue depth */
> +};
> +
> +extern struct list_head ats_devices;
> +extern bool_t ats_enabled;
> +
> +int enable_ats_device(int seg, int bus, int devfn);
> +void disable_ats_device(int seg, int bus, int devfn);
> +
> +#endif /* _X86_ATS_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®.