Skip to content

Commit c71b5eb

Browse files
Mrinmay Sarkarbjorn-helgaas
authored andcommitted
PCI: qcom-ep: Override NO_SNOOP attribute for SA8775P EP
Due to some hardware changes, SA8775P has set the NO_SNOOP attribute in its TLP for all the PCIe controllers. NO_SNOOP attribute when set, the requester is indicating that no cache coherency issues exist for the addressed memory on the host i.e., memory is not cached. But in reality, requester cannot assume this unless there is a complete control/visibility over the addressed memory on the host. And worst case, if the memory is cached on the host, it may lead to memory corruption issues. It should be noted that the caching of memory on the host is not solely dependent on the NO_SNOOP attribute in TLP. So to avoid the corruption, this patch overrides the NO_SNOOP attribute by setting the PCIE_PARF_NO_SNOOP_OVERIDE register. This patch is not needed for other upstream supported platforms since they do not set NO_SNOOP attribute by default. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Mrinmay Sarkar <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 1d648bf commit c71b5eb

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

drivers/pci/controller/dwc/pcie-qcom-ep.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define PARF_DBI_BASE_ADDR_HI 0x354
4848
#define PARF_SLV_ADDR_SPACE_SIZE 0x358
4949
#define PARF_SLV_ADDR_SPACE_SIZE_HI 0x35c
50+
#define PARF_NO_SNOOP_OVERIDE 0x3d4
5051
#define PARF_ATU_BASE_ADDR 0x634
5152
#define PARF_ATU_BASE_ADDR_HI 0x638
5253
#define PARF_SRIS_MODE 0x644
@@ -86,6 +87,10 @@
8687
#define PARF_DEBUG_INT_CFG_BUS_MASTER_EN BIT(2)
8788
#define PARF_DEBUG_INT_RADM_PM_TURNOFF BIT(3)
8889

90+
/* PARF_NO_SNOOP_OVERIDE register fields */
91+
#define WR_NO_SNOOP_OVERIDE_EN BIT(1)
92+
#define RD_NO_SNOOP_OVERIDE_EN BIT(3)
93+
8994
/* PARF_DEVICE_TYPE register fields */
9095
#define PARF_DEVICE_TYPE_EP 0x0
9196

@@ -152,9 +157,11 @@ enum qcom_pcie_ep_link_status {
152157
/**
153158
* struct qcom_pcie_ep_cfg - Per SoC config struct
154159
* @hdma_support: HDMA support on this SoC
160+
* @override_no_snoop: Override NO_SNOOP attribute in TLP to enable cache snooping
155161
*/
156162
struct qcom_pcie_ep_cfg {
157163
bool hdma_support;
164+
bool override_no_snoop;
158165
};
159166

160167
/**
@@ -175,6 +182,7 @@ struct qcom_pcie_ep_cfg {
175182
* @num_clks: PCIe clocks count
176183
* @perst_en: Flag for PERST enable
177184
* @perst_sep_en: Flag for PERST separation enable
185+
* @cfg: PCIe EP config struct
178186
* @link_status: PCIe Link status
179187
* @global_irq: Qualcomm PCIe specific Global IRQ
180188
* @perst_irq: PERST# IRQ
@@ -202,6 +210,7 @@ struct qcom_pcie_ep {
202210
u32 perst_en;
203211
u32 perst_sep_en;
204212

213+
const struct qcom_pcie_ep_cfg *cfg;
205214
enum qcom_pcie_ep_link_status link_status;
206215
int global_irq;
207216
int perst_irq;
@@ -497,6 +506,10 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)
497506
val |= BIT(8);
498507
writel_relaxed(val, pcie_ep->parf + PARF_LTSSM);
499508

509+
if (pcie_ep->cfg && pcie_ep->cfg->override_no_snoop)
510+
writel_relaxed(WR_NO_SNOOP_OVERIDE_EN | RD_NO_SNOOP_OVERIDE_EN,
511+
pcie_ep->parf + PARF_NO_SNOOP_OVERIDE);
512+
500513
return 0;
501514

502515
err_disable_resources:
@@ -811,7 +824,6 @@ static const struct dw_pcie_ep_ops pci_ep_ops = {
811824

812825
static int qcom_pcie_ep_probe(struct platform_device *pdev)
813826
{
814-
const struct qcom_pcie_ep_cfg *cfg;
815827
struct device *dev = &pdev->dev;
816828
struct qcom_pcie_ep *pcie_ep;
817829
char *name;
@@ -826,8 +838,8 @@ static int qcom_pcie_ep_probe(struct platform_device *pdev)
826838
pcie_ep->pci.ep.ops = &pci_ep_ops;
827839
pcie_ep->pci.edma.nr_irqs = 1;
828840

829-
cfg = of_device_get_match_data(dev);
830-
if (cfg && cfg->hdma_support) {
841+
pcie_ep->cfg = of_device_get_match_data(dev);
842+
if (pcie_ep->cfg && pcie_ep->cfg->hdma_support) {
831843
pcie_ep->pci.edma.ll_wr_cnt = 8;
832844
pcie_ep->pci.edma.ll_rd_cnt = 8;
833845
pcie_ep->pci.edma.mf = EDMA_MF_HDMA_NATIVE;
@@ -893,6 +905,7 @@ static void qcom_pcie_ep_remove(struct platform_device *pdev)
893905

894906
static const struct qcom_pcie_ep_cfg cfg_1_34_0 = {
895907
.hdma_support = true,
908+
.override_no_snoop = true,
896909
};
897910

898911
static const struct of_device_id qcom_pcie_ep_match[] = {

0 commit comments

Comments
 (0)