All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang2 <wei.wang2@amd.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Allen M Kay <allen.m.kay@intel.com>
Subject: Re: [PATCH 1 of 6] Move some ats functions into	 vendor neutral directories
Date: Fri, 21 Oct 2011 15:57:22 +0200	[thread overview]
Message-ID: <201110211557.22432.wei.wang2@amd.com> (raw)
In-Reply-To: <4EA18B02020000780005CC0B@nat28.tlf.novell.com>

On Friday 21 October 2011 15:08:50 Jan Beulich wrote:
> >>> On 21.10.11 at 14:55, Wei Wang <wei.wang2@amd.com> wrote:
> >
> > # HG changeset patch
> > # User Wei Wang <wei.wang2@amd.com>
> > # Date 1319201416 -7200
> > # Node ID a559e27ffb2c2a3a90dc25f09205b66668dcdbbb
> > # Parent  121af976b2988de389db139231103ceedd11bb8a
> > Move some ats functions into vendor neutral directories.
>
> You move them from an x86-specific place to common code. I suppose
> Intel had reasons to expect them to be implemented differently in ia64.
> Hence they should go into e.g. xen/drivers/passthrough/x86/ instead.
>
> Jan

Well, we don't have that directory yet. Could we change folder structures  in 
passthrough to be architecture first, then vendors, for example:
passthough/x86/vtd
passthough/x86/amd                             
passthough/ia64/vtd

Thanks,
Wei


> > Signed-off-by: Wei Wang <wei.wang2@amd.com>
> >
> > diff -r 121af976b298 -r a559e27ffb2c xen/drivers/passthrough/pci.c
> > --- a/xen/drivers/passthrough/pci.c	Fri Oct 14 10:17:22 2011 +0200
> > +++ b/xen/drivers/passthrough/pci.c	Fri Oct 21 14:50:16 2011 +0200
> > @@ -748,6 +748,95 @@ static int __init setup_dump_pcidevs(voi
> >  __initcall(setup_dump_pcidevs);
> >  #endif
> >
> > +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));
> > +}
> >
> >  /*
> >   * Local variables:
> > diff -r 121af976b298 -r a559e27ffb2c 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	Fri Oct 21 14:50:16 2011 +0200
> > @@ -62,8 +62,6 @@ 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 a559e27ffb2c
> > 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	Fri Oct 21 14:50:16 2011
> > +0200 @@ -30,20 +30,6 @@
> >
> >  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);
> >
> > @@ -121,97 +107,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 a559e27ffb2c xen/include/xen/pci.h
> > --- a/xen/include/xen/pci.h	Fri Oct 14 10:17:22 2011 +0200
> > +++ b/xen/include/xen/pci.h	Fri Oct 21 14:50:16 2011 +0200
> > @@ -63,6 +63,20 @@ struct pci_dev {
> >      u64 vf_rlen[6];
> >  };
> >
> > +#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);
> > +
> >  #define for_each_pdev(domain, pdev) \
> >      list_for_each_entry(pdev, &(domain->arch.pdev_list), domain_list)
> >
> > @@ -136,4 +150,7 @@ void msixtbl_pt_unregister(struct domain
> >  void msixtbl_pt_cleanup(struct domain *d);
> >  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);
> > +
> >  #endif /* __XEN_PCI_H__ */
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel

  reply	other threads:[~2011-10-21 13:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21 12:55 [PATCH 0 of 6] amd iommu: add ats device support Wei Wang
2011-10-21 12:55 ` [PATCH 1 of 6] Move some ats functions into vendor neutral directories Wei Wang
2011-10-21 13:08   ` Jan Beulich
2011-10-21 13:57     ` Wei Wang2 [this message]
2011-10-21 14:07       ` [PATCH 1 of 6] Move some ats functions into vendor neutraldirectories Jan Beulich
2011-10-21 12:55 ` [PATCH 2 of 6] Remove VTD prefix from debug output Wei Wang
2011-10-21 12:55 ` [PATCH 3 of 6] Fix iommu page size encoding when page order > 0 Wei Wang
2011-10-21 12:55 ` [PATCH 4 of 6] Add new ATS helper functions Wei Wang
2011-10-21 13:11   ` Jan Beulich
2011-10-21 13:58     ` Wei Wang2
2011-10-21 12:55 ` [PATCH 5 of 6] Add iotlb invalidation command for amd iommu Wei Wang
2011-10-21 12:55 ` [PATCH 6 of 6] Enable ats devices on amd iommu systems Wei Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201110211557.22432.wei.wang2@amd.com \
    --to=wei.wang2@amd.com \
    --cc=JBeulich@suse.com \
    --cc=allen.m.kay@intel.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.