diff mbox series

[v11,01/20] cxl/port: Fix release of RCD endpoints

Message ID 20230927154339.1600738-2-rrichter@amd.com
State Superseded
Headers show
Series cxl/pci: Add support for RCH RAS error handling | expand

Commit Message

Robert Richter Sept. 27, 2023, 3:43 p.m. UTC
Binding and unbindind RCD endpoints (e.g. mem0 device) caused the
corresponding endpoint not being released. Reason for that is the
wrong port discovered for RCD endpoints. See cxl_mem_probe() for
proper endpoint parent detection. Fix delete_endpoint() respectively.

Signed-off-by: Robert Richter <rrichter@amd.com>
---
 drivers/cxl/core/port.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Oct. 2, 2023, 2:14 p.m. UTC | #1
On Wed, 27 Sep 2023 17:43:20 +0200
Robert Richter <rrichter@amd.com> wrote:

> Binding and unbindind RCD endpoints (e.g. mem0 device) caused the
> corresponding endpoint not being released. Reason for that is the
> wrong port discovered for RCD endpoints. See cxl_mem_probe() for
> proper endpoint parent detection. Fix delete_endpoint() respectively.
> 
> Signed-off-by: Robert Richter <rrichter@amd.com>

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

I wondered briefly if an access function of some type could be
used to hide this detail away. However it's messy enough that
that is a little tricky so I think we should just keep it
explicit in each location.  So as you have it here.

> ---
>  drivers/cxl/core/port.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 7ca01a834e18..d4572a02989a 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1222,12 +1222,17 @@ static void delete_endpoint(void *data)
>  	struct cxl_memdev *cxlmd = data;
>  	struct cxl_port *endpoint = cxlmd->endpoint;
>  	struct cxl_port *parent_port;
> +	struct cxl_dport *dport;
>  	struct device *parent;
>  
> -	parent_port = cxl_mem_find_port(cxlmd, NULL);
> +	parent_port = cxl_mem_find_port(cxlmd, &dport);
>  	if (!parent_port)
>  		goto out;
> -	parent = &parent_port->dev;
> +
> +	if (dport->rch)
> +		parent = parent_port->uport_dev;
> +	else
> +		parent = &parent_port->dev;
>  
>  	device_lock(parent);
>  	if (parent->driver && !endpoint->dead) {
diff mbox series

Patch

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 7ca01a834e18..d4572a02989a 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -1222,12 +1222,17 @@  static void delete_endpoint(void *data)
 	struct cxl_memdev *cxlmd = data;
 	struct cxl_port *endpoint = cxlmd->endpoint;
 	struct cxl_port *parent_port;
+	struct cxl_dport *dport;
 	struct device *parent;
 
-	parent_port = cxl_mem_find_port(cxlmd, NULL);
+	parent_port = cxl_mem_find_port(cxlmd, &dport);
 	if (!parent_port)
 		goto out;
-	parent = &parent_port->dev;
+
+	if (dport->rch)
+		parent = parent_port->uport_dev;
+	else
+		parent = &parent_port->dev;
 
 	device_lock(parent);
 	if (parent->driver && !endpoint->dead) {