From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Halil Pasic <pasic@linux.ibm.com>, linux-s390@vger.kernel.org
Subject: [PATCH v2] s390/pci: fix CPU address in MSI for directed IRQ
Date: Thu, 26 Nov 2020 13:19:34 +0100 [thread overview]
Message-ID: <20201126121934.GA514@oc3871087118.ibm.com> (raw)
In-Reply-To: <a3be779d-6103-014a-3090-a0ea86c5668a@linux.ibm.com>
The directed MSIs are delivered to CPUs whose address is
written to the MSI message data. The current code assumes
that a CPU logical number (as it is seen by the kernel)
is also that CPU address.
The above assumption is not correct, as the CPU address
is rather the value returned by STAP instruction. That
value is not necessarily matches the kernel logical CPU
number.
Fixes: e979ce7bced2 ("s390/pci: provide support for CPU directed interrupts")
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
arch/s390/pci/pci_irq.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
index 743f257cf2cb..1309fd302f58 100644
--- a/arch/s390/pci/pci_irq.c
+++ b/arch/s390/pci/pci_irq.c
@@ -103,9 +103,10 @@ static int zpci_set_irq_affinity(struct irq_data *data, const struct cpumask *de
{
struct msi_desc *entry = irq_get_msi_desc(data->irq);
struct msi_msg msg = entry->msg;
+ int cpu_addr = smp_cpu_get_cpu_address(cpumask_first(dest));
msg.address_lo &= 0xff0000ff;
- msg.address_lo |= (cpumask_first(dest) << 8);
+ msg.address_lo |= (cpu_addr << 8);
pci_write_msi_msg(data->irq, &msg);
return IRQ_SET_MASK_OK;
@@ -238,6 +239,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
unsigned long bit;
struct msi_desc *msi;
struct msi_msg msg;
+ int cpu_addr;
int rc, irq;
zdev->aisb = -1UL;
@@ -287,9 +289,16 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
handle_percpu_irq);
msg.data = hwirq - bit;
if (irq_delivery == DIRECTED) {
+ if (msi->affinity) {
+ cpu = cpumask_first(&msi->affinity->mask);
+ cpu_addr = smp_cpu_get_cpu_address(cpu);
+ } else {
+ cpu_addr = 0;
+ }
+
msg.address_lo = zdev->msi_addr & 0xff0000ff;
- msg.address_lo |= msi->affinity ?
- (cpumask_first(&msi->affinity->mask) << 8) : 0;
+ msg.address_lo |= (cpu_addr << 8);
+
for_each_possible_cpu(cpu) {
airq_iv_set_data(zpci_ibv[cpu], hwirq, irq);
}
--
2.26.0
next parent reply other threads:[~2020-11-26 12:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <af38d74d-5310-9700-1773-85b8372022d4@linux.ibm.com>
[not found] ` <20201125142930.GA13435@oc3871087118.ibm.com>
[not found] ` <31dfedbf-cfe4-09d2-5dc5-ee9fb847d109@linux.ibm.com>
[not found] ` <8a072525-7915-27c8-40ef-d7c826419a89@linux.ibm.com>
[not found] ` <10403770-249e-ccbc-a90a-f4ceeb190346@linux.ibm.com>
[not found] ` <20201125155818.GA16580@oc3871087118.ibm.com>
[not found] ` <a3be779d-6103-014a-3090-a0ea86c5668a@linux.ibm.com>
2020-11-26 12:19 ` Alexander Gordeev [this message]
2020-11-26 15:08 ` [PATCH v2] s390/pci: fix CPU address in MSI for directed IRQ Niklas Schnelle
2020-11-26 16:43 ` Alexander Gordeev
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=20201126121934.GA514@oc3871087118.ibm.com \
--to=agordeev@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.ibm.com \
--cc=schnelle@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox