From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B171D189B8D; Thu, 2 Jan 2025 15:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735832561; cv=none; b=FWX9v5hhwiKvE695NtYPUe9lSI2cMhPbmCCWJLZIWoWdcqIPxeE64DHLg1jUi5ocG6cdS8spwN+P/GcmjsDGm8ebTtpApLAKctDx6NZhdeUwC1o3YZVnltkWFstqoIyZj4X6sjfhicmIcULbIywCnKpfhI33TGBgabgPI7cdKZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735832561; c=relaxed/simple; bh=nEZ3dqLnKDtRAh/9N7EcCdJaU8kaWy34Nl+Kw/1gmZ0=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IH75XCWB9+JL2bxL8ILlY059mir2AJCilSrNI6Nc5nvSePqzvEoSB3waRyZjsOXdljiHAuKSc0zFZj5+05NFFnJ3oaKJewctvBeCpm3Mk+AkNC977eXDhuI6/5DOkBTTC7E6A4had2Amvq5AQMxs+bnPUMvahi1ohkvZEIHDMIo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4YP9Ql5g1Jz6M4yn; Thu, 2 Jan 2025 23:21:19 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id AFC4B1401F3; Thu, 2 Jan 2025 23:22:45 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 2 Jan 2025 16:22:45 +0100 Date: Thu, 2 Jan 2025 15:22:43 +0000 From: Jonathan Cameron To: CC: , , , , , , , , , Alejandro Lucero Subject: Re: [PATCH v9 22/27] cxl: allow region creation by type2 drivers Message-ID: <20250102152243.00006b59@huawei.com> In-Reply-To: <20241230214445.27602-23-alejandro.lucero-palau@amd.com> References: <20241230214445.27602-1-alejandro.lucero-palau@amd.com> <20241230214445.27602-23-alejandro.lucero-palau@amd.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100010.china.huawei.com (7.191.174.197) To frapeml500008.china.huawei.com (7.182.85.71) On Mon, 30 Dec 2024 21:44:40 +0000 alejandro.lucero-palau@amd.com wrote: > From: Alejandro Lucero > > Creating a CXL region requires userspace intervention through the cxl > sysfs files. Type2 support should allow accelerator drivers to create > such cxl region from kernel code. > > Adding that functionality and integrating it with current support for > memory expanders. > > Based on https://lore.kernel.org/linux-cxl/168592159835.1948938.1647215579839222774.stgit@dwillia2-xfh.jf.intel.com/ > > Signed-off-by: Alejandro Lucero > Co-developed-by: Dan Williams > Reviewed-by: Zhi Wang Trivial comment inline. Either way Reviewed-by: Jonathan Cameron > --- > drivers/cxl/core/region.c | 145 ++++++++++++++++++++++++++++++++++---- > drivers/cxl/cxlmem.h | 2 + > drivers/cxl/port.c | 5 +- > include/cxl/cxl.h | 4 ++ > 4 files changed, 141 insertions(+), 15 deletions(-) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index 1b1d45c44b52..a2b92162edbd 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -2270,6 +2270,18 @@ static int cxl_region_detach(struct cxl_endpoint_decoder *cxled) > return rc; > } > > +int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled) > +{ > + int rc; > + > + down_write(&cxl_region_rwsem); Could use a guard here so you can return directly. > + cxled->mode = CXL_DECODER_DEAD; > + rc = cxl_region_detach(cxled); > + up_write(&cxl_region_rwsem); > + return rc; > +} > +EXPORT_SYMBOL_NS_GPL(cxl_accel_region_detach, "CXL");