Skip to content

Commit c4c50d8

Browse files
committed
Merge branch 'pci/controller/tegra'
- Correct the devm_kcalloc() argument order (Alok Tiwari) - When asserting PERST#, disable the controller instead of mistakenly disabling the PLL twice (Nagarjuna Kristam) - Convert struct tegra_msi mask_lock to raw spinlock to avoid a lock nesting error (Marek Vasut) - Rename 'root_bus' to 'root_port_bus' for clarity (Manivannan Sadhasivam) * pci/controller/tegra: PCI: tegra194: Rename 'root_bus' to 'root_port_bus' in tegra_pcie_downstream_dev_to_D0() PCI: tegra: Convert struct tegra_msi mask_lock into raw spinlock PCI: tegra194: Fix duplicate PLL disable in pex_ep_event_pex_rst_assert() PCI: tegra: Fix devm_kcalloc() argument order for port->phys allocation
2 parents 30eccd3 + e1bd928 commit c4c50d8

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

drivers/pci/controller/dwc/pcie-tegra194.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ static int tegra_pcie_bpmp_set_pll_state(struct tegra_pcie_dw *pcie,
12841284
static void tegra_pcie_downstream_dev_to_D0(struct tegra_pcie_dw *pcie)
12851285
{
12861286
struct dw_pcie_rp *pp = &pcie->pci.pp;
1287-
struct pci_bus *child, *root_bus = NULL;
1287+
struct pci_bus *child, *root_port_bus = NULL;
12881288
struct pci_dev *pdev;
12891289

12901290
/*
@@ -1297,19 +1297,19 @@ static void tegra_pcie_downstream_dev_to_D0(struct tegra_pcie_dw *pcie)
12971297
*/
12981298

12991299
list_for_each_entry(child, &pp->bridge->bus->children, node) {
1300-
/* Bring downstream devices to D0 if they are not already in */
13011300
if (child->parent == pp->bridge->bus) {
1302-
root_bus = child;
1301+
root_port_bus = child;
13031302
break;
13041303
}
13051304
}
13061305

1307-
if (!root_bus) {
1308-
dev_err(pcie->dev, "Failed to find downstream devices\n");
1306+
if (!root_port_bus) {
1307+
dev_err(pcie->dev, "Failed to find downstream bus of Root Port\n");
13091308
return;
13101309
}
13111310

1312-
list_for_each_entry(pdev, &root_bus->devices, bus_list) {
1311+
/* Bring downstream devices to D0 if they are not already in */
1312+
list_for_each_entry(pdev, &root_port_bus->devices, bus_list) {
13131313
if (PCI_SLOT(pdev->devfn) == 0) {
13141314
if (pci_set_power_state(pdev, PCI_D0))
13151315
dev_err(pcie->dev,
@@ -1736,9 +1736,9 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)
17361736
ret);
17371737
}
17381738

1739-
ret = tegra_pcie_bpmp_set_pll_state(pcie, false);
1739+
ret = tegra_pcie_bpmp_set_ctrl_state(pcie, false);
17401740
if (ret)
1741-
dev_err(pcie->dev, "Failed to turn off UPHY: %d\n", ret);
1741+
dev_err(pcie->dev, "Failed to disable controller: %d\n", ret);
17421742

17431743
pcie->ep_state = EP_STATE_DISABLED;
17441744
dev_dbg(pcie->dev, "Uninitialization of endpoint is completed\n");

drivers/pci/controller/pci-tegra.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include <linux/clk.h>
17+
#include <linux/cleanup.h>
1718
#include <linux/debugfs.h>
1819
#include <linux/delay.h>
1920
#include <linux/export.h>
@@ -270,7 +271,7 @@ struct tegra_msi {
270271
DECLARE_BITMAP(used, INT_PCI_MSI_NR);
271272
struct irq_domain *domain;
272273
struct mutex map_lock;
273-
spinlock_t mask_lock;
274+
raw_spinlock_t mask_lock;
274275
void *virt;
275276
dma_addr_t phys;
276277
int irq;
@@ -1344,7 +1345,7 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port)
13441345
unsigned int i;
13451346
int err;
13461347

1347-
port->phys = devm_kcalloc(dev, sizeof(phy), port->lanes, GFP_KERNEL);
1348+
port->phys = devm_kcalloc(dev, port->lanes, sizeof(phy), GFP_KERNEL);
13481349
if (!port->phys)
13491350
return -ENOMEM;
13501351

@@ -1581,29 +1582,27 @@ static void tegra_msi_irq_mask(struct irq_data *d)
15811582
struct tegra_msi *msi = irq_data_get_irq_chip_data(d);
15821583
struct tegra_pcie *pcie = msi_to_pcie(msi);
15831584
unsigned int index = d->hwirq / 32;
1584-
unsigned long flags;
15851585
u32 value;
15861586

1587-
spin_lock_irqsave(&msi->mask_lock, flags);
1588-
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1589-
value &= ~BIT(d->hwirq % 32);
1590-
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1591-
spin_unlock_irqrestore(&msi->mask_lock, flags);
1587+
scoped_guard(raw_spinlock_irqsave, &msi->mask_lock) {
1588+
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1589+
value &= ~BIT(d->hwirq % 32);
1590+
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1591+
}
15921592
}
15931593

15941594
static void tegra_msi_irq_unmask(struct irq_data *d)
15951595
{
15961596
struct tegra_msi *msi = irq_data_get_irq_chip_data(d);
15971597
struct tegra_pcie *pcie = msi_to_pcie(msi);
15981598
unsigned int index = d->hwirq / 32;
1599-
unsigned long flags;
16001599
u32 value;
16011600

1602-
spin_lock_irqsave(&msi->mask_lock, flags);
1603-
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1604-
value |= BIT(d->hwirq % 32);
1605-
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1606-
spin_unlock_irqrestore(&msi->mask_lock, flags);
1601+
scoped_guard(raw_spinlock_irqsave, &msi->mask_lock) {
1602+
value = afi_readl(pcie, AFI_MSI_EN_VEC(index));
1603+
value |= BIT(d->hwirq % 32);
1604+
afi_writel(pcie, value, AFI_MSI_EN_VEC(index));
1605+
}
16071606
}
16081607

16091608
static void tegra_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
@@ -1711,7 +1710,7 @@ static int tegra_pcie_msi_setup(struct tegra_pcie *pcie)
17111710
int err;
17121711

17131712
mutex_init(&msi->map_lock);
1714-
spin_lock_init(&msi->mask_lock);
1713+
raw_spin_lock_init(&msi->mask_lock);
17151714

17161715
if (IS_ENABLED(CONFIG_PCI_MSI)) {
17171716
err = tegra_allocate_domains(msi);

0 commit comments

Comments
 (0)