From nobody Tue Nov 26 02:25:57 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D41E1194C9E; Tue, 22 Oct 2024 09:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588318; cv=none; b=RLnwVh2Y7pGAcz48bDuXXsLA9+vJAvglDOu3M7++eNe0+PJ+cHgfmPyRzx5zD/kUe6DCao1MtP3Bz+P9KVTxKzUfLUxhnSbznkvZHMRFCuGjHZ0P8nC8ZFS8jEHgGJnsQjIbxvwoFiX/UwA9jPUXLE4qO57S5oa9xEr9yKw6yFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588318; c=relaxed/simple; bh=SKDmrC6wxkBh0QMo8rcm+HsLNB4sdnUMvZwopu+gpCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=UICsRtXsc32PuvcGH5ttkM/rDm6usm3mdfjHBIvv0JffVEbV3gKHQuGfb4ovtkdfH6SqBcKlkmaaDRZf1GdHvetbeg8IWQ7fD1sXiMo326I3Y0/c9hswbwOnPY9hMVKzuWAJ9if3CzTV+losgEqScZ2/J6k55/qo+lvvVurMzQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Qj5PGvVL; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Qj5PGvVL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729588317; x=1761124317; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SKDmrC6wxkBh0QMo8rcm+HsLNB4sdnUMvZwopu+gpCw=; b=Qj5PGvVLnCcYIBAkwL3ej7aDjVUI+XiS8geeeJWSfCXapjvEsxUE2tCy ZmIK+6duzIpnyoziGNgSBzgnULAgcAY0fNLd5jHcPAAlvTK5bkvl4HmAa tM+45iqSygsmmUZgCC33nFqCh64YWHwpNtrH+9gaB1mGjyRK8XFBdK9DK hLW4/oLNXegq9FMvZWVXG5jnhyv+Llpm7mUySiYq1fPK3bXYppsGHN7XS dg4dnQwAvSK7EhWWi8F5PCwbiP8CpBs6Utr0qOJYSMmJOX1r56U/jhKiL B25TE5tcSk/nYizeimVYZZzAGYHSsrYqccol/1S/KzPV3K9JliaRec5x/ w==; X-CSE-ConnectionGUID: HAhCNeqwTmSC5Y7vkAuDhQ== X-CSE-MsgGUID: 1qNBjOsOSka/DaVMHB7uww== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28885654" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28885654" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:11:57 -0700 X-CSE-ConnectionGUID: Im9MGC4zTW+5l/RHao6Q4g== X-CSE-MsgGUID: g3viHYcdQfan0VTNUcCnVQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,222,1725346800"; d="scan'208";a="80157937" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.146]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:11:54 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 1/4] PCI: cpqphp: Fix PCIBIOS_* return value confusions Date: Tue, 22 Oct 2024 12:11:37 +0300 Message-Id: <20241022091140.3504-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> References: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Code in and related to PCI_RefinedAccessConfig() has 3 types of return type confusion: - PCI_RefinedAccessConfig() tests pci_bus_read_config_dword() return value against -1. - PCI_RefinedAccessConfig() returns both -1 and PCIBIOS_* return codes. - Callers of PCI_RefinedAccessConfig() only test for -1. Make PCI_RefinedAccessConfig() return PCIBIOS_* codes consistently and adapt callers accordingly. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/hotplug/cpqphp_pci.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_= pci.c index 718bc6cf12cb..974c7db3265b 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c @@ -135,11 +135,13 @@ int cpqhp_unconfigure_device(struct pci_func *func) static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn= , u8 offset, u32 *value) { u32 vendID =3D 0; + int ret; =20 - if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID) =3D=3D = -1) - return -1; + ret =3D pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID); + if (ret !=3D PCIBIOS_SUCCESSFUL) + return PCIBIOS_DEVICE_NOT_FOUND; if (PCI_POSSIBLE_ERROR(vendID)) - return -1; + return PCIBIOS_DEVICE_NOT_FOUND; return pci_bus_read_config_dword(bus, devfn, offset, value); } =20 @@ -202,13 +204,15 @@ static int PCI_ScanBusForNonBridge(struct controller = *ctrl, u8 bus_num, u8 *dev_ { u16 tdevice; u32 work; + int ret; u8 tbus; =20 ctrl->pci_bus->number =3D bus_num; =20 for (tdevice =3D 0; tdevice < 0xFF; tdevice++) { /* Scan for access first */ - if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) =3D=3D = -1) + ret =3D PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); + if (ret) continue; dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice); /* Yep we got one. Not a bridge ? */ @@ -220,7 +224,8 @@ static int PCI_ScanBusForNonBridge(struct controller *c= trl, u8 bus_num, u8 *dev_ } for (tdevice =3D 0; tdevice < 0xFF; tdevice++) { /* Scan for access first */ - if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) =3D=3D = -1) + ret =3D PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); + if (ret) continue; dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); /* Yep we got one. bridge ? */ --=20 2.39.5 From nobody Tue Nov 26 02:25:57 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B49C3196D98; Tue, 22 Oct 2024 09:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588324; cv=none; b=h5dCogyjiwE+LGpcjGXDGNNlmgMWYZRVhMjTG3as1RTIt8byKi3OMYXq27LzgiV8camfOe3HIiDdURFLqCB/vQQWrxHafpU7icQNgnEq8efhJ4Mrgg2AtPcCavnQt6w6d3GJVCeC4TW7cuy0DtQHpZVPDHJZUfps1zIu/0O/EFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588324; c=relaxed/simple; bh=4LJ4d3l78k86ZkaKlk3S4ZkJk0tpxXAt6ZTjN54rH+w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Rx84JrH8O1FjhYJ1yz/2M9/nicEfsqQ2y5YHj8PH4FLmXsv3b0CoxiR+TcRu3RWJMSI8xPxeGLkN0BQXdcELzWumditDICNfC9GIek560/pCB4MXdzt9+Se9N+IVCcoDrY0YxpEYQs21g20Lrw5Z/ftdx1FlGv8JfKVz1dPrMaw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XG0YlhqD; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XG0YlhqD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729588323; x=1761124323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4LJ4d3l78k86ZkaKlk3S4ZkJk0tpxXAt6ZTjN54rH+w=; b=XG0YlhqDKucTpnZms48P0ZE+L8kslzATwoZr+MnDnhYJvMLPoNZNfzA2 6CcptsIIthP4gnvca6IotObKJ4I04xU2Ms5CEt6ixnco+LA/kaFL0k9MA p5F+72xTziph785+p+2fD/0iI3snj6/opED0HzgKaRCm9MDGyBCoA9Si6 OVk/RkdCs/7xhOPsaw21t0fkLgesLcsCG0HuneJN2eG3vE9lreP6O1Aki H7Xjw0zpqL8Y0BeLigyeaCYEF6kYIt9hri47Ro99Lo7tVelHkUAvdBQc2 PZcITInOpyKqiynohawy0U0afur2RojCRDPoGmtp11R6pfXzhlwxYReJ/ w==; X-CSE-ConnectionGUID: l0I5O1TOQYu+sWQpP6L3xA== X-CSE-MsgGUID: HDMNQgKjSFeLztBllhw0xQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28885684" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28885684" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:12:03 -0700 X-CSE-ConnectionGUID: Gf5h3P3WSROESeXFGBTCQA== X-CSE-MsgGUID: jVfLFbSLSy2pE5zjQJbgLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,222,1725346800"; d="scan'208";a="80157962" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.146]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:12:00 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 2/4] PCI: cpqphp: Use pci_bus_read_dev_vendor_id() to detect presence Date: Tue, 22 Oct 2024 12:11:38 +0300 Message-Id: <20241022091140.3504-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> References: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The intent of the first part in PCI_RefinedAccessConfig() is to read Vendor ID register and detect presense of the device that way. Remove PCI_RefinedAccessConfig() (which was not named very helpfully to begin with) and replace the call with pci_bus_read_dev_vendor_id() + read config because it makes the logic more obvious at the caller side. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/hotplug/cpqphp_pci.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_= pci.c index 974c7db3265b..7844007dbc86 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c @@ -132,20 +132,6 @@ int cpqhp_unconfigure_device(struct pci_func *func) return 0; } =20 -static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn= , u8 offset, u32 *value) -{ - u32 vendID =3D 0; - int ret; - - ret =3D pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID); - if (ret !=3D PCIBIOS_SUCCESSFUL) - return PCIBIOS_DEVICE_NOT_FOUND; - if (PCI_POSSIBLE_ERROR(vendID)) - return PCIBIOS_DEVICE_NOT_FOUND; - return pci_bus_read_config_dword(bus, devfn, offset, value); -} - - /* * cpqhp_set_irq * @@ -211,7 +197,9 @@ static int PCI_ScanBusForNonBridge(struct controller *c= trl, u8 bus_num, u8 *dev_ =20 for (tdevice =3D 0; tdevice < 0xFF; tdevice++) { /* Scan for access first */ - ret =3D PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); + if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0)) + continue; + ret =3D pci_bus_read_config_dword(ctrl->pci_bus, tdevice, 0x08, &work); if (ret) continue; dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice); @@ -224,7 +212,9 @@ static int PCI_ScanBusForNonBridge(struct controller *c= trl, u8 bus_num, u8 *dev_ } for (tdevice =3D 0; tdevice < 0xFF; tdevice++) { /* Scan for access first */ - ret =3D PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); + if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0)) + continue; + ret =3D pci_bus_read_config_dword(ctrl->pci_bus, tdevice, 0x08, &work); if (ret) continue; dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); --=20 2.39.5 From nobody Tue Nov 26 02:25:57 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B2AE1974EA; Tue, 22 Oct 2024 09:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588330; cv=none; b=YNMEB7iGv3AA4B3wc9ELZwZoMewn7z6aRgICoFe3YDXYMHu8kjdeGiRphe/ul6PrFa5pWwVib7NDKa+zQY+zHSrTu4YaEhiYCv2nKvyryiYJzMBe5y3h/KOfxqB0YZMz1xHY5es2JBxmHfGGuL8ETJt/t0OzJOIVrneOSZDK/7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588330; c=relaxed/simple; bh=Zh5fxfVyxE39hNkaci5uSsCnRj62lxU34l8OCLLtS8M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=V7Mgc7gmup0mgM5ZLcwN1z4xgMkDz+N23WXqOwoNS31/IYZHxyvfZ4r/h0GtY/t0A3T4hyEFvgegYOzN09Uc1cNfnMNI6yaCzM0xQck7Bx85gMP5z8bZzPMLcG02OfEumeBzz1Rnqn4e0S9csnwtx1gdt7aKGydhqzkc7QoapHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YHYRLtQ8; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YHYRLtQ8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729588330; x=1761124330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Zh5fxfVyxE39hNkaci5uSsCnRj62lxU34l8OCLLtS8M=; b=YHYRLtQ8sTSvBZjsx+6CrkFZ8KB10xWiOrR8IKokzFWp9cX+GFZUD2XW cWiYe8cm5oJy/iSar+43xUGDq7pRDp7vqvuczAP98ButXIhqCnLlpeZlv TQBHZlcOCeWJOryEt3vOainXfXek5tNHNZGebiLcSqoa6Wks6W2Nuhi4i IOZncPPjtiGshOGs1omqFpHe8FvxGD/eHTxbzlg16IlUO242yUexXQ4Ad Vr+Vn4+VuBGtRsIGtTYMclZbtV2WYX1aZtDjjr+xKtmEin+JQRETQ7ZgA abTvGqfk6VDMYpXbjqDgylEE/K3kg4Qg5Ik3iypRdgWD/y5aCTzDseS5d w==; X-CSE-ConnectionGUID: 0W7G2BCzQsiFF0TfRjRLMw== X-CSE-MsgGUID: 0M1k2oz6SgmFg6yoqg9+eQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28885707" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28885707" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:12:10 -0700 X-CSE-ConnectionGUID: HQiOBNHQT6mYhVqatMkodQ== X-CSE-MsgGUID: q7wXa3B0ROKwRT4m8WJzTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,222,1725346800"; d="scan'208";a="80157990" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.146]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:12:07 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 3/4] PCI: cpqphp: Use define to read class/revision dword Date: Tue, 22 Oct 2024 12:11:39 +0300 Message-Id: <20241022091140.3504-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> References: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Replace literal 0x08 with PCI_CLASS_REVISION. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/hotplug/cpqphp_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_= pci.c index 7844007dbc86..558866c15e03 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c @@ -199,7 +199,7 @@ static int PCI_ScanBusForNonBridge(struct controller *c= trl, u8 bus_num, u8 *dev_ /* Scan for access first */ if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0)) continue; - ret =3D pci_bus_read_config_dword(ctrl->pci_bus, tdevice, 0x08, &work); + ret =3D pci_bus_read_config_dword(ctrl->pci_bus, tdevice, PCI_CLASS_REVI= SION, &work); if (ret) continue; dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice); @@ -214,7 +214,7 @@ static int PCI_ScanBusForNonBridge(struct controller *c= trl, u8 bus_num, u8 *dev_ /* Scan for access first */ if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0)) continue; - ret =3D pci_bus_read_config_dword(ctrl->pci_bus, tdevice, 0x08, &work); + ret =3D pci_bus_read_config_dword(ctrl->pci_bus, tdevice, PCI_CLASS_REVI= SION, &work); if (ret) continue; dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); --=20 2.39.5 From nobody Tue Nov 26 02:25:57 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC6DF146019; Tue, 22 Oct 2024 09:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588337; cv=none; b=CgmCRb3enf0Kf8TndDNy3ke6Yht07lbx+gtb3tML8qtnq2lzN6J9nFsg+RviuoNtXqbTR/1+ViXufomGodg97FLAAHjwJ8mqyj32RX9kyECxiQ6ozpp9FKOaHPqddh+jgWR952CyHQiPayFShxxfcAGetRqqO1Lg+HPHcWyzazo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729588337; c=relaxed/simple; bh=KGDP7VI1pQb1iUfsRT1pBSqOi6/saODSeKZUhCGUWUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ONfekVAElQYaJkcv50wShNxHOOwuMe+nbgGqS128APCh+XrTYrnlQQdhuNP62DIfgVCqeZtlmKWYwdb7jC2QwztG0xJptRf1Zf+3JZvu0ZHtRus+6POZdJTQ9d0xw2X2TOq9H+36QIR4aM8sFKba8Vj+emBIxEqXFPCxLfT2YZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CLVBPyNg; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CLVBPyNg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729588336; x=1761124336; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KGDP7VI1pQb1iUfsRT1pBSqOi6/saODSeKZUhCGUWUY=; b=CLVBPyNgJI442KtR8fbUcoY/3XMFpadekFQ5zls2IYngL4N/MX4CYNHk NmGLyVojs3dCAit+ULJtKpNfDGQ94TpbosGa3EbA5yWrq7MuAwxOET4WH f13FWNEQzZ1DEZJtFo9Z+lzBJu5/i0c73k7vVslS+LuHaybTDlNB3HBso iIkvMu/AGIPK4/NpZJYVks0UPk0qOQXqWgAdvbzr3Hn22XFz+VmCgoRMi 6KrC9B2vmsCS1M+AAzkMhyL6xhiv2Tmp/hunkTHu9tVnbO6WdtKaNRZaK ws5OF8Q1jVnozzQyuXdM6YSklM0y0SrLHRse1BCsOBTYJrbVedCmcmw52 w==; X-CSE-ConnectionGUID: XFo7W0mtSvKkr2k8XgtCvA== X-CSE-MsgGUID: SIxHC8zzRnaZP9j7blJJHA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28885737" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28885737" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:12:16 -0700 X-CSE-ConnectionGUID: YPi8VKT4SB26aWdABwwMRw== X-CSE-MsgGUID: XDZ8z7AeQ5iq18dNhKmDyQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,222,1725346800"; d="scan'208";a="80158002" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.146]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 02:12:13 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 4/4] PCI: cpqphp: Simplify PCI_ScanBusForNonBridge() Date: Tue, 22 Oct 2024 12:11:40 +0300 Message-Id: <20241022091140.3504-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> References: <20241022091140.3504-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable PCI_ScanBusForNonBridge() has two loops, first searching for non-bridges and second that looks for bridges. The second loop has hints in a debug print it should do recursion for buses underneath the bridge but no recursion is attempted. Since the second loop is quite useless in its current form, just eliminate it. This code hasn't been touched for very long time so either it's unused or the missing parts are not important enough for anyone to attempt to add them. Leave only a warning print and comment about the missing recursion for the unlikely case that somebody comes across the lack of functionality. In any case, search whether an endpoint exists downstream of a bridge sounds generic enough to belong to core so if the functionality is to be extended it should probably be moved into PCI core. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/hotplug/cpqphp_pci.c | 34 ++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_= pci.c index 558866c15e03..ef7534a3ca40 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c @@ -12,8 +12,11 @@ * */ =20 +#define pr_fmt(fmt) "cpqphp: " fmt + #include #include +#include #include #include #include @@ -190,8 +193,7 @@ static int PCI_ScanBusForNonBridge(struct controller *c= trl, u8 bus_num, u8 *dev_ { u16 tdevice; u32 work; - int ret; - u8 tbus; + int ret =3D -1; =20 ctrl->pci_bus->number =3D bus_num; =20 @@ -208,26 +210,20 @@ static int PCI_ScanBusForNonBridge(struct controller = *ctrl, u8 bus_num, u8 *dev_ *dev_num =3D tdevice; dbg("found it !\n"); return 0; - } - } - for (tdevice =3D 0; tdevice < 0xFF; tdevice++) { - /* Scan for access first */ - if (!pci_bus_read_dev_vendor_id(ctrl->pci_bus, tdevice, &work, 0)) - continue; - ret =3D pci_bus_read_config_dword(ctrl->pci_bus, tdevice, PCI_CLASS_REVI= SION, &work); - if (ret) - continue; - dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); - /* Yep we got one. bridge ? */ - if ((work >> 8) =3D=3D PCI_TO_PCI_BRIDGE_CLASS) { - pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECO= NDARY_BUS, &tbus); - /* XXX: no recursion, wtf? */ - dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice); - return 0; + } else { + /* + * XXX: Code whose debug printout indicated + * recursion to buses underneath bridges might be + * necessary was removed because it never did + * any recursion. + */ + ret =3D 0; + pr_warn("missing feature: bridge scan recursion not implemented\n"); } } =20 - return -1; + + return ret; } =20 =20 --=20 2.39.5