Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1393256rdb; Mon, 2 Oct 2023 08:15:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVa9Lq6WtxcbucZT1lspPi3SenUzS8HE1yifRItkTEd8g+WeNN3OBWcN4N1EUEjBw8J7CN X-Received: by 2002:a17:902:ed54:b0:1c6:a2b:5a5c with SMTP id y20-20020a170902ed5400b001c60a2b5a5cmr10336093plb.34.1696259705326; Mon, 02 Oct 2023 08:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696259705; cv=none; d=google.com; s=arc-20160816; b=EtLg2Deuhzc+6VKpDOKqYw/PVk4j9FpWPbIVuemXeT7Bf8+58FeFYg2fHRCD7RbRPe lbWYRawGy1rjOxHdxYteJyZ9VOvDbXrTyAS1S7J9FPQK/DXaFaITNHNOMDzTJ/iJCPBT gg5sDmETIOZb9TAioXWVALhYfAjGVf1k7WDa4Rxz76uU9CnCNHdmnLFKTaytiU9eZKfR KDJS+rW9EVCiEfQ0gNVj0CEsaZuNkb/oGlxEob3cNPYQelrCFcXMoKHusX8zm2cdrzTQ 6yLSjIdsBpLYmqVzZ1tzJkmcg42Ql91exg2QAZH3Yjklkrgefd0/pWzvXim/FoWL19Oy 79MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=539EflQfQG5KeHZNX+kx5u/AMCDd4AHwBs5kC0DLJRU=; fh=6T4zZ8HeN4FNvjm5k4DIT/y7+At3BG9x6FXMDOBhu9c=; b=ey6FlU999eeMkbH/+/VhOEq2S//0otCIfcfWHOjfpu3abQnE5lkFggMk9vo3aNxO71 V5N7L5TEr37q6RR+hAF3BWhq347v6c8dTn78KkdP8NXXLTA4UbrMRV79+piW5cO89dEP /Ct/TXe84o6NGE778P9BfZlfkXFyVfxNnbPgKaY+kwJU6w9CDjfxHKPfDWRKApayHN84 e8xHFyc9LX/mtTEhhZDhN8gggNpfBEBYUge/bDxItpWMzhSgd2ONEa5JYWnZJAE/dAyR JOBDBy+SIyhk/QT4m91YcncO9OQ9gNmbqqzFVF0QO6WBsCVCVgxAkcFkmHjRXKKCEl5k atZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id f10-20020a170902684a00b001c33d339754si26672674pln.136.2023.10.02.08.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2861680E0B7B; Mon, 2 Oct 2023 07:15:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237673AbjJBOOv (ORCPT + 99 others); Mon, 2 Oct 2023 10:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237479AbjJBOOu (ORCPT ); Mon, 2 Oct 2023 10:14:50 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90AE5AD; Mon, 2 Oct 2023 07:14:46 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RzjbW6tMyz67ZgC; Mon, 2 Oct 2023 22:13:11 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 2 Oct 2023 15:14:44 +0100 Date: Mon, 2 Oct 2023 15:14:43 +0100 From: Jonathan Cameron To: Robert Richter CC: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , "Davidlohr Bueso" , Dave Jiang , , , Bjorn Helgaas , Terry Bowman Subject: Re: [PATCH v11 01/20] cxl/port: Fix release of RCD endpoints Message-ID: <20231002151443.000017d5@Huawei.com> In-Reply-To: <20230927154339.1600738-2-rrichter@amd.com> References: <20230927154339.1600738-1-rrichter@amd.com> <20230927154339.1600738-2-rrichter@amd.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100006.china.huawei.com (7.191.160.224) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 07:15:01 -0700 (PDT) On Wed, 27 Sep 2023 17:43:20 +0200 Robert Richter 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 Reviewed-by: Jonathan Cameron 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) {