mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Srirangan Madhavan <smadhavan@nvidia.com>
Cc: Dave Jiang <dave.jiang@intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Ira Weiny <ira.weiny@intel.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Vishal Verma <vishal.l.verma@intel.com>,
	<linux-cxl@vger.kernel.org>, <linux-pci@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Alex Williamson <alex.williamson@redhat.com>, <vsethi@nvidia.com>,
	<alwilliamson@nvidia.com>,
	Sai Yashwanth Reddy Kancherla <skancherla@nvidia.com>,
	Vishal Aslot <vaslot@nvidia.com>,
	Manish Honap <mhonap@nvidia.com>, Jiandi An <jan@nvidia.com>,
	Richard Cheng <icheng@nvidia.com>, <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v14 10/16] cxl: Cache endpoint HDM state during PCI enumeration
Date: Wed, 7 Oct 2026 12:37:43 -0700	[thread overview]
Message-ID: <asafh2lu2PJ465gF@aschofie-mobl2.lan> (raw)
In-Reply-To: <bcc1d04c-fd5f-4c65-bafd-c17b8bfe5011@intel.com>

On Tue, Oct 06, 2026 at 08:39:37AM -0700, Dave Jiang wrote:
> 
> 
> On 10/1/26 2:22 AM, Srirangan Madhavan wrote:
> > PCI capability initialization runs before BAR resources are finalized,
> > while driver binding is too late for driver-independent reset support.
> > Create pci_dev->hdm during pci_bus_add_device(), after PCI resource setup
> > and before driver binding.
> > 
> > Cache BAR-relative HDM location, global control, decoder settings, and CXL
> > Device DVSEC Control, then publish the completed cache under cxl_rwsem.dpa.
> > Restore PCI_COMMAND after temporary MMIO access and reject decoder-count
> > changes.
> > 
> > Signed-off-by: Srirangan Madhavan <smadhavan@nvidia.com>
> > ---
> >  drivers/cxl/core/Makefile   |   3 +-
> >  drivers/cxl/core/pci.c      |  15 +-
> >  drivers/cxl/core/regs.c     |   9 ++
> >  drivers/cxl/core/resource.c | 277 ++++++++++++++++++++++++++++++++++++
> >  drivers/pci/bus.c           |   2 +
> >  drivers/pci/probe.c         |   2 +
> >  include/cxl/cxl.h           |  21 +++
> >  tools/testing/cxl/Kbuild    |   1 -
> >  8 files changed, 326 insertions(+), 4 deletions(-)
> > 

snip

> > diff --git a/tools/testing/cxl/Kbuild b/tools/testing/cxl/Kbuild
> > index 2be1df80fcc9..e80500f457a9 100644
> > --- a/tools/testing/cxl/Kbuild
> > +++ b/tools/testing/cxl/Kbuild
> > @@ -55,7 +55,6 @@ obj-m += cxl_core.o
> >  
> >  cxl_core-y := $(CXL_CORE_SRC)/port.o
> >  cxl_core-y += $(CXL_CORE_SRC)/pmem.o
> > -cxl_core-y += $(CXL_CORE_SRC)/regs.o
> >  cxl_core-y += $(CXL_CORE_SRC)/memdev.o
> >  cxl_core-y += $(CXL_CORE_SRC)/mbox.o
> >  cxl_core-y += $(CXL_CORE_SRC)/pci.o
> 
> 
> In general I'm noticing a few functions that takes a 'struct pci_dev' that does not need that in resource.c. In the future, I would like to extend cxl_test to this core code in order to cover most of the functions in resource.c and the reset mechanism. Do you mind taking a look at if things can be reorganized? I did a quick refactor of your series using LLM [1]. See if the shaping of that is acceptable for you. Essentially I had it organize into 3 parts. drivers/cxl/core/hdm_regs.c, drivers/cxl/core/hdm_state.c, and drivers/pci/cxl.c. Feel free to use any or none of the changes.


Srirangan,

Agree with Dave on this point. We should avoid carrying struct  pci_dev down
into helpers that don't otherwise need to know about PCI.

There are a few more examples later in the series where this starts to spread
through the HDM/range handling. I'll call those out on patch 12/16.

-- Alison


> 
> ┌─────┬──────────────────┬───────────────────────────────────────────────┐
> │  #  │      Patch       │                    Change                     │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │ 1-4 │ unchanged        │ Same commit objects, all Reviewed-by tags     │
> │     │                  │ kept                                          │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Introduce        │ target_or_skip_reg_val replaced by an         │
> │ 5   │ reusable HDM     │ endpoint-only settings struct with skip;      │
> │     │ decoder settings │ switch commit takes the target list directly; │
> │     │                  │  endpoints write the DPA Skip registers again │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Move HDM decoder │ New built-in hdm_regs.c, built with           │
> │ 6   │  helpers to      │ obj-$(subst m,y,$(CONFIG_CXL_BUS)), so        │
> │     │ built-in code    │ linking cxl_core no longer depends on         │
> │     │                  │ CONFIG_CXL_RESET                              │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Share HDM        │ Unpacks the common config only; Target List   │
> │ 7   │ decoder register │ and DPA Skip are read where they're used      │
> │     │  unpacking       │ again                                         │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Reject           │                                               │
> │ 8   │ overflowing HDM  │ Rebased only                                  │
> │     │ decoder ranges   │                                               │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Refresh cached   │ Endpoint decoders only; CONFIG_CXL_RESET      │
> │ 9   │ PCI HDM decoder  │ introduced here; two bug fixes (below)        │
> │     │ settings         │                                               │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Cache endpoint   │ PCI-side code moved to the new                │
> │ 10  │ HDM state during │ drivers/pci/cxl.c; cache and cxl_rwsem in the │
> │     │  enumeration     │  new built-in hdm_state.c                     │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │ 11  │ Add CXL Device   │ Moved to drivers/pci/cxl.c, otherwise         │
> │     │ Reset sequencing │ identical                                     │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Validate and     │                                               │
> │ 12  │ synchronize HDM  │ Region-quiesce API in hdm_state.c, so the PCI │
> │     │ ranges around    │  core never takes cxl_rwsem directly          │
> │     │ reset            │                                               │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │ 13, │ Reject unsafe    │                                               │
> │  15 │ scope / Expose   │ Rebased only                                  │
> │     │ CXL Reset        │                                               │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Restore CXL      │ Decoder restore split into hdm_regs.c, which  │
> │ 14  │ state after PCI  │ needs no pci_dev                              │
> │     │ reset            │                                               │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> │     │ Restore CXL      │                                               │
> │ 16  │ state after CXL  │ Race fix. Found through testing.              │
> │     │ bus reset        │                                               │
> ├─────┼──────────────────┼───────────────────────────────────────────────┤
> 
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/djiang/linux.git/log/?h=cxl-type2-reset

  reply	other threads:[~2026-10-07 19:37 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01  9:22 [PATCH v14 00/16] PCI/CXL: Add CXL reset support for Type 2 devices Srirangan Madhavan
2026-10-01  9:22 ` [PATCH v14 01/16] cxl: Drop stale decoder interleave limit comment Srirangan Madhavan
2026-10-02  9:33   ` Richard Cheng
2026-10-07 12:07   ` Li Ming
2026-10-01  9:22 ` [PATCH v14 02/16] cxl: Share CXL port upstream PCI device lookup Srirangan Madhavan
2026-10-02  9:48   ` Richard Cheng
2026-10-07 12:22   ` Li Ming
2026-10-01  9:22 ` [PATCH v14 03/16] cxl: Move decoder declarations to shared header Srirangan Madhavan
2026-10-02  9:49   ` Richard Cheng
2026-10-07 12:29   ` Li Ming
2026-10-01  9:22 ` [PATCH v14 04/16] cxl: Embed decoder configuration in a standalone structure Srirangan Madhavan
2026-10-02 10:17   ` Richard Cheng
2026-10-02 19:07   ` Dave Jiang
2026-10-07 12:34   ` Li Ming
2026-10-01  9:22 ` [PATCH v14 05/16] cxl: Introduce reusable HDM decoder settings Srirangan Madhavan
2026-10-02 19:59   ` Dave Jiang
2026-10-07 13:12     ` Li Ming
2026-10-07 16:23       ` Dave Jiang
2026-10-01  9:22 ` [PATCH v14 06/16] cxl: Move HDM decoder helpers to built-in resource code Srirangan Madhavan
2026-10-05 21:42   ` Dave Jiang
2026-10-01  9:22 ` [PATCH v14 07/16] cxl: Share HDM decoder register unpacking Srirangan Madhavan
2026-10-02 21:46   ` Dave Jiang
2026-10-01  9:22 ` [PATCH v14 08/16] cxl: Reject overflowing HDM decoder ranges Srirangan Madhavan
2026-10-02 21:50   ` Dave Jiang
2026-10-01  9:22 ` [PATCH v14 09/16] cxl: Refresh cached PCI HDM decoder settings Srirangan Madhavan
2026-10-02 23:57   ` Dave Jiang
2026-10-01  9:22 ` [PATCH v14 10/16] cxl: Cache endpoint HDM state during PCI enumeration Srirangan Madhavan
2026-10-06 15:39   ` Dave Jiang
2026-10-07 19:37     ` Alison Schofield [this message]
2026-10-01  9:22 ` [PATCH v14 11/16] cxl: Add CXL Device Reset sequencing Srirangan Madhavan
2026-10-01  9:22 ` [PATCH v14 12/16] cxl: Validate and synchronize HDM ranges around reset Srirangan Madhavan
2026-10-02  8:06   ` Richard Cheng
2026-10-07 19:44   ` Alison Schofield
2026-10-01  9:22 ` [PATCH v14 13/16] PCI/CXL: Reject reset with unsafe function scope Srirangan Madhavan
2026-10-01  9:22 ` [PATCH v14 14/16] cxl: Restore CXL state after PCI reset Srirangan Madhavan
2026-10-07 19:49   ` Alison Schofield
2026-10-01  9:22 ` [PATCH v14 15/16] PCI/CXL: Expose CXL Reset as a PCI reset method Srirangan Madhavan
2026-10-01  9:22 ` [PATCH v14 16/16] PCI/CXL: Restore CXL state after CXL bus reset Srirangan Madhavan

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=asafh2lu2PJ465gF@aschofie-mobl2.lan \
    --to=alison.schofield@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=alwilliamson@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=icheng@nvidia.com \
    --cc=ira.weiny@intel.com \
    --cc=jan@nvidia.com \
    --cc=jic23@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mhonap@nvidia.com \
    --cc=skancherla@nvidia.com \
    --cc=smadhavan@nvidia.com \
    --cc=vaslot@nvidia.com \
    --cc=vishal.l.verma@intel.com \
    --cc=vsethi@nvidia.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

all inboxes | Powered by JetHome®