From patchwork Mon Jan 6 12:10:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13927258 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC23AE77199 for ; Mon, 6 Jan 2025 12:11:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A892E6B00A9; Mon, 6 Jan 2025 07:11:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A10A36B00AB; Mon, 6 Jan 2025 07:11:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 815226B00AC; Mon, 6 Jan 2025 07:11:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5BFF76B00A9 for ; Mon, 6 Jan 2025 07:11:51 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0E7F0140246 for ; Mon, 6 Jan 2025 12:11:51 +0000 (UTC) X-FDA: 82976913222.15.B27CA23 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf13.hostedemail.com (Postfix) with ESMTP id 0863A2000B for ; Mon, 6 Jan 2025 12:11:48 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736165509; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g815TbpT2Y/OMG2K9SBUSVUaSpLxD+Oo1RO+kQ8nE+I=; b=AK4+/okA+X5hkORFN70XBj5SRKW+2OWR/a5jIXL+XVCP9WX4sjaUwUlXunZWNTtGSuL4Yu jC/6NFoC0h1EUdcRL1E6xeTEVfrGi/0bOCSjVXfbZHdTDDSmZxmI241jUy2Unp6KJBZ5w+ U23rvHsdCHJl1Kt5ULXd+slD9mRDmTE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736165509; a=rsa-sha256; cv=none; b=YSoOYRA3g3w7g23/6O0Q5+XsAFmrAma+NQsJVFN0Bt0tlVlwSYSsgzgbO+PF+9ykVvOuaM 43OLxyvMBhC3jlqx/e5VI34W0SY4fwQsgVkTfa9+RjEe5t/p9NMGnTnYTmubHxtE+11/o6 PS1thXfqMWuUjKkSvkYJ29oN5mX8V1U= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4YRY0R4yZSz6LD8h; Mon, 6 Jan 2025 20:10:15 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 7890B140CF4; Mon, 6 Jan 2025 20:11:47 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.126.170.95) 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; Mon, 6 Jan 2025 13:11:45 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v18 09/19] cxl: Enumerate feature commands Date: Mon, 6 Jan 2025 12:10:05 +0000 Message-ID: <20250106121017.1620-10-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20250106121017.1620-1-shiju.jose@huawei.com> References: <20250106121017.1620-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.126.170.95] X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0863A2000B X-Stat-Signature: wenfm698a6973fpodms6mzeuwg8nci8t X-Rspam-User: X-HE-Tag: 1736165508-70727 X-HE-Meta: U2FsdGVkX183zuEVUB4ZNj40lprMEAlBN3M8ikRQMr8GxIcanYwkhIN94Zs2tJU5W2AG7zZ+m0M9JsU7LtfoXYRsX9cL65TYVXe7dLGCu4DSBxaOjfpD+lJevXVG83tbBQsVzSN3K3LO9ZI03P+7o9Bgvhp9bs6PbBJ1Jq1dTG9cz1iStd/Fgeo2jE5MlZUpQmI5PxCWWo45nwXlSFv7n/uxldw989vdZh3suSplNttLBbTgbDufc7bIotqGBzVVfiMCQFEAYMBJF/nDnvQ+8IwLbzonxO71THEqdzPfEEFfhbMw4iZvqleIw3ebG/KEIrFRF8WBpj/ePixFv/Sw1NTXmxT/C9NtFX+puyDRjmZAKWoiZ+tWyuj5ptOis2dk3SOj5oZCU/IafRqp6NeDt19dXaowh6vSLtL6ulv3YfR1YqgUwaJ7/JhNwIIsjsAH0xkBMMU9gy1FdCyTSizjZP+yoOGFhCPufziw+iYE6VpzDUaX41iAyX0nBI6hGeEYWOOktknrWukqsO2t4RL9NxbCD7a1M1veIj33G6XAtdVl87H1ilDjKUeFl6/NY1IVGeaDvRjLA9GlZYPsaOJbWWo/XRdV2z3utm2entD9StFstwQ/TrDQYnkgSLn3LtIyOiYso/rkkBDyQmObTS25v94OXGO/KZHOenIX7RmZsdPwVvm4BGyiVErgFuk6dzfxVW8HPc9GRnaUkcvqIpippO0GnLWYL+oT/C5XPGxZFmVrigOI+sAmGDvPLGX2+Sq71JW7erkjYxOIYHcE+QOJNSxAdGV7mmPmJeAMjA0wWnCyBu4Y6Zo4WGNAsF0SttHDZmzhnUvf7GaIjV19EYlA2UxyAJXGOSGlkDA6NQ3IXznPZrV0Ctiu3Fl9EIouTwIYcuakPZiwsLihz0PaQwhwHb/Nk0vLMxIicNyDVT6p0B8SafbwCB+gPS2vwzogumltvPpIpoZxE55Dc0IhBq9 USCUV8zV mq6AXeniCOS+dJ1EGaYou4pDuS+WvXmcA52kmHXMsZbfyfsQZch5nVfYsLfd9xj3XCn+7i+2AZdzcq+LoJRAF50XWu/ddEtcUaZpnn1Bei10YeGv3SwU4BPAo4Tsgm5rBB8SiqKSeUidbpgfoSoz6ov9MKP3MgBtnuIqfUyrHbbgOGQiFwDopkNJEwaN/QxfN6DW2hnqCGJH46qwiHM15/D0swe9UJIRIWfl/C7KvNKDXsLpD4rDg7NI/1Mz9uRlDt7UT X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Dave Jiang Add feature commands enumeration code in order to detect and enumerate the 3 feature related commands "get supported features", "get feature", and "set feature". The enumeration will help determine whether the driver can issue any of the 3 commands to the device. Signed-off-by: Dave Jiang --- drivers/cxl/core/mbox.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 3 +++ include/cxl/features.h | 7 +++++++ include/cxl/mailbox.h | 1 + 4 files changed, 52 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index bdb8f060f2c1..5e21ff99d70f 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -38,6 +38,21 @@ static bool cxl_raw_allow_all; .flags = _flags, \ } +#define cxl_for_each_feature_cmd(cmd) \ + for ((cmd) = &cxl_feature_commands[0]; \ + ((cmd) - cxl_feature_commands) < ARRAY_SIZE(cxl_feature_commands); (cmd)++) + +#define CXL_FEATURE_CMD(_id, sin, sout, _flags) \ + [CXL_FEATURE_ID_##_id] = { \ + .info = { \ + .id = CXL_FEATURE_ID_##_id, \ + .size_in = sin, \ + .size_out = sout, \ + }, \ + .opcode = CXL_MBOX_OP_##_id, \ + .flags = _flags, \ + } + #define CXL_VARIABLE_PAYLOAD ~0U /* * This table defines the supported mailbox commands for the driver. This table @@ -69,6 +84,13 @@ static struct cxl_mem_command cxl_mem_commands[CXL_MEM_COMMAND_ID_MAX] = { CXL_CMD(GET_TIMESTAMP, 0, 0x8, 0), }; +#define CXL_FEATURE_COMMAND_ID_MAX 3 +static struct cxl_mem_command cxl_feature_commands[CXL_FEATURE_COMMAND_ID_MAX] = { + CXL_FEATURE_CMD(GET_SUPPORTED_FEATURES, 0x8, CXL_VARIABLE_PAYLOAD, 0), + CXL_FEATURE_CMD(GET_FEATURE, 0xf, CXL_VARIABLE_PAYLOAD, 0), + CXL_FEATURE_CMD(SET_FEATURE, CXL_VARIABLE_PAYLOAD, 0, 0), +}; + /* * Commands that RAW doesn't permit. The rationale for each: * @@ -212,6 +234,17 @@ static struct cxl_mem_command *cxl_mem_find_command(u16 opcode) return NULL; } +static struct cxl_mem_command *cxl_find_feature_command(u16 opcode) +{ + struct cxl_mem_command *c; + + cxl_for_each_feature_cmd(c) + if (c->opcode == opcode) + return c; + + return NULL; +} + static const char *cxl_mem_opcode_to_name(u16 opcode) { struct cxl_mem_command *c; @@ -734,6 +767,14 @@ static void cxl_walk_cel(struct cxl_memdev_state *mds, size_t size, u8 *cel) if (cmd) { set_bit(cmd->info.id, cxl_mbox->enabled_cmds); enabled++; + } else { + struct cxl_mem_command *fcmd = + cxl_find_feature_command(opcode); + + if (fcmd) { + set_bit(fcmd->info.id, cxl_mbox->feature_cmds); + enabled++; + } } if (cxl_is_poison_command(opcode)) { diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index a0a49809cd76..55c55685cb39 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -490,6 +490,9 @@ enum cxl_opcode { CXL_MBOX_OP_GET_LOG_CAPS = 0x0402, CXL_MBOX_OP_CLEAR_LOG = 0x0403, CXL_MBOX_OP_GET_SUP_LOG_SUBLIST = 0x0405, + CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500, + CXL_MBOX_OP_GET_FEATURE = 0x0501, + CXL_MBOX_OP_SET_FEATURE = 0x0502, CXL_MBOX_OP_IDENTIFY = 0x4000, CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100, CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101, diff --git a/include/cxl/features.h b/include/cxl/features.h index b92da1e92780..7a8be3c621a1 100644 --- a/include/cxl/features.h +++ b/include/cxl/features.h @@ -5,6 +5,13 @@ struct cxl_mailbox; +enum feature_cmds { + CXL_FEATURE_ID_GET_SUPPORTED_FEATURES = 0, + CXL_FEATURE_ID_GET_FEATURE, + CXL_FEATURE_ID_SET_FEATURE, + CXL_FEATURE_ID_MAX, +}; + struct cxl_features { int id; struct device dev; diff --git a/include/cxl/mailbox.h b/include/cxl/mailbox.h index 6caab0d406ba..263fc346aeb1 100644 --- a/include/cxl/mailbox.h +++ b/include/cxl/mailbox.h @@ -58,6 +58,7 @@ struct cxl_mailbox { struct device *host; DECLARE_BITMAP(enabled_cmds, CXL_MEM_COMMAND_ID_MAX); DECLARE_BITMAP(exclusive_cmds, CXL_MEM_COMMAND_ID_MAX); + DECLARE_BITMAP(feature_cmds, CXL_FEATURE_ID_MAX); size_t payload_size; struct mutex mbox_mutex; /* lock to protect mailbox context */ struct rcuwait mbox_wait;