From patchwork Thu Feb 27 22:38:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 869304 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 65AEC27293B; Thu, 27 Feb 2025 22:39:34 +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=1740695976; cv=none; b=Tbv/tAsy4TNn/dY2oLcGigGO+b0PslZZ1w1z7nm+UJCye6bMku/q0Sk1K3YDY/p+fip6TmwbKcdp4TC27Hphb1Pi2TyQbVlTA1FaexcWqXxFaIUb80eUlhIKfCpa2hJXbM1LGNYHWq02pC7tblwHpevBQrH3fbqkZiQMo1WCrqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740695976; c=relaxed/simple; bh=buFbgvkVftTo5J2hG8ztPo+QajmUOxnCFZYOhekJHpk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WzxxrcB/pGTyUGXYRfCfIHBFCGR4EnhbvF1mxCJnScCHfgdIdSHA20GYhaOST1FFrA1xcIJ2RSCrSRcpcVxh8zajU59pmAMFO5cVgW7vPblVHTW5X7hZ2d3QzGT/1pFxHEKge4Fn3gjkHa387BIu5ZJtZ91iUjN2le0p1ewC0l4= 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.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Z3mQ72qBLz6L5Bl; Fri, 28 Feb 2025 06:35:43 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 4825A140CB1; Fri, 28 Feb 2025 06:39:32 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.48.149.240) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 27 Feb 2025 23:39:30 +0100 From: To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH 5/8] cxl/region: Add helper function to determine memory is online Date: Thu, 27 Feb 2025 22:38:12 +0000 Message-ID: <20250227223816.2036-6-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20250227223816.2036-1-shiju.jose@huawei.com> References: <20250227223816.2036-1-shiju.jose@huawei.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: lhrpeml500011.china.huawei.com (7.191.174.215) To frapeml500007.china.huawei.com (7.182.85.172) From: Shiju Jose Add helper function to determine a CXL memory is online. Use case: certain memory operations are permitted when the memory is offline only, for eg. some memory repair operations. Co-developed-by: Jonathan Cameron Signed-off-by: Jonathan Cameron Signed-off-by: Shiju Jose --- drivers/cxl/core/core.h | 9 +++++++++ drivers/cxl/core/region.c | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 6c83f6f18122..386e36b18c19 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -32,8 +32,17 @@ int cxl_get_poison_by_endpoint(struct cxl_port *port); struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa); u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 dpa); +bool cxl_are_decoders_committed(const struct cxl_memdev *cxlmd); #else +static inline bool cxl_are_decoders_committed(const struct cxl_memdev *cxlmd) +{ + /* + * If no driver, in absence of a way to check, assume decoders are committed. + */ + return true; +} + static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 dpa) { diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 9e7b716296d7..3fd14cb0c470 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2864,6 +2864,16 @@ struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa) return ctx.cxlr; } +bool cxl_are_decoders_committed(const struct cxl_memdev *cxlmd) +{ + struct cxl_port *port = cxlmd->endpoint; + + if (port && is_cxl_endpoint(port) && cxl_num_decoders_committed(port)) + return true; + + return false; +} + static bool cxl_is_hpa_in_chunk(u64 hpa, struct cxl_region *cxlr, int pos) { struct cxl_region_params *p = &cxlr->params;