All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status()
@ 2020-10-06 18:24 Sanjay R Mehta
  2020-10-06 19:38 ` Lukas Wunner
  2020-10-07  9:30   ` Dan Carpenter
  0 siblings, 2 replies; 9+ messages in thread
From: Sanjay R Mehta @ 2020-10-06 18:24 UTC (permalink / raw)
  To: bhelgaas, lukas, andriy.shevchenko, stuart.w.hayes, mr.nuke.me
  Cc: linux-kernel, Sanjay R Mehta

From: Sanjay R Mehta <sanju.mehta@amd.com>

if DL_ACTIVE bit is set it means that there is no need to check
PCI_EXP_LNKSTA_LT bit, as DL_ACTIVE would have set only if the link
is already trained. Hence adding a check which takes care of this
scenario.

Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
---
 drivers/pci/hotplug/pciehp_hpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 53433b3..81d1348 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -309,7 +309,8 @@ int pciehp_check_link_status(struct controller *ctrl)
 
 	pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
 	ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
-	if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
+	if (((lnk_status & PCI_EXP_LNKSTA_LT) &
+	     !(lnk_status & PCI_EXP_DPC_CAP_DL_ACTIVE)) ||
 	    !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
 		ctrl_err(ctrl, "link training error: status %#06x\n",
 			 lnk_status);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread
* Re: [PATCH] PCI: pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status()
@ 2020-10-07  9:18 kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2020-10-07  9:18 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4615 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <1602008668-43646-1-git-send-email-Sanju.Mehta@amd.com>
References: <1602008668-43646-1-git-send-email-Sanju.Mehta@amd.com>
TO: Sanjay R Mehta <Sanju.Mehta@amd.com>
TO: bhelgaas(a)google.com
TO: lukas(a)wunner.de
TO: andriy.shevchenko(a)linux.intel.com
TO: stuart.w.hayes(a)gmail.com
TO: mr.nuke.me(a)gmail.com
CC: linux-kernel(a)vger.kernel.org
CC: Sanjay R Mehta <sanju.mehta@amd.com>

Hi Sanjay,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v5.9-rc8]
[also build test WARNING on next-20201006]
[cannot apply to pci/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sanjay-R-Mehta/PCI-pciehp-Add-check-for-DL_ACTIVE-bit-in-pciehp_check_link_status/20201007-022638
base:    549738f15da0e5a00275977623be199fbbf7df50
:::::: branch date: 15 hours ago
:::::: commit date: 15 hours ago
config: x86_64-randconfig-m001-20201005 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/pci/hotplug/pciehp_hpc.c:313 pciehp_check_link_status() warn: maybe use && instead of &

vim +313 drivers/pci/hotplug/pciehp_hpc.c

f496648b99f8f7f Alexandru Gagniuc 2019-10-25  289  
82a9e79ef132cbf Kenji Kaneshige   2009-09-15  290  int pciehp_check_link_status(struct controller *ctrl)
^1da177e4c3f415 Linus Torvalds    2005-04-16  291  {
cd84d34074f5659 Bjorn Helgaas     2013-05-09  292  	struct pci_dev *pdev = ctrl_dev(ctrl);
1a84b99ccbb954c Bjorn Helgaas     2013-12-14  293  	bool found;
^1da177e4c3f415 Linus Torvalds    2005-04-16  294  	u16 lnk_status;
^1da177e4c3f415 Linus Torvalds    2005-04-16  295  
f0157160b359b1d Keith Busch       2018-09-20  296  	if (!pcie_wait_for_link(pdev, true))
f0157160b359b1d Keith Busch       2018-09-20  297  		return -1;
f18e9625e02bb3e Kenji Kaneshige   2008-10-22  298  
f496648b99f8f7f Alexandru Gagniuc 2019-10-25  299  	if (ctrl->inband_presence_disabled)
f496648b99f8f7f Alexandru Gagniuc 2019-10-25  300  		pcie_wait_for_presence(pdev);
f496648b99f8f7f Alexandru Gagniuc 2019-10-25  301  
2f5d8e4ff947ad6 Yinghai Lu        2012-01-27  302  	found = pci_bus_check_dev(ctrl->pcie->port->subordinate,
2f5d8e4ff947ad6 Yinghai Lu        2012-01-27  303  					PCI_DEVFN(0, 0));
0027cb3e1947d0f Kenji Kaneshige   2011-11-10  304  
6c35a1ac3da63a7 Lukas Wunner      2018-07-19  305  	/* ignore link or presence changes up to this point */
6c35a1ac3da63a7 Lukas Wunner      2018-07-19  306  	if (found)
6c35a1ac3da63a7 Lukas Wunner      2018-07-19  307  		atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC),
6c35a1ac3da63a7 Lukas Wunner      2018-07-19  308  			   &ctrl->pending_events);
6c35a1ac3da63a7 Lukas Wunner      2018-07-19  309  
1a84b99ccbb954c Bjorn Helgaas     2013-12-14  310  	pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
7f2feec140f1f1e Taku Izumi        2008-09-05  311  	ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
818dc520d6f8472 Sanjay R Mehta    2020-10-06  312  	if (((lnk_status & PCI_EXP_LNKSTA_LT) &
818dc520d6f8472 Sanjay R Mehta    2020-10-06 @313  	     !(lnk_status & PCI_EXP_DPC_CAP_DL_ACTIVE)) ||
322162a71bd9fc4 Kenji Kaneshige   2008-12-19  314  	    !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
3784e0c6b02d4fa Bjorn Helgaas     2015-06-15  315  		ctrl_err(ctrl, "link training error: status %#06x\n",
3784e0c6b02d4fa Bjorn Helgaas     2015-06-15  316  			 lnk_status);
1a84b99ccbb954c Bjorn Helgaas     2013-12-14  317  		return -1;
^1da177e4c3f415 Linus Torvalds    2005-04-16  318  	}
^1da177e4c3f415 Linus Torvalds    2005-04-16  319  
fdbd3ce9efb3a04 Yinghai Lu        2011-11-07  320  	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
fdbd3ce9efb3a04 Yinghai Lu        2011-11-07  321  
1a84b99ccbb954c Bjorn Helgaas     2013-12-14  322  	if (!found)
1a84b99ccbb954c Bjorn Helgaas     2013-12-14  323  		return -1;
2f5d8e4ff947ad6 Yinghai Lu        2012-01-27  324  
1a84b99ccbb954c Bjorn Helgaas     2013-12-14  325  	return 0;
^1da177e4c3f415 Linus Torvalds    2005-04-16  326  }
^1da177e4c3f415 Linus Torvalds    2005-04-16  327  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37370 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-10-09 10:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-06 18:24 [PATCH] PCI: pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status() Sanjay R Mehta
2020-10-06 19:38 ` Lukas Wunner
2020-10-08  7:13   ` Sanjay R Mehta
2020-10-08 11:29     ` Andy Shevchenko
2020-10-09 10:34     ` Lukas Wunner
2020-10-07  9:30 ` Dan Carpenter
2020-10-07  9:30   ` [kbuild] " Dan Carpenter
2020-10-07  9:30   ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2020-10-07  9:18 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.