Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Philipp Stanner <pstanner@redhat.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	 Eric Auger <eric.auger@redhat.com>,
	Kent Overstreet <kent.overstreet@gmail.com>,
	Niklas Schnelle <schnelle@linux.ibm.com>,
	Neil Brown <neilb@suse.de>, John Sanpe <sanpeqf@gmail.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Yury Norov <yury.norov@gmail.com>,
	Kees Cook <keescook@chromium.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	David Gow <davidgow@google.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Thomas Gleixner <tglx@linutronix.de>,
	 "wuqiang.matt" <wuqiang.matt@bytedance.com>,
	Jason Baron <jbaron@akamai.com>,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	Danilo Krummrich <dakr@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH 3/4] pci: move devres code from pci.c to devres.c
Date: Tue, 21 Nov 2023 11:36:04 +0100	[thread overview]
Message-ID: <fbf91189babaf640b573dfe3a1c68932718bda4e.camel@redhat.com> (raw)
In-Reply-To: <3bc69019-7867-4f51-806d-02bf85a3cbf9@app.fastmail.com>

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
> > 
> > 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.
> > 
> > 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.
> > 
> > Move as much devres-specific code from pci.c to devres.c as
> > possible.
> > 
> > Suggested-by: Danilo Krummrich <dakr@redhat.com>
> > Signed-off-by: Philipp Stanner <pstanner@redhat.com>
> > ---
> >  drivers/pci/devres.c | 243
> > +++++++++++++++++++++++++++++++++++++++++
> >  drivers/pci/pci.c    | 249 ---------------------------------------
> > ----
> >  drivers/pci/pci.h    |  24 +++++
> >  3 files changed, 267 insertions(+), 249 deletions(-)
> 
> 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.
> 
> 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_ – and then
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 = find_pci_dr(pdev);
 if (dr)
 dr->region_mask &= ~(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. 

We could branch that change out of the patch series and handle the
topics independently

P.

> 
>      Arnd
> 


  reply	other threads:[~2023-11-21 10:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 21:59 [PATCH 0/4] Regather scattered PCI-Code Philipp Stanner
2023-11-20 21:59 ` [PATCH 1/4] lib: move pci_iomap.c to drivers/pci/ Philipp Stanner
2023-11-21  4:20   ` kernel test robot
2023-11-21 10:44     ` Philipp Stanner
2023-11-21  6:48   ` kernel test robot
2023-11-21  7:22     ` Arnd Bergmann
2023-11-21  7:20   ` kernel test robot
2023-11-21  7:45   ` kernel test robot
2023-11-21  7:58   ` kernel test robot
2023-11-21  8:46   ` kernel test robot
2023-11-21 10:44   ` kernel test robot
2023-11-21 10:44   ` kernel test robot
2023-11-21 13:14   ` kernel test robot
2023-11-21 14:38   ` kernel test robot
2023-11-21 15:04   ` kernel test robot
2023-11-21 15:40   ` kernel test robot
2023-11-21 15:56   ` kernel test robot
2023-11-22  1:51     ` Liu, Yujie
2023-11-22  8:15       ` Philipp Stanner
2023-11-23  6:42         ` Yujie Liu
2023-11-22 16:28   ` kernel test robot
2023-11-20 21:59 ` [PATCH 2/4] lib: move pci-specific devres code " Philipp Stanner
2023-11-21  7:29   ` Arnd Bergmann
2023-11-21  8:00     ` Philipp Stanner
2023-11-21 10:10       ` Arnd Bergmann
2023-11-20 21:59 ` [PATCH 3/4] pci: move devres code from pci.c to devres.c Philipp Stanner
2023-11-21 10:17   ` Arnd Bergmann
2023-11-21 10:36     ` Philipp Stanner [this message]
2023-11-20 21:59 ` [PATCH 4/4] lib/iomap.c: improve comment about pci anomaly Philipp Stanner
2023-11-21 10:03   ` Arnd Bergmann
2023-11-21 14:38     ` Philipp Stanner
2023-11-21 14:41       ` Arnd Bergmann
2023-11-24 19:08     ` Danilo Krummrich
2023-11-29 10:16       ` Philipp Stanner
2023-11-29 17:37         ` Arnd Bergmann
2023-11-29 12:40     ` Philipp Stanner
2023-11-29 16:52       ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbf91189babaf640b573dfe3a1c68932718bda4e.camel@redhat.com \
    --to=pstanner@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@kernel.org \
    --cc=ben.dooks@codethink.co.uk \
    --cc=bhelgaas@google.com \
    --cc=dakr@redhat.com \
    --cc=dave.jiang@intel.com \
    --cc=davidgow@google.com \
    --cc=eric.auger@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jbaron@akamai.com \
    --cc=jgg@ziepe.ca \
    --cc=keescook@chromium.org \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=neilb@suse.de \
    --cc=rdunlap@infradead.org \
    --cc=sanpeqf@gmail.com \
    --cc=schnelle@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=wuqiang.matt@bytedance.com \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox