From patchwork Wed Sep 13 12:27:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 139203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp40742vqi; Wed, 13 Sep 2023 18:17:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBSKg89cfKvkSymQyOFBbF2zckov3+mYfq5ejzBm8tgapvMiV7BxElfLGuORWsaokI6GAo X-Received: by 2002:a17:90b:1056:b0:26d:17da:5e9f with SMTP id gq22-20020a17090b105600b0026d17da5e9fmr4040913pjb.1.1694654256844; Wed, 13 Sep 2023 18:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694654256; cv=none; d=google.com; s=arc-20160816; b=ClseVRPoofhho6WcJIN6xbFTR1kN1MJQdSXgflhdBtqcN/TiY4vIR3MkJTw6FH2mGZ w+dBF7/Fye7HzDGUl291oA8vF6QW8u0TqNBGssillRmA8eezy87xL58ytnifX+s+YMpG uvPU05WPd3Swiv4uilA50zWaJrQ0MVQXVljQXFAf2aGMQizgMvdDeOulyKMckQHyR2O1 3Ji6hQnC5onylK7ft7qOonaa1bzPeau7x/OM3THMf0yAEgjStG9Ogt8Cf1EM3U2YtZUP pqnu+wKSuitagGQMW9NJ/dp6Evej2cjMMU+uEQv1vpfWr1LBd1n7Rn3s8o/ix3ia9CFs 5zgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aG+seAEWJivQo2wRDqg+8qxnhwYw6sHS0Q6hn3asOks=; fh=TTiIDa12Uva7EtT9KWdViM6meb+1NkLz8d4vL4OGn0M=; b=exnc+B24ueKtwMku7rukRW4MX4nxPjS1sqTq+4NWWT86Ryh35+mmJ3HJALAq45tNA9 64WhoiIbBnd0iNxTjPdCeeIU6AWo6AJ+rSkfaBlRudq3Rkv4U8Bl90qcja5FP8Yl86j8 dRhWdaLK9ny6+IAQxpDMOg7Js6nojgmWZMzwXNpv7YK3ngO9QRg4jtx4YHAGVUq0yTG2 WhthayNvUfa5A/R4qed5Xvfog1hA+NxCenss4wul4/8Z0yhVandq0R6I7MN9Q78yqDBu A5j3udrCeO5tdfhCaEI2wz4jFUM9l3Z4lAdVpECK+oupmPmNzDlrfoQgLsBwWYfQYRrZ 47WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Hdi8p3qA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s8-20020a17090ad48800b0027455c727f5si520161pju.84.2023.09.13.18.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:17:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Hdi8p3qA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D13EE840B7FF; Wed, 13 Sep 2023 05:30:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240458AbjIMMas (ORCPT + 36 others); Wed, 13 Sep 2023 08:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240570AbjIMMan (ORCPT ); Wed, 13 Sep 2023 08:30:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF8BC1BCE; Wed, 13 Sep 2023 05:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694608239; x=1726144239; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+p2qHcmN288VJTNmarM516bgZohk8ZtzFjtp/gNHNio=; b=Hdi8p3qADp2DedEUei1iJZvjf3hCAgdsrd2EdoSFdpPGWpoiKzHkzIKx ucotlmanpLA3thVUoPCGHYGVHueYRbr7yRRdxiBxA/GUYbn8XIQzRhxmc N1/9obp7db0kMrGUIV5jAq17CzYP4BXUqbDhGNEGGImqZ2K+fPD3jUVib x0UtFbJKNDGmlnUM8Hdg4CjgET0mBq+CrTIsroqunETsa1pb/szVnQ41p 1og7louorEMT34L1GJpSoA3bSYkltpyJxBQJ240Fxb3xKdokbQYawraVW 8ePH/P7w0sCav2rvOmlCFMA5qNwyg7bl1zIOa5Gmlu/9UVhAKsr5l6IR0 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="368912450" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="368912450" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 05:28:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="693836640" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="693836640" Received: from pakurapo-mobl3.ger.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.249.45.213]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 05:28:13 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Jonathan Cameron , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Jonathan Cameron Subject: [PATCH v2 04/10] PCI: tegra194: Use FIELD_GET()/FIELD_PREP() with Link Width fields Date: Wed, 13 Sep 2023 15:27:42 +0300 Message-Id: <20230913122748.29530-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230913122748.29530-1-ilpo.jarvinen@linux.intel.com> References: <20230913122748.29530-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 05:30:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776973782146561460 X-GMAIL-MSGID: 1776973782146561460 Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of custom masking and shifting. Similarly, change custom code that misleadingly used PCI_EXP_LNKSTA_NLW_SHIFT to prepare value for PCI_EXP_LNKCAP write to use FIELD_PREP() with correct field define (PCI_EXP_LNKCAP_MLW). Signed-off-by: Ilpo Järvinen Reviewed-by: Jonathan Cameron --- drivers/pci/controller/dwc/pcie-tegra194.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c index 4bba31502ce1..248cd9347e8f 100644 --- a/drivers/pci/controller/dwc/pcie-tegra194.c +++ b/drivers/pci/controller/dwc/pcie-tegra194.c @@ -9,6 +9,7 @@ * Author: Vidya Sagar */ +#include #include #include #include @@ -346,8 +347,7 @@ static void apply_bad_link_workaround(struct dw_pcie_rp *pp) */ val = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA); if (val & PCI_EXP_LNKSTA_LBMS) { - current_link_width = (val & PCI_EXP_LNKSTA_NLW) >> - PCI_EXP_LNKSTA_NLW_SHIFT; + current_link_width = FIELD_GET(PCI_EXP_LNKSTA_NLW, val); if (pcie->init_link_width > current_link_width) { dev_warn(pci->dev, "PCIe link is bad, width reduced\n"); val = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base + @@ -760,8 +760,7 @@ static void tegra_pcie_enable_system_interrupts(struct dw_pcie_rp *pp) val_w = dw_pcie_readw_dbi(&pcie->pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA); - pcie->init_link_width = (val_w & PCI_EXP_LNKSTA_NLW) >> - PCI_EXP_LNKSTA_NLW_SHIFT; + pcie->init_link_width = FIELD_GET(PCI_EXP_LNKSTA_NLW, val_w); val_w = dw_pcie_readw_dbi(&pcie->pci, pcie->pcie_cap_base + PCI_EXP_LNKCTL); @@ -920,7 +919,7 @@ static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp) /* Configure Max lane width from DT */ val = dw_pcie_readl_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKCAP); val &= ~PCI_EXP_LNKCAP_MLW; - val |= (pcie->num_lanes << PCI_EXP_LNKSTA_NLW_SHIFT); + val |= FIELD_PREP(PCI_EXP_LNKCAP_MLW, pcie->num_lanes); dw_pcie_writel_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKCAP, val); /* Clear Slot Clock Configuration bit if SRNS configuration */