Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp733434rdg; Wed, 11 Oct 2023 04:12:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbGtVs1AEl1leY5MPUbx54BdbNmqj97+b9iwIBpZ2/QeLt5g9sA8fz9/mVjAh0KyyHLxYy X-Received: by 2002:a17:90b:1d0d:b0:274:6cc9:ec69 with SMTP id on13-20020a17090b1d0d00b002746cc9ec69mr17383058pjb.49.1697022737758; Wed, 11 Oct 2023 04:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022737; cv=none; d=google.com; s=arc-20160816; b=lExkb6Nna8IqKcN0wiXzCD5rbeVIn6u/ubRIjcJT/tgDXa9dvaoyDVHZ1bJxC72Z0l W2eB6G8mFJDGPiOU09lEjqGI0H8Thz8x2H7+rQc79gTG9C1BhSaHdW4xzZe23tG/Z1sq TfUZedU6Pe2cIdkxWAtYSxpch/jtM6tiG6OL/GlS2JWzNce5HOduzaqPAOhnOPkxhWSj 9p9CPHerqsGi7h3vbP6O5JK2o69G6LekyuWiLA42ikaL9iZBcKJfix2aEc2F2HiXJAQY k3rYamo0YKv6S9vvKWq3o+QI1gsjH/N5rLtmaMgOoRNDJsc6eLzuKv6YbwV45qR69/YG yE3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=7c6wv5nVgtdeOjufJLRuGtF+LbTKmIipROiyUtWEkec=; fh=3Y7Ht7EWw/18yRcMHQle9GJUsayF3jozSVIhvuxV6QI=; b=BxlpznCnA6Bw1cG2c+2wMtHhe9XHXLcj8cSROB2tLqZWVbbM4cN3QB5AtiLJ12n1UW qfDFZKCvFAlBJsW4cuB6VAtHqtFz2ZC64qSo2MW8/S0HunE3zcxJx1LKSYs64yZkzws/ uaQG7mZENYToVDhqyA3KvNbWIlUKGkKpVx/NQCZbUn6m8pCRN28DuyG9m9RT5emNCl3b rrNa1wGqiYeBsQhAcBshGNFxo/Lu4eZ+w1sVKxKrAYu6l3eq71ybJLzl/2RQl/YExYIy k3rZKVc39+pKz0kFevq9kmb/fYyJZzbzU3fkj/PYJnsJbQ+OSbAk/IFhGZjUpemy+TmP LaTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AWdNh5w5; 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 j8-20020a17090a738800b00278ee2b717fsi2312643pjg.85.2023.10.11.04.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:12:17 -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=AWdNh5w5; 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 1498F80AC581; Wed, 11 Oct 2023 04:12:15 -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 S231608AbjJKLMH (ORCPT + 99 others); Wed, 11 Oct 2023 07:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjJKLMG (ORCPT ); Wed, 11 Oct 2023 07:12:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 307928F; Wed, 11 Oct 2023 04:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697022725; x=1728558725; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=jPIy1MHT8CauY6fC3x5500c2jjdrHnqJ1dSekrvSM9A=; b=AWdNh5w5OXEaRWM2rUzIPPHMWcE7ZJDPS9tXFuY3OVX1UMWO99NiXrAl ohWwzm2HmK8lQ1IibWxPbMgniQVc4HmqY1DLh+31oqNyulbJ8sUdMoUah qjmxih9Rmb7q4tuHXop4kH9VDMatjJsdMymaSf4J/lCb1bZqvXTfZfy2Q wEJ7tKY1GUvHljEZBnjGWJtigil1INtkKZmKdfwZpMAONVB7HMyEaI7MS /ep9Y/6s+LiQSJzKQVX11oCt04ajuTi8OqoPSU08xyojUY3sDQNGCieDF HDGdOlIPeH6MC3xUv0/ngiIOmcGCwh0ZlDPBoyMEPsuqroBemOY1cU2UD A==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="387478973" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="387478973" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 04:01:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="703689784" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="703689784" Received: from opipikin-mobl2.ger.corp.intel.com (HELO sdodaev-mobl.ger.corp.intel.com) ([10.252.57.154]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 04:01:19 -0700 Date: Wed, 11 Oct 2023 14:01:13 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas cc: linux-pci@vger.kernel.org, Jonathan Cameron , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lorenzo Pieralisi , LKML , Bjorn Helgaas Subject: Re: [PATCH 06/10] PCI/DPC: Use FIELD_GET() In-Reply-To: <20231010204436.1000644-7-helgaas@kernel.org> Message-ID: References: <20231010204436.1000644-1-helgaas@kernel.org> <20231010204436.1000644-7-helgaas@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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, 11 Oct 2023 04:12:15 -0700 (PDT) X-Spam-Level: ** On Tue, 10 Oct 2023, Bjorn Helgaas wrote: > From: Bjorn Helgaas > > Use FIELD_GET() to remove dependences on the field position, i.e., the > shift value. No functional change intended. > > Signed-off-by: Bjorn Helgaas > --- > drivers/pci/pcie/dpc.c | 9 +++++---- > drivers/pci/quirks.c | 2 +- > include/uapi/linux/pci_regs.h | 1 + > 3 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c > index 3ceed8e3de41..6e551f34ec63 100644 > --- a/drivers/pci/pcie/dpc.c > +++ b/drivers/pci/pcie/dpc.c > @@ -8,6 +8,7 @@ > > #define dev_fmt(fmt) "DPC: " fmt > > +#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_STATUS_FIRST_ERR, dpc_status); > > for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) { > if ((status & ~mask) & (1 << i)) > @@ -270,8 +271,8 @@ void dpc_process_error(struct pci_dev *pdev) > pci_info(pdev, "containment event, status:%#06x source:%#06x\n", > status, source); > > - reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1; > - ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5; > + reason = FIELD_GET(PCI_EXP_DPC_STATUS_TRIGGER_RSN, status); > + ext_reason = FIELD_GET(PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT, status); > pci_warn(pdev, "%s detected\n", > (reason == 0) ? "unmasked uncorrectable error" : > (reason == 1) ? "ERR_NONFATAL" : BTW, it seems we're doing overlapping work here with many of these patches. It takes some time to think these through one by one, I don't just autorun through them with coccinelle so I've not posted my changes yet. I went to a different direction here and named all the reasons too with defines and used & to get the reason in order to be able to compare with the named reasons. You also missed convering one 0xfff4 to use define (although I suspect it never was your goal to go beyond FIELD_GET() here). > @@ -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 833e5fb40ea5..e97a06b50f95 100644 > --- a/include/uapi/linux/pci_regs.h > +++ b/include/uapi/linux/pci_regs.h > @@ -1046,6 +1046,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_STATUS_FIRST_ERR 0x1f00 /* RP PIO First Error Ptr */ If you prefer consistency, there already FEP used for "First Error Pointer" used in another define. > #define PCI_EXP_DPC_SOURCE_ID 0x0A /* DPC Source Identifier */ -- i.