From: Wan Zongshun <vincent.wan@amd.com> To: Joerg Roedel <joro@8bytes.org>, <iommu@lists.linux-foundation.org> Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>, Borislav Petkov <bp@suse.de>, Ray Huang <ray.huang@amd.com>, <vw@iommu.org>, <mcuos.com@gmail.com>, <linux-kernel@vger.kernel.org>, Wan Zongshun <Vincent.Wan@amd.com> Subject: [PATCH V3 8/9] iommu/amd: Manage iommu_group for ACPI HID devices Date: Fri, 1 Apr 2016 09:06:04 -0400 [thread overview] Message-ID: <1459515965-2865-9-git-send-email-vincent.wan@amd.com> (raw) In-Reply-To: <1459515965-2865-1-git-send-email-vincent.wan@amd.com> From: Wan Zongshun <Vincent.Wan@amd.com> This patch creates a new function for finding or creating an IOMMU group for acpihid(ACPI Hardware ID) device. The acpihid devices with the same devid will be put into same group and there will have the same domain id and share the same page table. Signed-off-by: Wan Zongshun <Vincent.Wan@amd.com> --- drivers/iommu/amd_iommu.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 0df651a3..713e7ea 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -276,6 +276,29 @@ static struct iommu_dev_data *get_dev_data(struct device *dev) return dev->archdata.iommu; } +/* +* Find or create an IOMMU group for a acpihid device. +*/ +static struct iommu_group *acpihid_device_group(struct device *dev) +{ + struct acpihid_map_entry *p, *entry = NULL; + u16 devid; + + devid = get_acpihid_device_id(dev, &entry); + if (devid < 0) + return ERR_PTR(devid); + + list_for_each_entry(p, &acpihid_map, list) { + if ((devid == p->devid) && p->group) + entry->group = p->group; + } + + if (!entry->group) + entry->group = generic_device_group(dev); + + return entry->group; +} + static bool pci_iommuv2_capable(struct pci_dev *pdev) { static const int caps[] = { @@ -2445,6 +2468,14 @@ static void amd_iommu_remove_device(struct device *dev) iommu_completion_wait(iommu); } +static struct iommu_group *amd_iommu_device_group(struct device *dev) +{ + if (dev_is_pci(dev)) + return pci_device_group(dev); + + return acpihid_device_group(dev); +} + /***************************************************************************** * * The next functions belong to the dma_ops mapping/unmapping code. @@ -3286,7 +3317,7 @@ static const struct iommu_ops amd_iommu_ops = { .iova_to_phys = amd_iommu_iova_to_phys, .add_device = amd_iommu_add_device, .remove_device = amd_iommu_remove_device, - .device_group = pci_device_group, + .device_group = amd_iommu_device_group, .get_dm_regions = amd_iommu_get_dm_regions, .put_dm_regions = amd_iommu_put_dm_regions, .pgsize_bitmap = AMD_IOMMU_PGSIZES, -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: Wan Zongshun <vincent.wan-5C7GfCeVMHo@public.gmane.org> To: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Wan Zongshun <Vincent.Wan-5C7GfCeVMHo@public.gmane.org>, Ray Huang <ray.huang-5C7GfCeVMHo@public.gmane.org>, Borislav Petkov <bp-l3A5Bk7waGM@public.gmane.org> Subject: [PATCH V3 8/9] iommu/amd: Manage iommu_group for ACPI HID devices Date: Fri, 1 Apr 2016 09:06:04 -0400 [thread overview] Message-ID: <1459515965-2865-9-git-send-email-vincent.wan@amd.com> (raw) In-Reply-To: <1459515965-2865-1-git-send-email-vincent.wan-5C7GfCeVMHo@public.gmane.org> From: Wan Zongshun <Vincent.Wan-5C7GfCeVMHo@public.gmane.org> This patch creates a new function for finding or creating an IOMMU group for acpihid(ACPI Hardware ID) device. The acpihid devices with the same devid will be put into same group and there will have the same domain id and share the same page table. Signed-off-by: Wan Zongshun <Vincent.Wan-5C7GfCeVMHo@public.gmane.org> --- drivers/iommu/amd_iommu.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 0df651a3..713e7ea 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -276,6 +276,29 @@ static struct iommu_dev_data *get_dev_data(struct device *dev) return dev->archdata.iommu; } +/* +* Find or create an IOMMU group for a acpihid device. +*/ +static struct iommu_group *acpihid_device_group(struct device *dev) +{ + struct acpihid_map_entry *p, *entry = NULL; + u16 devid; + + devid = get_acpihid_device_id(dev, &entry); + if (devid < 0) + return ERR_PTR(devid); + + list_for_each_entry(p, &acpihid_map, list) { + if ((devid == p->devid) && p->group) + entry->group = p->group; + } + + if (!entry->group) + entry->group = generic_device_group(dev); + + return entry->group; +} + static bool pci_iommuv2_capable(struct pci_dev *pdev) { static const int caps[] = { @@ -2445,6 +2468,14 @@ static void amd_iommu_remove_device(struct device *dev) iommu_completion_wait(iommu); } +static struct iommu_group *amd_iommu_device_group(struct device *dev) +{ + if (dev_is_pci(dev)) + return pci_device_group(dev); + + return acpihid_device_group(dev); +} + /***************************************************************************** * * The next functions belong to the dma_ops mapping/unmapping code. @@ -3286,7 +3317,7 @@ static const struct iommu_ops amd_iommu_ops = { .iova_to_phys = amd_iommu_iova_to_phys, .add_device = amd_iommu_add_device, .remove_device = amd_iommu_remove_device, - .device_group = pci_device_group, + .device_group = amd_iommu_device_group, .get_dm_regions = amd_iommu_get_dm_regions, .put_dm_regions = amd_iommu_put_dm_regions, .pgsize_bitmap = AMD_IOMMU_PGSIZES, -- 1.9.1
next prev parent reply other threads:[~2016-04-01 5:29 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-04-01 13:05 [PATCH V3 0/9] iommu/amd: enable ACPI hardware ID device support Wan Zongshun 2016-04-01 13:05 ` Wan Zongshun 2016-04-01 13:05 ` [PATCH V3 1/9] iommu/amd: Adding Extended Feature Register check for PC support Wan Zongshun 2016-04-01 13:05 ` Wan Zongshun 2016-04-01 13:05 ` [PATCH V3 2/9] iommu/amd: Modify ivhd_header structure to support type 11h and 40h Wan Zongshun 2016-04-01 13:05 ` Wan Zongshun 2016-04-01 13:05 ` [PATCH V3 3/9] iommu/amd: Use the most comprehensive IVHD type that the driver can support Wan Zongshun 2016-04-01 13:05 ` Wan Zongshun 2016-04-01 13:06 ` [PATCH V3 4/9] iommu/amd: Add new map for storing IVHD dev entry type HID Wan Zongshun 2016-04-01 13:06 ` Wan Zongshun 2016-04-01 13:06 ` [PATCH V3 5/9] iommu/amd: Introduces ivrs_acpihid kernel parameter Wan Zongshun 2016-04-01 13:06 ` Wan Zongshun 2016-04-01 13:06 ` [PATCH V3 6/9] iommu/amd: Make call-sites of get_device_id aware of its return value Wan Zongshun 2016-04-01 13:06 ` Wan Zongshun 2016-04-01 13:06 ` [PATCH V3 7/9] iommu/amd: Add iommu support for ACPI HID devices Wan Zongshun 2016-04-01 13:06 ` Wan Zongshun 2016-04-01 13:06 ` Wan Zongshun [this message] 2016-04-01 13:06 ` [PATCH V3 8/9] iommu/amd: Manage iommu_group " Wan Zongshun 2016-04-01 13:06 ` [PATCH V3 9/9] iommu/amd: Set AMD iommu callbacks for amba bus Wan Zongshun 2016-04-01 13:06 ` Wan Zongshun 2016-04-07 11:30 ` [PATCH V3 0/9] iommu/amd: enable ACPI hardware ID device support Joerg Roedel 2016-04-07 11:30 ` Joerg Roedel
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=1459515965-2865-9-git-send-email-vincent.wan@amd.com \ --to=vincent.wan@amd.com \ --cc=Suravee.Suthikulpanit@amd.com \ --cc=bp@suse.de \ --cc=iommu@lists.linux-foundation.org \ --cc=joro@8bytes.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mcuos.com@gmail.com \ --cc=ray.huang@amd.com \ --cc=vw@iommu.org \ /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: linkBe 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.