From: Joerg Roedel <joerg.roedel@amd.com>
To: <iommu@lists.linux-foundation.org>, <linux-kernel@vger.kernel.org>
Cc: Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 9/9] x86/amd-iommu: Store device alias as dev_data pointer
Date: Fri, 10 Jun 2011 14:08:49 +0200 [thread overview]
Message-ID: <1307707729-29767-10-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1307707729-29767-1-git-send-email-joerg.roedel@amd.com>
This finally allows PCI-Device-IDs to be handled by the
IOMMU driver that have no corresponding struct device
present in the system.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/include/asm/amd_iommu_types.h | 2 +-
arch/x86/kernel/amd_iommu.c | 34 ++++++++++++++-----------------
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index fffbe3c..5b9c507 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -311,7 +311,7 @@ struct protection_domain {
struct iommu_dev_data {
struct list_head list; /* For domain->dev_list */
struct list_head dev_data_list; /* For global dev_data_list */
- struct device *alias; /* The Alias Device */
+ struct iommu_dev_data *alias_data;/* The alias dev_data */
struct protection_domain *domain; /* Domain the device is bound to */
atomic_t bind; /* Domain attach reverent count */
u16 devid; /* PCI Device ID */
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index f647998..0ed1c94 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -203,7 +203,6 @@ static bool check_device(struct device *dev)
static int iommu_init_device(struct device *dev)
{
struct iommu_dev_data *dev_data;
- struct pci_dev *pdev;
u16 alias;
if (dev->archdata.iommu)
@@ -215,13 +214,16 @@ static int iommu_init_device(struct device *dev)
alias = amd_iommu_alias_table[dev_data->devid];
if (alias != dev_data->devid) {
- pdev = pci_get_bus_and_slot(PCI_BUS(alias), alias & 0xff);
- if (pdev)
- dev_data->alias = &pdev->dev;
- else {
+ struct iommu_dev_data *alias_data;
+
+ alias_data = find_dev_data(alias);
+ if (alias_data == NULL) {
+ pr_err("AMD-Vi: Warning: Unhandled device %s\n",
+ dev_name(dev));
free_dev_data(dev_data);
return -ENOTSUPP;
}
+ dev_data->alias_data = alias_data;
}
dev->archdata.iommu = dev_data;
@@ -1642,14 +1644,8 @@ static int __attach_device(struct iommu_dev_data *dev_data,
/* lock domain */
spin_lock(&domain->lock);
- if (dev_data->alias != NULL) {
- struct iommu_dev_data *alias_data;
-
- alias_data = get_dev_data(dev_data->alias);
-
- ret = -EINVAL;
- if (!alias_data)
- goto out_unlock;
+ if (dev_data->alias_data != NULL) {
+ struct iommu_dev_data *alias_data = dev_data->alias_data;
/* Some sanity checks */
ret = -EBUSY;
@@ -1721,7 +1717,6 @@ static int attach_device(struct device *dev,
*/
static void __detach_device(struct iommu_dev_data *dev_data)
{
- struct iommu_dev_data *alias_data;
struct protection_domain *domain;
unsigned long flags;
@@ -1731,8 +1726,9 @@ static void __detach_device(struct iommu_dev_data *dev_data)
spin_lock_irqsave(&domain->lock, flags);
- if (dev_data->alias) {
- alias_data = get_dev_data(dev_data->alias);
+ if (dev_data->alias_data != NULL) {
+ struct iommu_dev_data *alias_data = dev_data->alias_data;
+
if (atomic_dec_and_test(&alias_data->bind))
do_detach(alias_data);
}
@@ -1779,7 +1775,7 @@ static void detach_device(struct device *dev)
*/
static struct protection_domain *domain_for_device(struct device *dev)
{
- struct iommu_dev_data *dev_data, *alias_data;
+ struct iommu_dev_data *dev_data;
struct protection_domain *dom = NULL;
unsigned long flags;
@@ -1788,8 +1784,8 @@ static struct protection_domain *domain_for_device(struct device *dev)
if (dev_data->domain)
return dev_data->domain;
- if (dev_data->alias != NULL) {
- alias_data = get_dev_data(dev_data->alias);
+ if (dev_data->alias_data != NULL) {
+ struct iommu_dev_data *alias_data = dev_data->alias_data;
read_lock_irqsave(&amd_iommu_devtable_lock, flags);
if (alias_data->domain != NULL) {
--
1.7.4.1
prev parent reply other threads:[~2011-06-10 12:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-10 12:08 [PATCH 0/9] AMD IOMMU: Reduce dependency to struct device Joerg Roedel
2011-06-10 12:08 ` [PATCH 1/9] x86/amd-iommu: Remove redundant device_flush_dte() calls Joerg Roedel
2011-06-10 12:08 ` [PATCH 2/9] x86/amd-iommu: Introduce global dev_data_list Joerg Roedel
2011-06-10 17:36 ` Chris Wright
2011-06-11 10:27 ` Roedel, Joerg
2011-06-10 12:08 ` [PATCH 3/9] x86/amd-iommu: Store devid in dev_data Joerg Roedel
2011-06-10 12:08 ` [PATCH 4/9] x86/amd-iommu: Store ATS state " Joerg Roedel
2011-06-10 12:08 ` [PATCH 5/9] x86/amd-iommu: Use only dev_data for dte and iotlb flushing routines Joerg Roedel
2011-06-10 12:08 ` [PATCH 6/9] x86/amd-iommu: Use only dev_data in low-level domain attach/detach functions Joerg Roedel
2011-06-10 12:08 ` [PATCH 7/9] x86/amd-iommu: Allow dev_data->alias to be NULL Joerg Roedel
2011-06-10 12:08 ` [PATCH 8/9] x86/amd-iommu: Search for existind dev_data before allocting a new one Joerg Roedel
2011-06-10 20:52 ` Chris Wright
2011-06-11 10:29 ` Roedel, Joerg
2011-06-10 12:08 ` Joerg Roedel [this message]
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=1307707729-29767-10-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®