Skip to content

Commit 1d648bf

Browse files
Mrinmay Sarkarbjorn-helgaas
authored andcommitted
PCI: qcom: Override NO_SNOOP attribute for SA8775P RC
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 issue exist for the addressed memory on the endpoint 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 endpoint. And worst case, if the memory is cached on the endpoint, it may lead to memory corruption issues. It should be noted that the caching of memory on the endpoint 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. 8775 has IP version 1.34.0 so introduce a new cfg(cfg_1_34_0) for this platform. Assign override_no_snoop flag into struct qcom_pcie_cfg and set it true in cfg_1_34_0 and enable cache snooping if this particular flag is true. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Mrinmay Sarkar <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> [bhelgaas: wrap comments to fit in 80 columns] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 3c6c844 commit 1d648bf

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#define PARF_SID_OFFSET 0x234
5252
#define PARF_BDF_TRANSLATE_CFG 0x24c
5353
#define PARF_SLV_ADDR_SPACE_SIZE 0x358
54+
#define PARF_NO_SNOOP_OVERIDE 0x3d4
5455
#define PARF_DEVICE_TYPE 0x1000
5556
#define PARF_BDF_TO_SID_TABLE_N 0x2000
5657
#define PARF_BDF_TO_SID_CFG 0x2c00
@@ -118,6 +119,10 @@
118119
/* PARF_LTSSM register fields */
119120
#define LTSSM_EN BIT(8)
120121

122+
/* PARF_NO_SNOOP_OVERIDE register fields */
123+
#define WR_NO_SNOOP_OVERIDE_EN BIT(1)
124+
#define RD_NO_SNOOP_OVERIDE_EN BIT(3)
125+
121126
/* PARF_DEVICE_TYPE register fields */
122127
#define DEVICE_TYPE_RC 0x4
123128

@@ -229,8 +234,15 @@ struct qcom_pcie_ops {
229234
int (*config_sid)(struct qcom_pcie *pcie);
230235
};
231236

237+
/**
238+
* struct qcom_pcie_cfg - Per SoC config struct
239+
* @ops: qcom PCIe ops structure
240+
* @override_no_snoop: Override NO_SNOOP attribute in TLP to enable cache
241+
* snooping
242+
*/
232243
struct qcom_pcie_cfg {
233244
const struct qcom_pcie_ops *ops;
245+
bool override_no_snoop;
234246
bool no_l0s;
235247
};
236248

@@ -930,6 +942,12 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)
930942

931943
static int qcom_pcie_post_init_2_7_0(struct qcom_pcie *pcie)
932944
{
945+
const struct qcom_pcie_cfg *pcie_cfg = pcie->cfg;
946+
947+
if (pcie_cfg->override_no_snoop)
948+
writel(WR_NO_SNOOP_OVERIDE_EN | RD_NO_SNOOP_OVERIDE_EN,
949+
pcie->parf + PARF_NO_SNOOP_OVERIDE);
950+
933951
qcom_pcie_clear_aspm_l0s(pcie->pci);
934952
qcom_pcie_clear_hpc(pcie->pci);
935953

@@ -1305,6 +1323,11 @@ static const struct qcom_pcie_cfg cfg_1_9_0 = {
13051323
.ops = &ops_1_9_0,
13061324
};
13071325

1326+
static const struct qcom_pcie_cfg cfg_1_34_0 = {
1327+
.ops = &ops_1_9_0,
1328+
.override_no_snoop = true,
1329+
};
1330+
13081331
static const struct qcom_pcie_cfg cfg_2_1_0 = {
13091332
.ops = &ops_2_1_0,
13101333
};
@@ -1606,7 +1629,7 @@ static const struct of_device_id qcom_pcie_match[] = {
16061629
{ .compatible = "qcom,pcie-msm8996", .data = &cfg_2_3_2 },
16071630
{ .compatible = "qcom,pcie-qcs404", .data = &cfg_2_4_0 },
16081631
{ .compatible = "qcom,pcie-sa8540p", .data = &cfg_sc8280xp },
1609-
{ .compatible = "qcom,pcie-sa8775p", .data = &cfg_1_9_0},
1632+
{ .compatible = "qcom,pcie-sa8775p", .data = &cfg_1_34_0},
16101633
{ .compatible = "qcom,pcie-sc7280", .data = &cfg_1_9_0 },
16111634
{ .compatible = "qcom,pcie-sc8180x", .data = &cfg_1_9_0 },
16121635
{ .compatible = "qcom,pcie-sc8280xp", .data = &cfg_sc8280xp },

0 commit comments

Comments
 (0)