Skip to content

Commit ec2b9d4

Browse files
dcpleungjhedberg
authored andcommitted
pcie: msi: pci_msi_enable() to take IRQ as parameter
This changes pci_msi_enable() to take IRQ number as a function parameter. The old behavior relies on putting the IRQ number into the interrupt line register in the PCI config space during IRQ allocation, and reading it back when enabling IRQ. However, the interrupt line register is only required to be read-/writable when legacy interrupt is supported on the device. Otherwise it has undefined behavior. On ACRN, they don't even care about this register and always wires it to 0x00. So this commit changes the behavior in pci_msi_enable() to not require reading back the interrupt line register and instead takes the IRQ number via function parameter. Fixes #36765 Signed-off-by: Daniel Leung <[email protected]>
1 parent e7436ea commit ec2b9d4

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

drivers/pcie/host/msi.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,12 @@ bool pcie_msi_vector_connect(pcie_bdf_t bdf,
188188
static void enable_msix(pcie_bdf_t bdf,
189189
msi_vector_t *vectors,
190190
uint8_t n_vector,
191-
uint32_t base)
191+
uint32_t base,
192+
unsigned int irq)
192193
{
193-
unsigned int irq;
194194
uint32_t mcr;
195195
int i;
196196

197-
irq = pcie_get_irq(bdf);
198-
199197
for (i = 0; i < n_vector; i++) {
200198
uint32_t map = pcie_msi_map(irq, &vectors[i]);
201199
uint32_t mdr = pcie_msi_mdr(irq, &vectors[i]);
@@ -228,16 +226,14 @@ static void disable_msi(pcie_bdf_t bdf,
228226
static void enable_msi(pcie_bdf_t bdf,
229227
msi_vector_t *vectors,
230228
uint8_t n_vector,
231-
uint32_t base)
229+
uint32_t base,
230+
unsigned int irq)
232231
{
233-
unsigned int irq;
234232
uint32_t mcr;
235233
uint32_t map;
236234
uint32_t mdr;
237235
uint32_t mme;
238236

239-
irq = pcie_get_irq(bdf);
240-
241237
map = pcie_msi_map(irq, vectors);
242238
pcie_conf_write(bdf, base + PCIE_MSI_MAP0, map);
243239

@@ -263,7 +259,8 @@ static void enable_msi(pcie_bdf_t bdf,
263259

264260
bool pcie_msi_enable(pcie_bdf_t bdf,
265261
msi_vector_t *vectors,
266-
uint8_t n_vector)
262+
uint8_t n_vector,
263+
unsigned int irq)
267264
{
268265
bool msi = true;
269266
uint32_t base;
@@ -288,9 +285,9 @@ bool pcie_msi_enable(pcie_bdf_t bdf,
288285
}
289286

290287
if (!msi && IS_ENABLED(CONFIG_PCIE_MSI_X)) {
291-
enable_msix(bdf, vectors, n_vector, base);
288+
enable_msix(bdf, vectors, n_vector, base, irq);
292289
} else {
293-
enable_msi(bdf, vectors, n_vector, base);
290+
enable_msi(bdf, vectors, n_vector, base, irq);
294291
}
295292

296293
pcie_set_cmd(bdf, PCIE_CONF_CMDSTAT_MASTER, true);

drivers/pcie/host/pcie.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ unsigned int pcie_get_irq(pcie_bdf_t bdf)
238238
void pcie_irq_enable(pcie_bdf_t bdf, unsigned int irq)
239239
{
240240
#if CONFIG_PCIE_MSI
241-
if (pcie_msi_enable(bdf, NULL, 1)) {
241+
if (pcie_msi_enable(bdf, NULL, 1, irq)) {
242242
return;
243243
}
244244
#endif

include/drivers/pcie/msi.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ extern uint16_t pcie_msi_mdr(unsigned int irq,
101101
* @param bdf the target PCI endpoint
102102
* @param vectors an array of allocated vector(s)
103103
* @param n_vector the size of the vector array
104+
* @param irq The IRQ we wish to trigger via MSI.
104105
* @return true if the endpoint supports MSI, false otherwise.
105106
*/
106107
extern bool pcie_msi_enable(pcie_bdf_t bdf,
107108
msi_vector_t *vectors,
108-
uint8_t n_vector);
109+
uint8_t n_vector,
110+
unsigned int irq);
109111

110112
/*
111113
* MSI capability IDs in the PCI configuration capability list.

0 commit comments

Comments
 (0)