On Mon, Jul 14, 2025 at 03:27:23PM -0700, Vishal Verma wrote:
> On Fri, 2025-07-11 at 15:33 -0700, Dave Jiang wrote:
> > 'cxl enable-port -m' uses cxl_port_get_dport_by_memdev() to find the
> > memdevs that are associated with a port in order to enable those
> > associated memdevs. When the kernel switch to delayed dport
> > initialization by enumerating the dports during memdev probe, the
> > dports are no longer valid until the memdev is probed. This means
> > that cxl_port_get_dport_by_memdev() will not find any memdevs under
> > the port.
> > 
> > Add a new helper function cxl_port_is_memdev_hierarchy() that checks if a
> 
> Stale commit message - since the actual helper is called
> cxl_memdev_is_port_ancestor() ?

Sure, I can fix that up the commit log when applying.

Vishal - Can you comment on how to handle the existing library call that
now behaves differently? Here we have a comment to add to the docs. I'm
not clear that is crisp enough. Prior to this patch it would only return
NULL if dport not found. Now it returns NULL if dport not found, or memdev
not bound.

For cxl-cli - we never used the dport, so the new call suffices. If 'other'
library users, were using it similarly, then the suggestion is to switch
to the new call. But that usage is not a given - maybe they wanted the
actual dport.

So - asking for your library rules expertise on the options here.

> 
> > port is in the memdev hierarchy via the memdev->host_path where the sysfs
> > path contains all the devices in the hierarchy. This call is also backward
> > compatible with the old behavior.

I guess it's backward compatible, if user was only checking for
existense:

        if (cxl_port_get_dport_by_memdev())
                then do this

but not if they were doing this: dport = cxl_port_get_dport_by_memdev();

BTW - I'm also OK with fixing this up for cxl-cli by adding and using
the new helper, and then coming around with another patch dealing 
with the existing library call for our 'other' library users.

-- Alison


> > 
> > Signed-off-by: Dave Jiang <dave.ji...@intel.com>
> > ---
> > v2:
> > - Remove usages of cxl_port_get_dport_by_memdev() and add documentation to 
> > explain
> >   when cxl_port_get_dport_by_memdev() should be used. (Alison)
> > ---
> >  Documentation/cxl/lib/libcxl.txt |  5 +++++
> >  cxl/filter.c                     |  2 +-
> >  cxl/lib/libcxl.c                 | 31 +++++++++++++++++++++++++++++++
> >  cxl/lib/libcxl.sym               |  5 +++++
> >  cxl/libcxl.h                     |  3 +++
> >  cxl/port.c                       |  4 ++--
> >  6 files changed, 47 insertions(+), 3 deletions(-)

Reply via email to