Skip to content

Commit 0514572

Browse files
author
Mete Durlu
committed
s390/pci: Refactor arch_setup_msi_irqs()
JIRA: https://issues.redhat.com/browse/RHEL-69123 Build-Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=66090493 commit 5fd11b9 Author: Gerd Bayer <gbayer@linux.ibm.com> Date: Thu Jul 11 15:45:26 2024 +0200 s390/pci: Refactor arch_setup_msi_irqs() Factor out adapter interrupt allocation from arch_setup_msi_irqs() in preparation for enabling registration of multiple MSIs. Code movement only, no change of functionality intended. Signed-off-by: Gerd Bayer <gbayer@linux.ibm.com> Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Mete Durlu <mdurlu@redhat.com>
1 parent 5928120 commit 0514572

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

arch/s390/pci/pci_irq.c

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -268,44 +268,54 @@ static void zpci_floating_irq_handler(struct airq_struct *airq,
268268
}
269269
}
270270

271-
int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
271+
static int __alloc_airq(struct zpci_dev *zdev, int msi_vecs,
272+
unsigned long *bit)
272273
{
273-
struct zpci_dev *zdev = to_zpci(pdev);
274-
unsigned int hwirq, msi_vecs, cpu;
275-
unsigned long bit;
276-
struct msi_desc *msi;
277-
struct msi_msg msg;
278-
int cpu_addr;
279-
int rc, irq;
280-
281-
zdev->aisb = -1UL;
282-
zdev->msi_first_bit = -1U;
283-
if (type == PCI_CAP_ID_MSI && nvec > 1)
284-
return 1;
285-
msi_vecs = min_t(unsigned int, nvec, zdev->max_msi);
286-
287274
if (irq_delivery == DIRECTED) {
288275
/* Allocate cpu vector bits */
289-
bit = airq_iv_alloc(zpci_ibv[0], msi_vecs);
290-
if (bit == -1UL)
276+
*bit = airq_iv_alloc(zpci_ibv[0], msi_vecs);
277+
if (*bit == -1UL)
291278
return -EIO;
292279
} else {
293280
/* Allocate adapter summary indicator bit */
294-
bit = airq_iv_alloc_bit(zpci_sbv);
295-
if (bit == -1UL)
281+
*bit = airq_iv_alloc_bit(zpci_sbv);
282+
if (*bit == -1UL)
296283
return -EIO;
297-
zdev->aisb = bit;
284+
zdev->aisb = *bit;
298285

299286
/* Create adapter interrupt vector */
300287
zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK, NULL);
301288
if (!zdev->aibv)
302289
return -ENOMEM;
303290

304291
/* Wire up shortcut pointer */
305-
zpci_ibv[bit] = zdev->aibv;
292+
zpci_ibv[*bit] = zdev->aibv;
306293
/* Each function has its own interrupt vector */
307-
bit = 0;
294+
*bit = 0;
308295
}
296+
return 0;
297+
}
298+
299+
int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
300+
{
301+
struct zpci_dev *zdev = to_zpci(pdev);
302+
unsigned int hwirq, msi_vecs, cpu;
303+
struct msi_desc *msi;
304+
struct msi_msg msg;
305+
unsigned long bit;
306+
int cpu_addr;
307+
int rc, irq;
308+
309+
zdev->aisb = -1UL;
310+
zdev->msi_first_bit = -1U;
311+
312+
if (type == PCI_CAP_ID_MSI && nvec > 1)
313+
return 1;
314+
msi_vecs = min_t(unsigned int, nvec, zdev->max_msi);
315+
316+
rc = __alloc_airq(zdev, msi_vecs, &bit);
317+
if (rc < 0)
318+
return rc;
309319

310320
/* Request MSI interrupts */
311321
hwirq = bit;

0 commit comments

Comments
 (0)