Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp282432rdf; Tue, 21 Nov 2023 02:36:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEm8j/6ck8v1JePVKiTeOX5oO8Li2xE9/3Z/oB5JqikGrEa5f03LIuRe3tVtHxsJNAoo/m8 X-Received: by 2002:a17:90b:1b10:b0:280:959d:1d10 with SMTP id nu16-20020a17090b1b1000b00280959d1d10mr7795325pjb.3.1700562987649; Tue, 21 Nov 2023 02:36:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700562987; cv=none; d=google.com; s=arc-20160816; b=xOC/ytCaHHJ0A7t8+qYdJbqcSBeinOxlzteRlNbEF1so5ZK1Z+Osp2kK3GMndVzDZr DE5mEQkZFYBEHO7VsUS5fxlmYEkXZw3L1fZz5KLPafxS7jY8oTI0bQyoVrteDGiiJ6BD toPpxG+vuMFzVjO20ASRO+m3Rv8zesK4i9PwrjXrSUQYEPtDSRbcuSuGD+iYsPp8WJjz 9B4HAbXs7whhKRhN2QhWTRqGH07oPmBwSTK8n2R2SjPBOcATWCJbhGrcJjSsgy5StT5n 0uagSa8GcUxZQ6S6CkrY9ydeS4ck/qzCR1/qI2Qt3goV0FqzS9WGteTGpUw3qHJKoYCw rK3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=7fXaJSQMl560/CujFDTiC43FQHsULeYQafoon8VIZRg=; fh=GRbJXuxrGmeIDuZprfbUdB1UwoDI71mY+8eQPRZuXcA=; b=oK1aUD8nr45c0hLRLbL2UXCN0v7EAlLZeGlBgIo3yWozd/uK0uvD9vKMAdLyvAVL/1 aRrucEHh1ErlczmTDeuZIWT70PuWGeiIVKTJHskO9miZu/eG1vExSowprkG2ppKaN908 CwXjthfPkfZbWTHsdOJpwBvVhbbN1S+XOSrg2KX8xJd/AVPH91kBg0TRjH6+psyvqfwx Tfcvf733rq1hmfTmN+J0F4306F96qup43UzR+p7TXg08eYZWek2bUIYmFboDXjMXDkrV CLBPkehAqiR8YfA3KDfkWV1GJ1pGofFZ4T324kLr0JUcul8WmJ63d+8QpNesS+kMfEt4 GOsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XcECAx3z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b23-20020a17090acc1700b0027e022bd420si12341998pju.77.2023.11.21.02.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:36:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XcECAx3z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C2ACE80B1A1D; Tue, 21 Nov 2023 02:36:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbjKUKgR (ORCPT + 99 others); Tue, 21 Nov 2023 05:36:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjKUKgP (ORCPT ); Tue, 21 Nov 2023 05:36:15 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CCBBB9 for ; Tue, 21 Nov 2023 02:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700562971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7fXaJSQMl560/CujFDTiC43FQHsULeYQafoon8VIZRg=; b=XcECAx3zcWDWQaB/bSd+hrmZaIJOlsLM6DqfRl3hzQANLoFVOL77SGXb2U4fL8F77j/gKn BMgosbRIPpNlT0f8xf+ol8VbjzRgP+mnubw3bzeEayNMo1hIVcVyRcCxCm+enU/B7XM5Pg tKzC2gJGy3A3VxT6TUW2xJlVuQl5fJo= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-540-JibIog2JMTiGRSnGAb6L6w-1; Tue, 21 Nov 2023 05:36:09 -0500 X-MC-Unique: JibIog2JMTiGRSnGAb6L6w-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-677fb270eacso9829346d6.1 for ; Tue, 21 Nov 2023 02:36:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700562969; x=1701167769; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7fXaJSQMl560/CujFDTiC43FQHsULeYQafoon8VIZRg=; b=CEJnwrQv4leARd/t36wIGZVoJELZBuSft3JRJjVWZIznEI1ZR4GJnx4DruyfbQi/Mc 5JFfE2cRz9HhgN/5+YziZiprhNjD2QRNnmLRUVZbqo4tFZ12RW3MK4agjjvH1WUgIM0k vmJQvMZa5Q/HDDC75V+C6XGThLmVJxeAU34AV3u+XU0xmkaLuisd7V+A5l8Dm/OYHNnL KUWZEtzK80P9YOsu4xH8QHNgoacQS0OXLbr+PMAhS4+97x8ia3z5CkMMevAcwMg3jY/8 qq4IQcvfiQQjfaqN/vz9gVa/1x+PSAjfWYqzId+1rly6Xm7t2DP6Sp1bCodgU5aWKj8U ITwg== X-Gm-Message-State: AOJu0YyoF1UZI7ZRFxnGgOF8HDHzM6aDyr9jab/QjR85AHEiz7Y/IP6v dsnGxqfCvSaDCEFUpcmXhc5gSYTEpy2BanJlY7U3b4yOuCyy1W9zUhMp93FEgBZrIvtTm9/UDaP D3p1Sn2IMQ2EXXg5PFXSmTuXZt4OI8bc0nEo= X-Received: by 2002:a05:6214:57ce:b0:677:f602:2c8 with SMTP id lw14-20020a05621457ce00b00677f60202c8mr9752801qvb.0.1700562968888; Tue, 21 Nov 2023 02:36:08 -0800 (PST) X-Received: by 2002:a05:6214:57ce:b0:677:f602:2c8 with SMTP id lw14-20020a05621457ce00b00677f60202c8mr9752787qvb.0.1700562968587; Tue, 21 Nov 2023 02:36:08 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.remote.csb (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id k27-20020a05620a0b9b00b0077d5cf2108esm201580qkh.73.2023.11.21.02.36.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:36:08 -0800 (PST) Message-ID: Subject: Re: [PATCH 3/4] pci: move devres code from pci.c to devres.c From: Philipp Stanner To: Arnd Bergmann , Bjorn Helgaas , Andrew Morton , Randy Dunlap , Jason Gunthorpe , Eric Auger , Kent Overstreet , Niklas Schnelle , Neil Brown , John Sanpe , Dave Jiang , Yury Norov , Kees Cook , Masami Hiramatsu , David Gow , Herbert Xu , Thomas Gleixner , "wuqiang.matt" , Jason Baron , Ben Dooks , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 21 Nov 2023 11:36:04 +0100 In-Reply-To: <3bc69019-7867-4f51-806d-02bf85a3cbf9@app.fastmail.com> References: <20231120215945.52027-2-pstanner@redhat.com> <20231120215945.52027-5-pstanner@redhat.com> <3bc69019-7867-4f51-806d-02bf85a3cbf9@app.fastmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=0.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 02:36:25 -0800 (PST) On Tue, 2023-11-21 at 11:17 +0100, Arnd Bergmann wrote: > On Mon, Nov 20, 2023, at 22:59, Philipp Stanner wrote: > > The file pci.c is very large and contains a number of devres- > > functions. > > These functions should now reside in devres.c > >=20 > > There are a few callers left in pci.c that do devres operations. > > These > > should be ported in the future. Corresponding TODOs are added by > > this > > commit. > >=20 > > The reason they are not moved right now in this commit is that > > pci's > > devres currently implements a sort of "hybrid-mode": > > pci_request_region(), for instance, does not have a corresponding > > pcim_ > > equivalent, yet. Instead, the function can be made managed by > > previously > > calling pcim_enable_device() (instead of pci_enable_device()). This > > makes it unreasonable to move pci_request_region() to devres.c > > Moving the functions would require changes to pci's API and is, > > therefore, left for future work. > >=20 > > Move as much devres-specific code from pci.c to devres.c as > > possible. > >=20 > > Suggested-by: Danilo Krummrich > > Signed-off-by: Philipp Stanner > > --- > > =C2=A0drivers/pci/devres.c | 243 > > +++++++++++++++++++++++++++++++++++++++++ > > =C2=A0drivers/pci/pci.c=C2=A0=C2=A0=C2=A0 | 249 -----------------------= ---------------- > > ---- > > =C2=A0drivers/pci/pci.h=C2=A0=C2=A0=C2=A0 |=C2=A0 24 +++++ > > =C2=A03 files changed, 267 insertions(+), 249 deletions(-) >=20 > I had just commented in the other mail that you'd have to move > these functions to devres.c for the file to make sense, but that > I think the existing state is better. >=20 > Just to clarify again here: this patch does not seem to improve > anything to me, Have you read the cover letter? It elaborates on that. The idea behind centralizing devres-pci-code in a separate file is that the current implementation is strangely torn. My mid-term goal would be to fix that, but that's beyond the scope of this series. PCI has some separate devres functions, prefixed with pcim_ =E2=80=93 and t= hen there are some other functions that use a crazy hybrid mode: drivers/pci/pci.c: void pci_release_region(struct pci_dev *pdev, int bar) { /* ..... SNIP ......... */ dr =3D find_pci_dr(pdev); if (dr) dr->region_mask &=3D ~(1 << bar); } Some functions without pcim_ prefix switch to managed mode if pcim_enable_device() instead of pci_enable_device() was called. So some functions are sometimes managed and others never are, which is totally inconsistent. This is bug-provoking because programmers won't know without looking very closely which functions become managed and which don't. That should be fixed. And a first step towards that goal is to cleanly split them. Everything managed should reside, on the long term, in drivers/pci/devres.c > I'd much prefer leaving it the way it is, and > moving the pcim_iomap family to corresponding drivers/pci/iomap.c.=20 We could branch that change out of the patch series and handle the topics independently P. >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 Arnd >=20