Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp870615lqs; Fri, 14 Jun 2024 08:02:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqStweeDqWQ2TkxPPHwiILfDzraNJUyR+j0ydqSX6mOaPLi50JQCUfgCBSzC1ga00IXdBOY1Hg4WxaOPXzF+CKomf78pk94TFT/ZbuLA== X-Google-Smtp-Source: AGHT+IFyWEwoaxk34NQWlcnvAOaZiNmk8WlrJbpPsJmFeA2TWn4iYlcaqdbcvnM2Q2LPPcNBCG72 X-Received: by 2002:a05:6830:4413:b0:6f9:7919:a33a with SMTP id 46e09a7af769-6fb937849d6mr3763344a34.19.1718377330505; Fri, 14 Jun 2024 08:02:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718377330; cv=pass; d=google.com; s=arc-20160816; b=B35ECUa1fYT6WWyg5DVVPCLM1fLPVUHi/Omv1aamxIQnqyHZ4dZ1h1l8R18Yf1YWve 7gpV+N3a9JIMvU/tJCbxIo/zojwGXGGdXI6G9Zn1LERmHAwAmed06BZ2sz6FpImurvo1 y+pLtzJKPpPSLFqfTFofmfcCOz6GthgBioZANuU6aKj3v5gZdxk26sFPKKvzIkCVocR6 8rJkoNggVzCnK8/rzZybdkiYpM6BtTw4Md5pGysuA69DYDfXi6dRgAU1ojZnuRITvuJJ sxn4iU6l1Twij8YJ8q0XAPW3zq3JU3LGxeO3tsLkRLq4Xp3Grir84Qt8vqy3+APP3KP8 wHXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=tTRIXQ0zCF1cKj/W1Gzxydi7oiSYsgqW/YBslgqxaUg=; fh=fuHXiyUfYFovODHdOGpufYY4cj/mwOcl5U1Qs0jJPIY=; b=E2tNV3QoJ3pDJhP4iffJy4kddD+kS6ZErfaFjoHwaCc6RudNXRUq9mchQojAyBRmDr R7jdB7qQQDQi2Vy9T/BkTNRSQtQIHU3XqEAZ+CDYNZI5PO8jcB+qlnSWpy3I522uxxHx Y3gBZb+KJIDSmWg6pz5CEZN+5tHRJ+9Yox9W+wkWp/eJCa+mtNkuvP6AfWv/STl/i+dL IaOKqVFox9OclahO2b+qlqHSnW9UK/BoWHQfS8djGH78oGijOdoQVvH6s7Yo5nI+77Ob CYpMzl5nv3HDzrxjIBFPH78FTFTvLOq6qFLYfF/nkZLp1iYBWIHGYg3PjSBOlZqGoW3g UURw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nopoLBWV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 46e09a7af769-6fb5b1b1547si1396861a34.115.2024.06.14.08.02.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:02:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nopoLBWV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F52F28598D for ; Fri, 14 Jun 2024 12:32:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 500DD1990C2; Fri, 14 Jun 2024 12:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nopoLBWV" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 A802312D74D; Fri, 14 Jun 2024 12:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718368334; cv=none; b=dWMUsrhVdMHqog/9lV20iqcrAbav2B7D+/j1lqiAmWW9SpaktICbTFYI7vP1ml3LgrsbQit20CMOO+xFkwVyxKcdIlVP6XMAvjCU+OwoHxWjyd/LTNiYEJGxAkpFhjGn7MKIL+PjApb5S/qH/dQ6O1S98fvs077wLC5x6pyHpmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718368334; c=relaxed/simple; bh=d4Bv2ZzuYu1QopJr82AZ6xrYRfuX0NoNXCgdGIEC8Nc=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=HHVZ8apKioEiOszJsF+u4OX3hTdFxLTW8GU8H67pNQp8YLAcHOpIf3TVnnF+zY1xc85KBPr3J2DblNG/YsbNZh+E/vm07k1Jl65FBnfY3EykP9bEoREhof4qlz+TmKEhwSuZyPpm4GNgpfF+4X4GGQKt5lNymEUCtJsNfzOpIaU= 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=nopoLBWV; arc=none smtp.client-ip=198.175.65.13 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718368333; x=1749904333; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=d4Bv2ZzuYu1QopJr82AZ6xrYRfuX0NoNXCgdGIEC8Nc=; b=nopoLBWVgSFSExTMBwO/aW4kMJIYsMsdyNQsT72/1dXDRK0NDOW7e2Ri ceuEArmNwdkhMVMd+CN9SiFjRFtSgjkYD6ZA55/XNE48UAEuLU3pjmTif s/M49bCv5Kra3GinF/wHpe3i2Mx9WMMN9yEXRhbofrKv/6XRang1O96Yh FAd6DBoLOAgGWYd5ykOyR9V1jijDYBnyA0S6IBRSQf1L7Wz4ToKz4veHd F7Uu4Veuqa2gnT4s/a9QQGVEButySgp/xXDIdRWqfk3qL8qQKqLXF9WHE VkvljUzRrgdwYCo6suW+yUzPlY/2V14RgaBAUsCHDCouk3JI7alnFOR9r Q==; X-CSE-ConnectionGUID: c4nys7iCQhSEjg28/63XYw== X-CSE-MsgGUID: knrB/t/5TE6ckMB8gDY8sA== X-IronPort-AV: E=McAfee;i="6700,10204,11103"; a="26366574" X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="26366574" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2024 05:32:12 -0700 X-CSE-ConnectionGUID: tdkimbqMR1mmScCfKZcLzg== X-CSE-MsgGUID: KkhV+DFFQ7q2xccIm4rZzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="40414794" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.222]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2024 05:32:04 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Fri, 14 Jun 2024 15:32:01 +0300 (EEST) To: Krishna chaitanya chundru cc: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , Lorenzo Pieralisi , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Bjorn Helgaas , johan+linaro@kernel.org, bmasney@redhat.com, djakov@kernel.org, Krzysztof Kozlowski , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, LKML , linux-pci@vger.kernel.org, vireshk@kernel.org, quic_vbadigan@quicinc.com, quic_skananth@quicinc.com, quic_nitegupt@quicinc.com, quic_parass@quicinc.com, krzysztof.kozlowski@linaro.org Subject: Re: [PATCH v14 3/4] PCI: Bring the PCIe speed to MBps logic to new pcie_link_speed_to_mbps() In-Reply-To: <20240609-opp_support-v14-3-801cff862b5a@quicinc.com> Message-ID: References: <20240609-opp_support-v14-0-801cff862b5a@quicinc.com> <20240609-opp_support-v14-3-801cff862b5a@quicinc.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=US-ASCII On Sun, 9 Jun 2024, Krishna chaitanya chundru wrote: > Bring the switch case in pcie_link_speed_mbps() to new function to > the header file so that it can be used in other places like > in controller driver. > > Signed-off-by: Krishna chaitanya chundru > Reviewed-by: Manivannan Sadhasivam > Acked-by: Bjorn Helgaas > --- > drivers/pci/pci.c | 19 +------------------ > drivers/pci/pci.h | 22 ++++++++++++++++++++++ > 2 files changed, 23 insertions(+), 18 deletions(-) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index d2c388761ba9..6e50fa89b913 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -6027,24 +6027,7 @@ int pcie_link_speed_mbps(struct pci_dev *pdev) > if (err) > return err; > > - switch (to_pcie_link_speed(lnksta)) { > - case PCIE_SPEED_2_5GT: > - return 2500; > - case PCIE_SPEED_5_0GT: > - return 5000; > - case PCIE_SPEED_8_0GT: > - return 8000; > - case PCIE_SPEED_16_0GT: > - return 16000; > - case PCIE_SPEED_32_0GT: > - return 32000; > - case PCIE_SPEED_64_0GT: > - return 64000; > - default: > - break; > - } > - > - return -EINVAL; > + return pcie_link_speed_to_mbps(to_pcie_link_speed(lnksta)); pcie_link_speed_mbps() calls pcie_link_speed_to_mbps(), seems quite confusing to me. Perhaps renaming one to pcie_dev_speed_mbps() would help against the almost identical naming. In general, I don't like moving that code into a header file, did you check how large footprint the new function is (when it's not inlined)? Unrelated to this patch, it would be nice if LNKSTA register read would not be needed at all here but since cur_bus_speed is what it is currently, it's just wishful thinking. > } > EXPORT_SYMBOL(pcie_link_speed_mbps); > > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h > index 1b021579f26a..391a5cd388bd 100644 > --- a/drivers/pci/pci.h > +++ b/drivers/pci/pci.h > @@ -333,6 +333,28 @@ void pci_bus_put(struct pci_bus *bus); > (speed) == PCIE_SPEED_2_5GT ? 2500*8/10 : \ > 0) > > +static inline int pcie_link_speed_to_mbps(enum pci_bus_speed speed) > +{ > + switch (speed) { > + case PCIE_SPEED_2_5GT: > + return 2500; > + case PCIE_SPEED_5_0GT: > + return 5000; > + case PCIE_SPEED_8_0GT: > + return 8000; > + case PCIE_SPEED_16_0GT: > + return 16000; > + case PCIE_SPEED_32_0GT: > + return 32000; > + case PCIE_SPEED_64_0GT: > + return 64000; > + default: > + break; > + } > + > + return -EINVAL; > +} -- i.