From: Megha Dey <megha.dey@linux.intel.com>
To: bhelgaas@google.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: tglx@linutronix.de, marc.zyngier@arm.com, ashok.raj@intel.com,
jacob.jun.pan@linux.intel.com, megha.dey@intel.com,
Megha Dey <megha.dey@linux.intel.com>
Subject: [RFC V1 RESEND 4/6] PCI/MSI: Introduce new structure to manage MSI-x entries
Date: Fri, 21 Jun 2019 17:19:36 -0700 [thread overview]
Message-ID: <1561162778-12669-5-git-send-email-megha.dey@linux.intel.com> (raw)
In-Reply-To: <1561162778-12669-1-git-send-email-megha.dey@linux.intel.com>
This is a preparatory patch to introduce disabling of MSI-X vectors
belonging to a particular group. In this patch, we introduce a new
structure msix_sysfs, which manages sysfs entries for dynamically
allocated MSI-X vectors belonging to a particular group.
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Megha Dey <megha.dey@linux.intel.com>
---
drivers/pci/msi.c | 12 +++++++++++-
drivers/pci/probe.c | 1 +
include/linux/pci.h | 9 +++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index fd7fa6e..e947243 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -479,10 +479,11 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
struct device_attribute *msi_dev_attr;
struct attribute_group *msi_irq_group;
const struct attribute_group **msi_irq_groups;
+ struct msix_sysfs *msix_sysfs_entry;
struct msi_desc *entry;
int ret = -ENOMEM;
int num_msi = 0;
- int count = 0;
+ int count = 0, group = -1;
int i;
/* Determine how many msi entries we have */
@@ -509,6 +510,8 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
goto error_attrs;
msi_dev_attr->attr.mode = S_IRUGO;
msi_dev_attr->show = msi_mode_show;
+ if (!i)
+ group = entry->group_id;
++count;
}
}
@@ -524,6 +527,13 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
goto error_irq_group;
msi_irq_groups[0] = msi_irq_group;
+ msix_sysfs_entry = kzalloc(sizeof(*msix_sysfs_entry) * 2, GFP_KERNEL);
+ msix_sysfs_entry->msi_irq_group = msi_irq_group;
+ msix_sysfs_entry->group_id = group;
+ msix_sysfs_entry->vecs_in_grp = count;
+ INIT_LIST_HEAD(&msix_sysfs_entry->list);
+ list_add_tail(&msix_sysfs_entry->list, &pdev->msix_sysfs);
+
if (!pdev->msix_enabled)
ret = sysfs_create_group(&pdev->dev.kobj, msi_irq_group);
else
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 491c1cf..bb20ef6 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2435,6 +2435,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
idr_init(dev->grp_idr);
INIT_LIST_HEAD(&dev->bus_list);
+ INIT_LIST_HEAD(&dev->msix_sysfs);
dev->dev.type = &pci_dev_type;
dev->bus = pci_bus_get(bus);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c56462c..73385c0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -471,6 +471,7 @@ struct pci_dev {
struct idr *grp_idr; /* IDR to assign group to MSI-X vecs */
unsigned long *entry; /* Bitmap to represent MSI-X entries */
bool one_shot; /* If true, oneshot MSI-X allocation */
+ struct list_head msix_sysfs; /* sysfs entries for MSI-X group */
};
static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
@@ -1390,6 +1391,14 @@ struct msix_entry {
u16 entry; /* Driver uses to specify entry, OS writes */
};
+/* Manage sysfs entries for dynamically allocated MSI-X vectors */
+struct msix_sysfs {
+ struct attribute_group *msi_irq_group;
+ struct list_head list;
+ int group_id;
+ int vecs_in_grp;
+};
+
#ifdef CONFIG_PCI_MSI
int pci_msi_vec_count(struct pci_dev *dev);
void pci_disable_msi(struct pci_dev *dev);
--
2.7.4
next prev parent reply other threads:[~2019-06-21 23:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-22 0:19 [RFC V1 RESEND 0/6] Introduce dynamic allocation/freeing of MSI-X vectors Megha Dey
2019-06-22 0:19 ` [RFC V1 RESEND 1/6] PCI/MSI: New structures/macros for dynamic MSI-X allocation Megha Dey
2019-06-22 0:19 ` [RFC V1 RESEND 2/6] PCI/MSI: Dynamic allocation of MSI-X vectors by group Megha Dey
2019-06-29 7:59 ` Thomas Gleixner
2019-08-06 19:05 ` Megha Dey
2019-08-07 13:56 ` Thomas Gleixner
2019-08-07 14:18 ` Marc Zyngier
2019-08-11 7:20 ` Thomas Gleixner
2019-08-12 17:54 ` Megha Dey
2019-08-12 17:48 ` Megha Dey
2019-08-12 17:47 ` Megha Dey
2021-01-07 22:30 ` Jacob Keller
2019-06-22 0:19 ` [RFC V1 RESEND 3/6] x86: Introduce the dynamic teardown function Megha Dey
2019-06-29 8:01 ` Thomas Gleixner
2019-08-06 19:06 ` Megha Dey
2019-06-22 0:19 ` Megha Dey [this message]
2019-06-22 0:19 ` [RFC V1 RESEND 5/6] PCI/MSI: Free MSI-X resources by group Megha Dey
2019-06-29 8:08 ` Thomas Gleixner
2019-08-06 19:09 ` Megha Dey
2019-08-11 7:18 ` Thomas Gleixner
2019-08-12 18:13 ` Megha Dey
2019-06-22 0:19 ` [RFC V1 RESEND 6/6] Documentation: PCI/MSI: Document dynamic MSI-X infrastructure Megha Dey
2019-08-02 0:24 ` [RFC V1 RESEND 0/6] Introduce dynamic allocation/freeing of MSI-X vectors Bjorn Helgaas
2019-08-06 19:12 ` Megha Dey
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=1561162778-12669-5-git-send-email-megha.dey@linux.intel.com \
--to=megha.dey@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=bhelgaas@google.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=megha.dey@intel.com \
--cc=tglx@linutronix.de \
/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
Powered by JetHome