Skip to content

Commit 46ad3dc

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: aardvark: Fix setting MSI address
MSI address for receiving MSI interrupts needs to be correctly set before enabling processing of MSI interrupts. Move code for setting PCIE_MSI_ADDR_LOW_REG and PCIE_MSI_ADDR_HIGH_REG from advk_pcie_init_msi_irq_domain() to advk_pcie_setup_hw(), before enabling PCIE_CORE_CTRL2_MSI_ENABLE. After this we can remove the now unused member msi_msg, which was used only for MSI doorbell address. MSI address can be any address which cannot be used to DMA to. So change it to the address of the main struct advk_pcie. Link: https://lore.kernel.org/r/20220110015018.26359-12-kabel@kernel.org Fixes: 8c39d71 ("PCI: aardvark: Add Aardvark PCI host controller driver") Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Marek Behún <kabel@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Marc Zyngier <maz@kernel.org> Cc: stable@vger.kernel.org # f21a8b1 ("PCI: aardvark: Move to MSI handling using generic MSI support")
1 parent e77d9c9 commit 46ad3dc

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/pci/controller/pci-aardvark.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ struct advk_pcie {
277277
raw_spinlock_t msi_irq_lock;
278278
DECLARE_BITMAP(msi_used, MSI_IRQ_NUM);
279279
struct mutex msi_used_lock;
280-
u16 msi_msg;
281280
int link_gen;
282281
struct pci_bridge_emul bridge;
283282
struct gpio_desc *reset_gpio;
@@ -472,6 +471,7 @@ static void advk_pcie_disable_ob_win(struct advk_pcie *pcie, u8 win_num)
472471

473472
static void advk_pcie_setup_hw(struct advk_pcie *pcie)
474473
{
474+
phys_addr_t msi_addr;
475475
u32 reg;
476476
int i;
477477

@@ -560,6 +560,11 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
560560
reg |= LANE_COUNT_1;
561561
advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
562562

563+
/* Set MSI address */
564+
msi_addr = virt_to_phys(pcie);
565+
advk_writel(pcie, lower_32_bits(msi_addr), PCIE_MSI_ADDR_LOW_REG);
566+
advk_writel(pcie, upper_32_bits(msi_addr), PCIE_MSI_ADDR_HIGH_REG);
567+
563568
/* Enable MSI */
564569
reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG);
565570
reg |= PCIE_CORE_CTRL2_MSI_ENABLE;
@@ -1175,10 +1180,10 @@ static void advk_msi_irq_compose_msi_msg(struct irq_data *data,
11751180
struct msi_msg *msg)
11761181
{
11771182
struct advk_pcie *pcie = irq_data_get_irq_chip_data(data);
1178-
phys_addr_t msi_msg = virt_to_phys(&pcie->msi_msg);
1183+
phys_addr_t msi_addr = virt_to_phys(pcie);
11791184

1180-
msg->address_lo = lower_32_bits(msi_msg);
1181-
msg->address_hi = upper_32_bits(msi_msg);
1185+
msg->address_lo = lower_32_bits(msi_addr);
1186+
msg->address_hi = upper_32_bits(msi_addr);
11821187
msg->data = data->hwirq;
11831188
}
11841189

@@ -1337,18 +1342,10 @@ static struct msi_domain_info advk_msi_domain_info = {
13371342
static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie)
13381343
{
13391344
struct device *dev = &pcie->pdev->dev;
1340-
phys_addr_t msi_msg_phys;
13411345

13421346
raw_spin_lock_init(&pcie->msi_irq_lock);
13431347
mutex_init(&pcie->msi_used_lock);
13441348

1345-
msi_msg_phys = virt_to_phys(&pcie->msi_msg);
1346-
1347-
advk_writel(pcie, lower_32_bits(msi_msg_phys),
1348-
PCIE_MSI_ADDR_LOW_REG);
1349-
advk_writel(pcie, upper_32_bits(msi_msg_phys),
1350-
PCIE_MSI_ADDR_HIGH_REG);
1351-
13521349
pcie->msi_inner_domain =
13531350
irq_domain_add_linear(NULL, MSI_IRQ_NUM,
13541351
&advk_msi_domain_ops, pcie);

0 commit comments

Comments
 (0)