From 0904cd90061e27a4bac037ce6b45085f45624b90 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Wed, 18 Dec 2019 17:11:39 -0800 Subject: [PATCH 1/2] msm: pcie: cache l1ss timeout in drv_info Update drv_info to cache the l1ss timeout value so that it can be changed if needed. Change-Id: If147d96e4cf2a402b2bd0ce7bcfa9356905a2e10 Signed-off-by: Tony Truong --- drivers/pci/controller/pci-msm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-msm.c b/drivers/pci/controller/pci-msm.c index 6160dd1581d8..9ad035eb8d5e 100644 --- a/drivers/pci/controller/pci-msm.c +++ b/drivers/pci/controller/pci-msm.c @@ -616,6 +616,7 @@ struct msm_pcie_drv_info { u16 seq; u16 reply_seq; u32 timeout_ms; /* IPC command timeout */ + u32 l1ss_timeout_us; struct completion completion; }; @@ -5597,7 +5598,6 @@ static int msm_pcie_setup_drv(struct msm_pcie_dev_t *pcie_dev, struct msm_pcie_drv_msg *msg; struct msm_pcie_drv_tre *pkt; struct msm_pcie_drv_header *hdr; - u32 drv_l1ss_timeout_us = 0; int ret; drv_info = devm_kzalloc(&pcie_dev->pdev->dev, sizeof(*drv_info), @@ -5606,12 +5606,12 @@ static int msm_pcie_setup_drv(struct msm_pcie_dev_t *pcie_dev, return -ENOMEM; ret = of_property_read_u32(of_node, "qcom,drv-l1ss-timeout-us", - &drv_l1ss_timeout_us); + &drv_info->l1ss_timeout_us); if (ret) - drv_l1ss_timeout_us = L1SS_TIMEOUT_US; + drv_info->l1ss_timeout_us = L1SS_TIMEOUT_US; PCIE_DBG(pcie_dev, "PCIe: RC%d: DRV L1ss timeout: %dus\n", - pcie_dev->rc_idx, drv_l1ss_timeout_us); + pcie_dev->rc_idx, drv_info->l1ss_timeout_us); drv_info->dev_id = pcie_dev->rc_idx; @@ -5627,7 +5627,7 @@ static int msm_pcie_setup_drv(struct msm_pcie_dev_t *pcie_dev, pkt->dword[0] = MSM_PCIE_DRV_CMD_ENABLE; pkt->dword[1] = hdr->dev_id; - pkt->dword[2] = drv_l1ss_timeout_us / 1000; + pkt->dword[2] = drv_info->l1ss_timeout_us / 1000; msg = &drv_info->drv_disable; pkt = &msg->pkt; From 2a66f16d02f3a7615fcea578eaa4120e099f9354 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Thu, 19 Dec 2019 14:58:46 -0800 Subject: [PATCH 2/2] msm: pcie: add option to disable L1ss TO for DRV suspend There are usecases where clients will not want DRV subsystem to enable L1ss inactivity timeout. Provide PCIe clients the option to disable L1ss inactivity timeout when requesting a DRV suspend. Change-Id: I940526a58bb2496529e919b5b602c0bc31ca9ae1 Signed-off-by: Tony Truong --- drivers/pci/controller/pci-msm.c | 11 +++++++++-- include/linux/msm_pcie.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-msm.c b/drivers/pci/controller/pci-msm.c index 9ad035eb8d5e..f1eb5952a8ec 100644 --- a/drivers/pci/controller/pci-msm.c +++ b/drivers/pci/controller/pci-msm.c @@ -6856,11 +6856,13 @@ static int msm_pcie_drv_resume(struct msm_pcie_dev_t *pcie_dev) return 0; } -static int msm_pcie_drv_suspend(struct msm_pcie_dev_t *pcie_dev) +static int msm_pcie_drv_suspend(struct msm_pcie_dev_t *pcie_dev, + u32 options) { struct rpmsg_device *rpdev = pcie_drv.rpdev; struct msm_pcie_drv_info *drv_info = pcie_dev->drv_info; struct msm_pcie_drv_msg *drv_enable = &drv_info->drv_enable; + struct msm_pcie_drv_tre *pkt = &drv_enable->pkt; struct msm_pcie_clk_info_t *clk_info; int ret, i; @@ -6883,6 +6885,11 @@ static int msm_pcie_drv_suspend(struct msm_pcie_dev_t *pcie_dev) /* disable global irq - no more linkdown/aer detection */ disable_irq(pcie_dev->irq[MSM_PCIE_INT_GLOBAL_INT].num); + if (options & MSM_PCIE_CONFIG_NO_L1SS_TO) + pkt->dword[2] = 0; + else + pkt->dword[2] = drv_info->l1ss_timeout_us / 1000; + drv_info->reply_seq = drv_info->seq++; drv_enable->hdr.seq = drv_info->reply_seq; @@ -6991,7 +6998,7 @@ int msm_pcie_pm_control(enum msm_pcie_pm_opt pm_opt, u32 busnr, void *user, PCIE_DBG(pcie_dev, "PCIe: RC%d: DRV: user requests for DRV suspend\n", rc_idx); - ret = msm_pcie_drv_suspend(pcie_dev); + ret = msm_pcie_drv_suspend(pcie_dev, options); break; case MSM_PCIE_SUSPEND: PCIE_DBG(&msm_pcie_dev[rc_idx], diff --git a/include/linux/msm_pcie.h b/include/linux/msm_pcie.h index b358db554db3..accb15c0117f 100644 --- a/include/linux/msm_pcie.h +++ b/include/linux/msm_pcie.h @@ -12,6 +12,7 @@ enum msm_pcie_config { MSM_PCIE_CONFIG_NO_CFG_RESTORE = 0x1, MSM_PCIE_CONFIG_LINKDOWN = 0x2, MSM_PCIE_CONFIG_NO_RECOVERY = 0x4, + MSM_PCIE_CONFIG_NO_L1SS_TO = 0x8, }; enum msm_pcie_pm_opt {