Re: [PATCH v12 01/20] cxl/port: Fix release of RCD endpoints

From: Robert Richter
Date: Sun Oct 29 2023 - 12:46:40 EST


On 27.10.23 18:39:28, Dan Williams wrote:
> Dan Williams wrote:
> > Robert Richter wrote:
> > > Dan,
> > [..]
> > >
> > > delete_endpoint() is called here, but the uport etc. is not unbound.
> > > Which means this is not true:
> > >
> > > if (parent->driver && !endpoint->dead) {
> > > ...
> > >
> > > I don't remember this with my patch. The parent is there different, so
> > > that could be the reason.
> > >
> > > I could not yet look into more detail but wanted to let you know. Will
> > > continue.
> >
> > Apologies, I didn't have that regression going, I think I see the issue.
> > Thanks for the heads up.
>
> Here is the incremental fix on top of the lifetime fix:
>
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 6230ddfc0be8..0fe915ec2cc2 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1217,30 +1217,39 @@ static struct device *grandparent(struct device *dev)
> return NULL;
> }
>
> +static struct device *endpoint_host(struct cxl_port *endpoint)
> +{
> + struct cxl_port *port = to_cxl_port(endpoint->dev.parent);
> +
> + if (is_cxl_root(port))
> + return port->uport_dev;
> + return &port->dev;
> +}

Yes, that works.

Reviewed-by: Robert Richter <rrichter@xxxxxxx>
Tested-by: Robert Richter <rrichter@xxxxxxx>

Thanks,

-Robert