Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1189532rdg; Fri, 13 Oct 2023 13:02:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3xLAnrrdSfM4IZ22wgRNwP5oqfPdWd3Ku0/hbjN4KLcJi5BjD4xXNH+FwFaUqdWxoH2GO X-Received: by 2002:a05:6e02:1a4f:b0:352:a19c:a581 with SMTP id u15-20020a056e021a4f00b00352a19ca581mr35894199ilv.13.1697227377630; Fri, 13 Oct 2023 13:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697227377; cv=none; d=google.com; s=arc-20160816; b=szbs77kHjqGRFSAmZLskgLEfvb0N+LPhj+fM5Jt18eW8lk4xAYY7KPrYzUnBqwF1DQ tHsxGpksVoxyk6iCecDpwXXYZrepMPUHX4s27WsgPdF8i5+xM0w8pSNN9YyjEV8RdNLx cttH0zx7FGtq01F9R76Jw1QQP00OdiTmn0FPcEJBU1Y0Nw3+kQfYXh85LGEiMx3tKou1 vF3GhOS+yZOo3PScxtyFjFXerL4l7Bf/0UzdttpsFmMKKRRsE0PqzSqiSEc0LRr0UP0Y uqcaB0smZTaCQU3jL7lTLMfe58cZ44Rpl+evhTbyzzv+NejZUvaCb8wjMgN8xf7/Mab4 nLqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=db5cK4aLbA8OONEMI85DfG2oz+k43JgRh9gn6/tbsM0=; fh=Iy9BA2Nzy1VBSzOqqv2Gce1sKk7p0T7HBn0+c2++aA8=; b=AHC/c8ZiO9XHilJzNZhlZELswRev71Lu4aUSg1EqD88NnoGUmXKR+5GoPi++gR3P9p D/J0z6beQKJ13WKtnhcKG3JXk0HU7wuiKuitpTWiHvjWCYUKptDWw3G6/qeUzO70eZRK JRWRGA2iB2T1L8BmBokAVU7YfSrlSrbEJjKc5Lma1kBId0skbuyXjeTjVrnepFw7f/kF uBBpaI3repqDajVsIR92/siXOGPYUXzzC/wFfBWZEanERNsS4Ho6wiAHVyH9SHiC/ido kwlGg0XIGQ5YJEXoWSN0sVh0B8daGbe0JGAq93WKJhCocMCSBJm/BBPlVljFUpkaMick qanA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i2rbxOIt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b6-20020a056a00114600b00690cd91cee7si17974715pfm.287.2023.10.13.13.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:02:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i2rbxOIt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D4FE5804747A; Fri, 13 Oct 2023 13:02:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231846AbjJMUCz (ORCPT + 99 others); Fri, 13 Oct 2023 16:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231636AbjJMUCy (ORCPT ); Fri, 13 Oct 2023 16:02:54 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 928F1B7; Fri, 13 Oct 2023 13:02:51 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE1F5C433C7; Fri, 13 Oct 2023 20:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697227371; bh=YPysSJ75Z66PNMuLGBGQnsEDjA0/a98d1E2F+Hgg2jI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=i2rbxOItdbYJ2r5QKG1SbRRH0Zs90cDrBVIEpDUhE9zdiFpsn/waLZiov7mEpgQcL Bz+GjG8334uvOwlyUo83kwih7ef58WvPPY2CoIVBNmxSwGOSfwk0S7Ho8+2bgEcU7z nYD78sqFH6cUQLZ9aUcAzFpKTc0okAdmovI1jZsmJiESJzI1UU6BmYssNV+sUXPaG7 OThHxlex/Jcj/PiEf/Z56KIlyoBasUm9iWl6r/VPdWLj+/clGwl7JGtOhbSx42ITEj OvcKjkDjsM7gmVeK+YIdZ7bYzqpf5oA1/Z6bb0/TPe5iS78eKHsPPMeF1hR3CMbGk7 VHP9lcff9Dxwg== Date: Fri, 13 Oct 2023 15:02:49 -0500 From: Bjorn Helgaas To: Ilpo =?utf-8?B?SsOkcnZpbmVu?= Cc: linux-pci@vger.kernel.org, Jonathan Cameron , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Lorenzo Pieralisi , LKML , Bjorn Helgaas Subject: Re: [PATCH 06/10] PCI/DPC: Use FIELD_GET() Message-ID: <20231013200249.GA1123559@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:02:57 -0700 (PDT) On Wed, Oct 11, 2023 at 02:01:13PM +0300, Ilpo Järvinen wrote: > 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). Pure FIELD_GET() and FIELD_PREP() was my goal. If you have patches you prefer, I'll drop mine. I did these about a year ago and it seemed like the time to do something with them since you did the PCI_EXP_LNKSTA_NLW ones and to try to prevent overlapping work. Since we've started, I'd like to get as much of it done this cycle as possible. Bjorn