Message ID | 1667289595-12440-1-git-send-email-hongxing.zhu@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2817117wru; Tue, 1 Nov 2022 01:26:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63NyCiQwdbqreJDuxoMSgR0x3zBTlGmAMdwtsZ6rbJ6KJiw7OyU2acb+AE60ieHyQUx6LB X-Received: by 2002:a17:907:3f19:b0:7a3:2317:4221 with SMTP id hq25-20020a1709073f1900b007a323174221mr16992780ejc.562.1667291181336; Tue, 01 Nov 2022 01:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667291181; cv=none; d=google.com; s=arc-20160816; b=e43ymtBrbbygUjd7prwO5jsuHcp2l6NtL+6DzuwANVetNOnkDabfkD64mTjVbTDnYk GCj6s+CSgR2JtKQzTZDNGdsxUUChUg/TXivMPeqE51xvR3cKkoxpkwh2/R2HVZZ4fDoG CHewJNTlVwqrw26QwTFY00AZup8FbYiYbaj2BtGBaBO3s2EIN6XpPnX9h0+KnHSBXgPR lbezyEUS+So8mqChlUVSYcIPI3lfLQRWPrijFI50mX+GpAG+eroWx2lv4bhMq1nt0T0U TkwGQi8HJdDg56s5thVFjFFa/YwdtCglbiYZZ/4B/c2NW0paIRpRiQy2nk8ufonTR++j kvgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=ddpdp72KKiswce5PgNwlNrpvU7/FpYmCl59mZ+gEgbw=; b=iFeMpqw5vRf+GWdY0j6hoaZp2LAmijQaA4/heAAwDwb3qey3KV6nGBLICDjYOip8/g 1uZzT0zEAV3ofxWKMeqwYhiNHPtWD/KK7ybF3oLW0NM+M9dmJI1+ylwNiXYvXlelvCxK ZIoRDP0oe/oiU6QxwhthtfebAwGu4P/GlTtpODE2gcUIoMtZpoBkb6D2ClqCpVH9sH1e KqjqHay5syQ2EHOP/2/bwCXXxLnzXh9MaWAtt/6BOyw5ipldrRXXC2Kx56Ch1VzJhM7u vqPjM8YIY8cMgNZbH9NFsOIpNDhMp6IHSl++Hd4RmOYFBo8/dAvhgLkTsi5TQmuXwCIs N6ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a056402524c00b0045c786162f5si13520188edd.567.2022.11.01.01.25.57; Tue, 01 Nov 2022 01:26:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbiKAIUq (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Tue, 1 Nov 2022 04:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbiKAIUn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Nov 2022 04:20:43 -0400 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1AC918394; Tue, 1 Nov 2022 01:20:42 -0700 (PDT) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2B81A1A03D2; Tue, 1 Nov 2022 09:20:41 +0100 (CET) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id F38281A03FE; Tue, 1 Nov 2022 09:20:40 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id A0624180222A; Tue, 1 Nov 2022 16:20:39 +0800 (+08) From: Richard Zhu <hongxing.zhu@nxp.com> To: l.stach@pengutronix.de, bhelgaas@google.com, lorenzo.pieralisi@arm.com Cc: hongxing.zhu@nxp.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com Subject: [PATCH v1] PCI: imx6: Set MSI enable bit of RC in resume Date: Tue, 1 Nov 2022 15:59:55 +0800 Message-Id: <1667289595-12440-1-git-send-email-hongxing.zhu@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748281517745336530?= X-GMAIL-MSGID: =?utf-8?q?1748281517745336530?= |
Series |
[v1] PCI: imx6: Set MSI enable bit of RC in resume
|
|
Commit Message
Richard Zhu
Nov. 1, 2022, 7:59 a.m. UTC
The MSI Enable bit controls delivery of MSI interrupts from components
below the Root Port. This bit might lost during the suspend, should be
re-configured during resume.
Encapsulate the MSI enable set into a standalone function, and invoke it
in both probe and resume.
Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
drivers/pci/controller/dwc/pci-imx6.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
Comments
On Tue, Nov 01, 2022 at 03:59:55PM +0800, Richard Zhu wrote: > The MSI Enable bit controls delivery of MSI interrupts from components > below the Root Port. This bit might lost during the suspend, should be > re-configured during resume. Just out of curiosity, why would this bit "get lost" during suspend? Don't the normal save and restore in the suspend/resume paths take care of this? Are there other bits that might get lost? > Encapsulate the MSI enable set into a standalone function, and invoke it > in both probe and resume. > > Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> > --- > drivers/pci/controller/dwc/pci-imx6.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 2616585ca5f8..dba15546075f 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -1041,6 +1041,21 @@ static void imx6_pcie_pm_turnoff(struct imx6_pcie *imx6_pcie) > usleep_range(1000, 10000); > } > > +static void pci_imx_set_msi_en(struct dw_pcie *pci) > +{ > + u8 offset; > + u16 val; > + > + if (pci_msi_enabled()) { > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > + dw_pcie_dbi_ro_wr_en(pci); > + val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > + val |= PCI_MSI_FLAGS_ENABLE; > + dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > + dw_pcie_dbi_ro_wr_dis(pci); > + } > +} > + > static int imx6_pcie_suspend_noirq(struct device *dev) > { > struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); > @@ -1073,6 +1088,7 @@ static int imx6_pcie_resume_noirq(struct device *dev) > if (imx6_pcie->link_is_up) > imx6_pcie_start_link(imx6_pcie->pci); > > + pci_imx_set_msi_en(imx6_pcie->pci); > return 0; > } > > @@ -1090,7 +1106,6 @@ static int imx6_pcie_probe(struct platform_device *pdev) > struct resource *dbi_base; > struct device_node *node = dev->of_node; > int ret; > - u16 val; > > imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); > if (!imx6_pcie) > @@ -1282,12 +1297,7 @@ static int imx6_pcie_probe(struct platform_device *pdev) > if (ret < 0) > return ret; > > - if (pci_msi_enabled()) { > - u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > - val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > - val |= PCI_MSI_FLAGS_ENABLE; > - dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > - } > + pci_imx_set_msi_en(pci); > > return 0; > } > -- > 2.25.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> -----Original Message----- > From: Bjorn Helgaas <helgaas@kernel.org> > Sent: 2022年11月3日 7:11 > To: Hongxing Zhu <hongxing.zhu@nxp.com> > Cc: l.stach@pengutronix.de; bhelgaas@google.com; > lorenzo.pieralisi@arm.com; linux-pci@vger.kernel.org; > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > kernel@pengutronix.de; dl-linux-imx <linux-imx@nxp.com> > Subject: Re: [PATCH v1] PCI: imx6: Set MSI enable bit of RC in resume > > On Tue, Nov 01, 2022 at 03:59:55PM +0800, Richard Zhu wrote: > > The MSI Enable bit controls delivery of MSI interrupts from components > > below the Root Port. This bit might lost during the suspend, should be > > re-configured during resume. > > Just out of curiosity, why would this bit "get lost" during suspend? > > Don't the normal save and restore in the suspend/resume paths take care of > this? Are there other bits that might get lost? Hi Bjorn: Thanks for your care. The controller might be reset to the known stat during the re-initialization in the resume path, I think. dw_pcie_setup_rc() configures most of the controller setting during resume. It seems that this bit is i.MX PCIe special, should be configured in both the probe and suspend/resume. Best Regards Richard Zhu > > > Encapsulate the MSI enable set into a standalone function, and invoke > > it in both probe and resume. > > > > Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> > > --- > > drivers/pci/controller/dwc/pci-imx6.c | 24 +++++++++++++++++------- > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c > > b/drivers/pci/controller/dwc/pci-imx6.c > > index 2616585ca5f8..dba15546075f 100644 > > --- a/drivers/pci/controller/dwc/pci-imx6.c > > +++ b/drivers/pci/controller/dwc/pci-imx6.c > > @@ -1041,6 +1041,21 @@ static void imx6_pcie_pm_turnoff(struct > imx6_pcie *imx6_pcie) > > usleep_range(1000, 10000); > > } > > > > +static void pci_imx_set_msi_en(struct dw_pcie *pci) { > > + u8 offset; > > + u16 val; > > + > > + if (pci_msi_enabled()) { > > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > > + dw_pcie_dbi_ro_wr_en(pci); > > + val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > > + val |= PCI_MSI_FLAGS_ENABLE; > > + dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > > + dw_pcie_dbi_ro_wr_dis(pci); > > + } > > +} > > + > > static int imx6_pcie_suspend_noirq(struct device *dev) { > > struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); @@ -1073,6 > > +1088,7 @@ static int imx6_pcie_resume_noirq(struct device *dev) > > if (imx6_pcie->link_is_up) > > imx6_pcie_start_link(imx6_pcie->pci); > > > > + pci_imx_set_msi_en(imx6_pcie->pci); > > return 0; > > } > > > > @@ -1090,7 +1106,6 @@ static int imx6_pcie_probe(struct platform_device > *pdev) > > struct resource *dbi_base; > > struct device_node *node = dev->of_node; > > int ret; > > - u16 val; > > > > imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); > > if (!imx6_pcie) > > @@ -1282,12 +1297,7 @@ static int imx6_pcie_probe(struct > platform_device *pdev) > > if (ret < 0) > > return ret; > > > > - if (pci_msi_enabled()) { > > - u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > > - val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > > - val |= PCI_MSI_FLAGS_ENABLE; > > - dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > > - } > > + pci_imx_set_msi_en(pci); > > > > return 0; > > } > > -- > > 2.25.1 > > > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists > > .infradead.org%2Fmailman%2Flistinfo%2Flinux-arm-kernel&data=05%7 > C0 > > > 1%7Chongxing.zhu%40nxp.com%7C4454f7f5d1d0438d009908dabd27767e% > 7C686ea1 > > > d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638030274437186510%7CUnk > nown%7CTW > > > FpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV > CI6 > > > Mn0%3D%7C3000%7C%7C%7C&sdata=gfiPPlezSSocyNTpq0oKnk5rwwm > hpmWCszaHa > > YWLhoI%3D&reserved=0
Friendly ping. Anymore comments are very appreciated. BTW, I had verified on i.MX7D/i.MX6QP platforms that MSI wouldn’t be functional after resume without this patch. Best Regards Richard Zhu > -----Original Message----- > From: Richard Zhu <hongxing.zhu@nxp.com> > Sent: 2022年11月1日 16:00 > To: l.stach@pengutronix.de; bhelgaas@google.com; > lorenzo.pieralisi@arm.com > Cc: Hongxing Zhu <hongxing.zhu@nxp.com>; linux-pci@vger.kernel.org; > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > kernel@pengutronix.de; dl-linux-imx <linux-imx@nxp.com> > Subject: [PATCH v1] PCI: imx6: Set MSI enable bit of RC in resume > > The MSI Enable bit controls delivery of MSI interrupts from components below > the Root Port. This bit might lost during the suspend, should be re-configured > during resume. > > Encapsulate the MSI enable set into a standalone function, and invoke it in > both probe and resume. > > Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> > --- > drivers/pci/controller/dwc/pci-imx6.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c > b/drivers/pci/controller/dwc/pci-imx6.c > index 2616585ca5f8..dba15546075f 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -1041,6 +1041,21 @@ static void imx6_pcie_pm_turnoff(struct > imx6_pcie *imx6_pcie) > usleep_range(1000, 10000); > } > > +static void pci_imx_set_msi_en(struct dw_pcie *pci) { > + u8 offset; > + u16 val; > + > + if (pci_msi_enabled()) { > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > + dw_pcie_dbi_ro_wr_en(pci); > + val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > + val |= PCI_MSI_FLAGS_ENABLE; > + dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > + dw_pcie_dbi_ro_wr_dis(pci); > + } > +} > + > static int imx6_pcie_suspend_noirq(struct device *dev) { > struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); @@ -1073,6 > +1088,7 @@ static int imx6_pcie_resume_noirq(struct device *dev) > if (imx6_pcie->link_is_up) > imx6_pcie_start_link(imx6_pcie->pci); > > + pci_imx_set_msi_en(imx6_pcie->pci); > return 0; > } > > @@ -1090,7 +1106,6 @@ static int imx6_pcie_probe(struct platform_device > *pdev) > struct resource *dbi_base; > struct device_node *node = dev->of_node; > int ret; > - u16 val; > > imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); > if (!imx6_pcie) > @@ -1282,12 +1297,7 @@ static int imx6_pcie_probe(struct platform_device > *pdev) > if (ret < 0) > return ret; > > - if (pci_msi_enabled()) { > - u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > - val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > - val |= PCI_MSI_FLAGS_ENABLE; > - dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > - } > + pci_imx_set_msi_en(pci); > > return 0; > } > -- > 2.25.1
Am Freitag, dem 25.11.2022 um 02:07 +0000 schrieb Hongxing Zhu: > Friendly ping. > Anymore comments are very appreciated. > > BTW, I had verified on i.MX7D/i.MX6QP platforms that MSI wouldn’t be functional > after resume without this patch. Instead of playing whack-a-mole and restoring individual config setting after resume, shouldn't we just do a pci_save_state() on suspend and then restore the complete config by calling pci_restore_state() on resume? Regards, Lucas > > Best Regards > Richard Zhu > > > -----Original Message----- > > From: Richard Zhu <hongxing.zhu@nxp.com> > > Sent: 2022年11月1日 16:00 > > To: l.stach@pengutronix.de; bhelgaas@google.com; > > lorenzo.pieralisi@arm.com > > Cc: Hongxing Zhu <hongxing.zhu@nxp.com>; linux-pci@vger.kernel.org; > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > > kernel@pengutronix.de; dl-linux-imx <linux-imx@nxp.com> > > Subject: [PATCH v1] PCI: imx6: Set MSI enable bit of RC in resume > > > > The MSI Enable bit controls delivery of MSI interrupts from components below > > the Root Port. This bit might lost during the suspend, should be re-configured > > during resume. > > > > Encapsulate the MSI enable set into a standalone function, and invoke it in > > both probe and resume. > > > > Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> > > --- > > drivers/pci/controller/dwc/pci-imx6.c | 24 +++++++++++++++++------- > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c > > b/drivers/pci/controller/dwc/pci-imx6.c > > index 2616585ca5f8..dba15546075f 100644 > > --- a/drivers/pci/controller/dwc/pci-imx6.c > > +++ b/drivers/pci/controller/dwc/pci-imx6.c > > @@ -1041,6 +1041,21 @@ static void imx6_pcie_pm_turnoff(struct > > imx6_pcie *imx6_pcie) > > usleep_range(1000, 10000); > > } > > > > +static void pci_imx_set_msi_en(struct dw_pcie *pci) { > > + u8 offset; > > + u16 val; > > + > > + if (pci_msi_enabled()) { > > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > > + dw_pcie_dbi_ro_wr_en(pci); > > + val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > > + val |= PCI_MSI_FLAGS_ENABLE; > > + dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > > + dw_pcie_dbi_ro_wr_dis(pci); > > + } > > +} > > + > > static int imx6_pcie_suspend_noirq(struct device *dev) { > > struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); @@ -1073,6 > > +1088,7 @@ static int imx6_pcie_resume_noirq(struct device *dev) > > if (imx6_pcie->link_is_up) > > imx6_pcie_start_link(imx6_pcie->pci); > > > > + pci_imx_set_msi_en(imx6_pcie->pci); > > return 0; > > } > > > > @@ -1090,7 +1106,6 @@ static int imx6_pcie_probe(struct platform_device > > *pdev) > > struct resource *dbi_base; > > struct device_node *node = dev->of_node; > > int ret; > > - u16 val; > > > > imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); > > if (!imx6_pcie) > > @@ -1282,12 +1297,7 @@ static int imx6_pcie_probe(struct platform_device > > *pdev) > > if (ret < 0) > > return ret; > > > > - if (pci_msi_enabled()) { > > - u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > > - val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > > - val |= PCI_MSI_FLAGS_ENABLE; > > - dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > > - } > > + pci_imx_set_msi_en(pci); > > > > return 0; > > } > > -- > > 2.25.1 >
> -----Original Message----- > From: Lucas Stach <l.stach@pengutronix.de> > Sent: 2022年11月25日 18:19 > To: Hongxing Zhu <hongxing.zhu@nxp.com>; bhelgaas@google.com; > lorenzo.pieralisi@arm.com > Cc: linux-pci@vger.kernel.org; linux-arm-kernel@lists.infradead.org; > linux-kernel@vger.kernel.org; kernel@pengutronix.de; dl-linux-imx > <linux-imx@nxp.com> > Subject: Re: [PATCH v1] PCI: imx6: Set MSI enable bit of RC in resume > > Am Freitag, dem 25.11.2022 um 02:07 +0000 schrieb Hongxing Zhu: > > Friendly ping. > > Anymore comments are very appreciated. > > > > BTW, I had verified on i.MX7D/i.MX6QP platforms that MSI wouldn’t be > > functional after resume without this patch. > > Instead of playing whack-a-mole and restoring individual config setting after > resume, shouldn't we just do a pci_save_state() on suspend and then restore > the complete config by calling pci_restore_state() on resume? > Hi Lucas: Thanks for your comments. Refer to my understanding, only the i.MX PCIe specific configs that might be lost during suspend/resume should be saved/restored here. Because that most of the configs had been re-configured in the suspend/resume paths already. So, only the PCI_MSI_FLAGS should be saved/restored here, right? Best Regards Richard Zhu > Regards, > Lucas > > > > > Best Regards > > Richard Zhu > > > > > -----Original Message----- > > > From: Richard Zhu <hongxing.zhu@nxp.com> > > > Sent: 2022年11月1日 16:00 > > > To: l.stach@pengutronix.de; bhelgaas@google.com; > > > lorenzo.pieralisi@arm.com > > > Cc: Hongxing Zhu <hongxing.zhu@nxp.com>; linux-pci@vger.kernel.org; > > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > > > kernel@pengutronix.de; dl-linux-imx <linux-imx@nxp.com> > > > Subject: [PATCH v1] PCI: imx6: Set MSI enable bit of RC in resume > > > > > > The MSI Enable bit controls delivery of MSI interrupts from > > > components below the Root Port. This bit might lost during the > > > suspend, should be re-configured during resume. > > > > > > Encapsulate the MSI enable set into a standalone function, and > > > invoke it in both probe and resume. > > > > > > Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> > > > --- > > > drivers/pci/controller/dwc/pci-imx6.c | 24 +++++++++++++++++------- > > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c > > > b/drivers/pci/controller/dwc/pci-imx6.c > > > index 2616585ca5f8..dba15546075f 100644 > > > --- a/drivers/pci/controller/dwc/pci-imx6.c > > > +++ b/drivers/pci/controller/dwc/pci-imx6.c > > > @@ -1041,6 +1041,21 @@ static void imx6_pcie_pm_turnoff(struct > > > imx6_pcie *imx6_pcie) > > > usleep_range(1000, 10000); > > > } > > > > > > +static void pci_imx_set_msi_en(struct dw_pcie *pci) { > > > + u8 offset; > > > + u16 val; > > > + > > > + if (pci_msi_enabled()) { > > > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > > > + dw_pcie_dbi_ro_wr_en(pci); > > > + val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > > > + val |= PCI_MSI_FLAGS_ENABLE; > > > + dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > > > + dw_pcie_dbi_ro_wr_dis(pci); > > > + } > > > +} > > > + > > > static int imx6_pcie_suspend_noirq(struct device *dev) { > > > struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); @@ -1073,6 > > > +1088,7 @@ static int imx6_pcie_resume_noirq(struct device *dev) > > > if (imx6_pcie->link_is_up) > > > imx6_pcie_start_link(imx6_pcie->pci); > > > > > > + pci_imx_set_msi_en(imx6_pcie->pci); > > > return 0; > > > } > > > > > > @@ -1090,7 +1106,6 @@ static int imx6_pcie_probe(struct > > > platform_device > > > *pdev) > > > struct resource *dbi_base; > > > struct device_node *node = dev->of_node; > > > int ret; > > > - u16 val; > > > > > > imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); > > > if (!imx6_pcie) > > > @@ -1282,12 +1297,7 @@ static int imx6_pcie_probe(struct > > > platform_device > > > *pdev) > > > if (ret < 0) > > > return ret; > > > > > > - if (pci_msi_enabled()) { > > > - u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > > > - val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); > > > - val |= PCI_MSI_FLAGS_ENABLE; > > > - dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); > > > - } > > > + pci_imx_set_msi_en(pci); > > > > > > return 0; > > > } > > > -- > > > 2.25.1 > > >
diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 2616585ca5f8..dba15546075f 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1041,6 +1041,21 @@ static void imx6_pcie_pm_turnoff(struct imx6_pcie *imx6_pcie) usleep_range(1000, 10000); } +static void pci_imx_set_msi_en(struct dw_pcie *pci) +{ + u8 offset; + u16 val; + + if (pci_msi_enabled()) { + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); + dw_pcie_dbi_ro_wr_en(pci); + val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); + val |= PCI_MSI_FLAGS_ENABLE; + dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); + dw_pcie_dbi_ro_wr_dis(pci); + } +} + static int imx6_pcie_suspend_noirq(struct device *dev) { struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); @@ -1073,6 +1088,7 @@ static int imx6_pcie_resume_noirq(struct device *dev) if (imx6_pcie->link_is_up) imx6_pcie_start_link(imx6_pcie->pci); + pci_imx_set_msi_en(imx6_pcie->pci); return 0; } @@ -1090,7 +1106,6 @@ static int imx6_pcie_probe(struct platform_device *pdev) struct resource *dbi_base; struct device_node *node = dev->of_node; int ret; - u16 val; imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); if (!imx6_pcie) @@ -1282,12 +1297,7 @@ static int imx6_pcie_probe(struct platform_device *pdev) if (ret < 0) return ret; - if (pci_msi_enabled()) { - u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); - val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); - val |= PCI_MSI_FLAGS_ENABLE; - dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); - } + pci_imx_set_msi_en(pci); return 0; }