[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1656684800-31278-3-git-send-email-quic_krichai@quicinc.com>
Date: Fri, 1 Jul 2022 19:43:19 +0530
From: Krishna chaitanya chundru <quic_krichai@...cinc.com>
To: helgaas@...nel.org
Cc: linux-pci@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org, mka@...omium.org,
quic_vbadigan@...cinc.com, quic_hemantk@...cinc.com,
quic_nitegupt@...cinc.com, quic_skananth@...cinc.com,
quic_ramkri@...cinc.com, manivannan.sadhasivam@...aro.org,
swboyd@...omium.org, dmitry.baryshkov@...aro.org,
Krishna chaitanya chundru <quic_krichai@...cinc.com>,
Jingoo Han <jingoohan1@...il.com>,
Gustavo Pimentel <gustavo.pimentel@...opsys.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Rob Herring <robh@...nel.org>,
Krzysztof WilczyĆski <kw@...ux.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Andy Gross <agross@...nel.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Stanimir Varbanov <svarbanov@...sol.com>
Subject: [PATCH v3 2/2] PCI: qcom: Restrict pci transactions after pci suspend
If the endpoint device state is D0 and irq's are not freed, then
kernel try to mask interrupts in system suspend path by writing
in to the vector table (for MSIX interrupts) and config space (for MSI's).
These transactions are initiated in the pm suspend after pcie clocks got
disabled as part of platform driver pm suspend call. Due to it, these
transactions are resulting in un-clocked access and eventually to crashes.
So added a logic in qcom driver to restrict these unclocked access.
And updated the logic to check the link state before masking
or unmasking the interrupts.
Signed-off-by: Krishna chaitanya chundru <quic_krichai@...cinc.com>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 14 +++++++--
drivers/pci/controller/dwc/pcie-qcom.c | 36 +++++++++++++++++++++--
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 2fa86f3..2a46b40 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -29,13 +29,23 @@ static void dw_msi_ack_irq(struct irq_data *d)
static void dw_msi_mask_irq(struct irq_data *d)
{
- pci_msi_mask_irq(d);
+ struct pcie_port *pp = irq_data_get_irq_chip_data(d->parent_data);
+ struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
+
+ if (dw_pcie_link_up(pci))
+ pci_msi_mask_irq(d);
+
irq_chip_mask_parent(d);
}
static void dw_msi_unmask_irq(struct irq_data *d)
{
- pci_msi_unmask_irq(d);
+ struct pcie_port *pp = irq_data_get_irq_chip_data(d->parent_data);
+ struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
+
+ if (dw_pcie_link_up(pci))
+ pci_msi_unmask_irq(d);
+
irq_chip_unmask_parent(d);
}
diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index d7ede0c..f0e9079 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -1335,11 +1335,41 @@ static int qcom_pcie_suspend_2_7_0(struct qcom_pcie *pcie)
return 0;
}
+static u32 qcom_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base,
+ u32 reg, size_t size)
+{
+ struct qcom_pcie *pcie = to_qcom_pcie(pci);
+ u32 val;
+
+ if (pcie->is_suspended)
+ return PCIBIOS_BAD_REGISTER_NUMBER;
+
+ dw_pcie_read(base + reg, size, &val);
+ return val;
+}
+
+static void qcom_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base,
+ u32 reg, size_t size, u32 val)
+{
+ struct qcom_pcie *pcie = to_qcom_pcie(pci);
+
+ if (pcie->is_suspended)
+ return;
+
+ dw_pcie_write(base + reg, size, val);
+}
+
static int qcom_pcie_link_up(struct dw_pcie *pci)
{
- u16 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
- u16 val = readw(pci->dbi_base + offset + PCI_EXP_LNKSTA);
+ struct qcom_pcie *pcie = to_qcom_pcie(pci);
+ u16 offset;
+ u16 val;
+
+ if (pcie->is_suspended)
+ return false;
+ offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
+ val = readw(pci->dbi_base + offset + PCI_EXP_LNKSTA);
return !!(val & PCI_EXP_LNKSTA_DLLLA);
}
@@ -1583,6 +1613,8 @@ static const struct qcom_pcie_cfg sc7280_cfg = {
static const struct dw_pcie_ops dw_pcie_ops = {
.link_up = qcom_pcie_link_up,
.start_link = qcom_pcie_start_link,
+ .read_dbi = qcom_pcie_read_dbi,
+ .write_dbi = qcom_pcie_write_dbi,
};
static int qcom_pcie_probe(struct platform_device *pdev)
--
2.7.4
Powered by blists - more mailing lists