Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3729145rdg; Wed, 18 Oct 2023 04:34:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHX26INfo4K6C5KCGou2mrf7z9nTYUDNk17KETEaj+zd+2085+WmPDqyA6ySFh2+wK+GCad X-Received: by 2002:a17:90a:bd0d:b0:27c:ecec:8854 with SMTP id y13-20020a17090abd0d00b0027cecec8854mr7227752pjr.7.1697628892481; Wed, 18 Oct 2023 04:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697628892; cv=none; d=google.com; s=arc-20160816; b=SoBA9xD7A8d3kErnxq54CRfXNTFa4VrKxA38Dy3nrVKRgeqMC8VH9q5YW1+6f+QTUA iR0+NWslJTj4bhhG/OhlBNXKoax6v3EZdykXDKPQRbi4XYnF58Qu4pxDnCoXG+q3mZu0 h8faHGyV7PCmzfQTLWm0kgdFVxMGv4E9547NkvN395K2mNZ9XtBFgYmp5JhXx0UMZJ+Z z50svKB+R5aYl6QRmf/jVVFrUVqRXNBQ2Cu6IhrGHVqn/N7P3+61bwaQp2ogf3JJxBHJ 7/dXYM1F7cJoLt5ASpFUq/jTUb7qy6ZAveVsAU4anx/jxLLHT81f920MqX0V3atR0B/v DcdQ== 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=nfRQcQcln4VXgEw3SKTjbEo141OrnL/o2od2t1nCocM=; fh=a4jVY77fL8q59y9vETjVHhCjkDpQmBwhOdq5bpbAGHU=; b=qTKpQ9cOl6BgWgf3997UfRkd0uzxSLZTH8VgAoL80jtYzk62uVexE3VBVpynNoD3ne lrAsQ0lwHFH8x7y6R5G5NQRZcvj2i5/Q7sZYEdBVDWdScxxJ6pq5SkaCX2XG3cL+pZaj 9xzmlMHbPPoGwRsyJb+Pq1Yhgecs2Cp8y3vvpVLt/UpM5LUgeHv7zWSDK/ckVp2wroL0 5ttmcei8KmwpwTegeURCqrsmDsqGHtK/bgnukfiEt9hv0L2THLy/SsRBP4jgRq6aEjP3 v39TW3HwBi9DS2j/Ckl5bzkqnrzeJm+13Zq3cNT79qu5JX3phWsOBLshL1/LLvp8Ha5p ZDAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n+mNjmKR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t1-20020a17090aba8100b0027cef9ad081si527403pjr.164.2023.10.18.04.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 04:34:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n+mNjmKR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id F0A5180220EC; Wed, 18 Oct 2023 04:34:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbjJRLeb (ORCPT + 99 others); Wed, 18 Oct 2023 07:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231176AbjJRLeZ (ORCPT ); Wed, 18 Oct 2023 07:34:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85F7B11A; Wed, 18 Oct 2023 04:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697628863; x=1729164863; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VjreTDi7jjJH97Z5MyoUOCUozCMclaID/DbiusXdx6k=; b=n+mNjmKR7c2Bqus+QmqeZqy4DnKw0j/iAXSscaw8HOCvNFgrducuxp7G 067EiZeIxAzLh3+EPBf7NSPitb4GBmSUFgV0d7pkpCziTU5T4ZOcLGNA6 2Zncv6woiUzgt6QK0KC/84blXuPu9Sg0Eat5zva/JhXWhPAc79hIHwxW7 IWw1chKq9p0WO+FODIthqXp8KytqIPmfEGRaqWUwD4hTAq2ogWjeTT1Et QJAbjH2AMKK9vYI04le1Rgu6vmFOIMRlBwCDKZ1j/YkBMt4wYnNjKw+ot oI1+0twJOoYYDJ4cK/eytJEs1wRmWMY9+jQkBzEurxJw1Ncjro/PFUHiM Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="383215893" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="383215893" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 04:34:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="826855199" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="826855199" Received: from suguccin-mobl1.amr.corp.intel.com (HELO localhost) ([10.252.44.63]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 04:34:13 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Jonathan Cameron , Mahesh J Salgaonkar , "Oliver O'Halloran" , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 4/7] PCI/DPC: Use FIELD_GET() Date: Wed, 18 Oct 2023 14:32:51 +0300 Message-Id: <20231018113254.17616-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231018113254.17616-1-ilpo.jarvinen@linux.intel.com> References: <20231018113254.17616-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 04:34:50 -0700 (PDT) From: Bjorn Helgaas Use FIELD_GET() to remove dependencies on the field position, i.e., the shift value. No functional change intended. Signed-off-by: Ilpo Järvinen Signed-off-by: Bjorn Helgaas --- drivers/pci/pcie/dpc.c | 5 +++-- drivers/pci/quirks.c | 2 +- include/uapi/linux/pci_regs.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index 3ceed8e3de41..a5c259ada9ea 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -9,6 +9,7 @@ #define dev_fmt(fmt) "DPC: " fmt #include +#include #include #include #include @@ -202,7 +203,7 @@ static void dpc_process_rp_pio_error(struct pci_dev *pdev) /* Get First Error Pointer */ pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &dpc_status); - first_error = (dpc_status & 0x1f00) >> 8; + first_error = FIELD_GET(PCI_EXP_DPC_RP_PIO_FEP, dpc_status); for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) { if ((status & ~mask) & (1 << i)) @@ -338,7 +339,7 @@ void pci_dpc_init(struct pci_dev *pdev) /* Quirks may set dpc_rp_log_size if device or firmware is buggy */ if (!pdev->dpc_rp_log_size) { pdev->dpc_rp_log_size = - (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8; + FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, cap); if (pdev->dpc_rp_log_size < 4 || pdev->dpc_rp_log_size > 9) { pci_err(pdev, "RP PIO log size %u is invalid\n", pdev->dpc_rp_log_size); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index eeec1d6f9023..a9fdc2e3f110 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -6154,7 +6154,7 @@ static void dpc_log_size(struct pci_dev *dev) if (!(val & PCI_EXP_DPC_CAP_RP_EXT)) return; - if (!((val & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8)) { + if (FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, val) == 0) { pci_info(dev, "Overriding RP PIO Log Size to 4\n"); dev->dpc_rp_log_size = 4; } diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 495f0ae4ecd5..2d6df02a4b93 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -1047,6 +1047,7 @@ #define PCI_EXP_DPC_STATUS_INTERRUPT 0x0008 /* Interrupt Status */ #define PCI_EXP_DPC_RP_BUSY 0x0010 /* Root Port Busy */ #define PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */ +#define PCI_EXP_DPC_RP_PIO_FEP 0x1f00 /* Root Port PIO First Error Pointer */ #define PCI_EXP_DPC_SOURCE_ID 0x0A /* DPC Source Identifier */ -- 2.30.2