From patchwork Wed Oct 16 04:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ravis OpenSrc X-Patchwork-Id: 13837721 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2063.outbound.protection.outlook.com [40.107.95.63]) (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 1F2EC18A95E for ; Wed, 16 Oct 2024 05:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729054806; cv=fail; b=K66MK56VtI68ZEhl6ikOrmmjkkaKYV9jfUw2uJOT14YFexLGHcbtZi583GuWBkztOfgrw0wmSTFYZGIbvQ1hRqmSoXX3wvngg+PxqLUK6vsD81HnZY5GcPRKio66FcjJwqg3T+OkFB3+p2BAHL4dNExRRtq6tM5JJgBSAM7q7bY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729054806; c=relaxed/simple; bh=YWZaz8HUJ7zNFnEPrOgcbdWU2SjlwKpb4inu5VyeJNo=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=gl9tHk9DbvaZAlZ3enOanXYzjE4CI/y810bZKALHNzVFsogTMC2wxVAxRsXP2Wv7rguJ44UCxCB31x6h66xVJdi/cT4GzLoQwnQxMu99AplzXpzZ52kKgjSuokb3haBV4tCE6+HmyJV0BPLscWvwN6yYRJSYb9CcacWGWEiH5iA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=micron.com; spf=pass smtp.mailfrom=micron.com; dkim=pass (2048-bit key) header.d=micron.com header.i=@micron.com header.b=MhL1pxcH; arc=fail smtp.client-ip=40.107.95.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=micron.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=micron.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=micron.com header.i=@micron.com header.b="MhL1pxcH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q2BNLy3Tys/WnV6hGSWHzcQsUqT4RsakSdiY/xqljWp1vmOIE/O5j57V6cQ+nlVaw98vP8ZyiBI2ULa5WvoEJRrzWFQpqFgMd3zxvXb62K6cCbbekFJZ+QbZ+jqH4Mq9DphGt9ruEMyAtWI9hu34ggMZkm3fWBSkCzehIuLsgHPRTp+UsiUVAirH3gy1Ss/3dBWrMla+HpJEMPLKftAzK+SIwU3unTffNpdAZ4cOCq9aJMiEs2PZHZoQO43bwXo8VqsDQZkFPaGgYAepddqb4fG0aUow9aexhY3Ii81dUVk8izBToqV8C3ZVzc7FWmM4T/zCAJppqKnczaHLAvXmQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GnqzN35w1JAXkYGkRioMhmLqElHTtYzdKgcq/Yeosbc=; b=rWnVCp1jBKtTWG84LtfiIPArWjNzt7bZVJlyvTUgEjBdnzQb+YjuSULfZA1RjsoQApU1k/8QVqZoBEzl51hQ202E1wshXpIYdzuiCmZm+UdKhogsDmflWo97J2E5+6PtkbYGvK0dJQlPCrZ7ACVMfHMGXUML0Nmu4g4EHQjEbfwnO9nhovFm+D3K4P6CRzSsIvAdVtFhnL4+C75Wl0b108QAgBwARZnN61S1ORiOIwFjQBHSpvtwFSocuADZkxgyLHXjG74Hnuncr1PfHSWdI6SFWZO55zJUBBSQDMPYNf4lYDHVQzN4P5M+Pma+J4UuAK6xNeevto+rFpOMFalsdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.201.242.130) smtp.rcpttodomain=jagalactic.com smtp.mailfrom=micron.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=micron.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=micron.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GnqzN35w1JAXkYGkRioMhmLqElHTtYzdKgcq/Yeosbc=; b=MhL1pxcH6MMG0cQlGWR7rJJPJazvtzTNo8msmgN/Cgkj0CiIlnBmavLeinBAprzb15BUveExzHc4pGm/Pzyk4PHEMXVsuzCFtc98Ubz+CidF6HxghQImYZoyym7QZ4kl3pQ6FERVXn3nQKSftQZSj6Tqzp0pgXd70FOdBvy/VGQUMS810dy5g2adlt6ZONcZ46ntJ2A+Dk+utb0rajJF7UV/iMHeIf8+zsCa6bwG/0TmWBJvwbMWcErXhFWelqmzLrtDrrDgNvpocrfZP27iyjsb654C782A90UU1+llxr4ovQ8+2Fxff7DAawjdPLYEY+5nBHJDVXrQaxujgY9W1A== Received: from CH0P223CA0012.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:116::29) by SN4PR0801MB7725.namprd08.prod.outlook.com (2603:10b6:806:200::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Wed, 16 Oct 2024 04:59:58 +0000 Received: from CH3PEPF0000000A.namprd04.prod.outlook.com (2603:10b6:610:116:cafe::10) by CH0P223CA0012.outlook.office365.com (2603:10b6:610:116::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Wed, 16 Oct 2024 04:59:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 137.201.242.130) smtp.mailfrom=micron.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=micron.com; Received-SPF: Pass (protection.outlook.com: domain of micron.com designates 137.201.242.130 as permitted sender) receiver=protection.outlook.com; client-ip=137.201.242.130; helo=mail.micron.com; pr=C Received: from mail.micron.com (137.201.242.130) by CH3PEPF0000000A.mail.protection.outlook.com (10.167.244.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Wed, 16 Oct 2024 04:59:58 +0000 Received: from BOW17EX19B.micron.com (137.201.21.219) by BOW17EX19B.micron.com (137.201.21.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 15 Oct 2024 22:59:56 -0600 Received: from BOW17EX19B.micron.com ([fe80::1c0a:12aa:1e25:d8a3]) by BOW17EX19B.micron.com ([fe80::1c0a:12aa:1e25:d8a3%6]) with mapi id 15.02.1544.011; Tue, 15 Oct 2024 22:59:56 -0600 From: Ravis OpenSrc To: "linux-cxl@vger.kernel.org" , "dan.j.williams@intel.com" , "dave.jiang@intel.com" , "jonathan.cameron@huawei.com" CC: Srinivasulu Opensrc , "john@jagalactic.com" , Ajay Joshi Subject: [RFC PATCH v2 1/4] cxl: Enable mailbox ops with background only if request abort operation is supported. Thread-Topic: [RFC PATCH v2 1/4] cxl: Enable mailbox ops with background only if request abort operation is supported. Thread-Index: AQHbH4g+o4Yi/F6bYEWlyf9LmgVvoA== Date: Wed, 16 Oct 2024 04:59:56 +0000 Message-ID: <6e6cc093f70442e792c05e779393442a@micron.com> References: <20241015205633.127333-1-ravis.opensrc@micron.com>,<20241015205633.127333-2-ravis.opensrc@micron.com> In-Reply-To: <20241015205633.127333-2-ravis.opensrc@micron.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mt-whitelisted: matched Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF0000000A:EE_|SN4PR0801MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 03a8f530-4ed0-49c8-61fe-08dced9f624b X-EXT-ByPass: 1 X-MT-RULE-Whitelisted: Triggered X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?q?/r5bfZDXcwLVwpeBCh8vjiyJbG?= =?iso-8859-1?q?CsY6YeMwa2SR1SMvqQFG2OGcF16W9eJ+AMipXNwtKf7j3QBQYlJmd384Kgfh?= =?iso-8859-1?q?76slHlUCndXx963yJSsxnuSXviocM+V7bQYLElhGcosS93OLyx7tF8KUcZ6M?= =?iso-8859-1?q?Cjck/8jpF4/ZjnhVJ4mNNJ2nM9jBDgO3KoAxfHjLdmq5Wycntz00M93FIo5s?= =?iso-8859-1?q?poJSZYn1G/MWRUyzUf2dN+PoxQCu4l9FKWjCZuH0EIpXXBQrwc3FGZloJAWp?= =?iso-8859-1?q?Ol8ZqnCOv9RlhYiFez3YmUHeJJ5ifd1cvK+iZmCHgvGUIfdlmH5grK7JSNnZ?= =?iso-8859-1?q?4mRBp/hp6/RNL+OUZWPNyKnPGayiLxZZR/s3QSQl9IIWPu8DI/CukghOJW/+?= =?iso-8859-1?q?QyYboWX0s8TeJbAd6ieckosTH1XB9ioVUlX5gdcIow1cwfsuI9e1vGY8uT5r?= =?iso-8859-1?q?4ARcFyfyq5pHlqK+6UYVnOTxsrgTF3hNBweHY5QXC+p+c7kC40hJnx51zTGR?= =?iso-8859-1?q?s+D7bgXhkoZDLdDkP87PXThQgrJPqBx9FaXRtALeUOP00RjUeet3zztymp/z?= =?iso-8859-1?q?06jpwixiFh2od434EvQrxFAS/mdQWfPjAfAB7eI+lpbJ+6yacGKmkWmOeaE4?= =?iso-8859-1?q?Y7upbJycruR/TjZIIMvooWHRnGsu/Q5WAjQ+PjwPIHLGx0pWgIKE92aHmQEa?= =?iso-8859-1?q?w6/DzUUCEeikbFGhl26em4nOJTCT0lWNKXRdHSQSkff7GpsknOxK5Epp7o9i?= =?iso-8859-1?q?MdB5VMw2wUC+nds/RjeOq5Dq1mZpykrEWzcCOgk44jK8U5ccrWghUEibp/1T?= =?iso-8859-1?q?uqa+m8TCRS5LSwafKUjXObj0dMxu9IJz8ale2bhnmMzaJmleIOBw/a345b5/?= =?iso-8859-1?q?So88yRcki/LsRnz1KBDoJsCUYEFHkLJmOVkAWWS8IpVjkYynEoKt4hkuv6bp?= =?iso-8859-1?q?i1WUzGonHOJeAlPqj739u8YRs9si0a0CF1u4Sg/Mdyuc77RxcZM0njl6mUAv?= =?iso-8859-1?q?UBxmiVz3e4MCCgifh0fnToXA0qDlwBQTOTyOSZpKmddUJWMjqsipxia9u3PB?= =?iso-8859-1?q?wccoPSMArnaXqJ3+aa0F8IkYHlFS9YKFZtGdCgEaemvpnMk967IsZyYieZXw?= =?iso-8859-1?q?F6ixXJLMWjVtMVISPOpIw5yGHH+cnD7exLOJ286uu6TkD392fBVZ22gHAwOI?= =?iso-8859-1?q?xG/SweciJKqiayACocHsJfgDzYnvp9nYhKkI0L0e72ZhEsYo1xNJiglxGuw0?= =?iso-8859-1?q?JKFuH3XKK1FIS3KdESmGsxW3Cwwll6HXwasiJVn5Y8e/I7FybNagRN6oXGPr?= =?iso-8859-1?q?Cm8DHtvG8IdFysDZ0of9hizyq1WAEUu99GxhRJaBLWpsBtgzwVgR/iCK69oR?= =?iso-8859-1?q?Quy1iPrKy8KIhzppvjJcZ++IJXxTS/UGOssILJtgSTbJqvgRd9ibF3qd76Xj?= =?iso-8859-1?q?IW?= X-Forefront-Antispam-Report: CIP:137.201.242.130;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.micron.com;PTR:masquerade.micron.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: micron.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 04:59:58.3051 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03a8f530-4ed0-49c8-61fe-08dced9f624b X-MS-Exchange-CrossTenant-Id: f38a5ecd-2813-4862-b11b-ac1d563c806f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f38a5ecd-2813-4862-b11b-ac1d563c806f;Ip=[137.201.242.130];Helo=[mail.micron.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF0000000A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0801MB7725 Enabling mailbox commands only if background operation and request abort cancellation are both supported. This check is to allow user space commands to initiate background commands responsibly while complying with any default background timeout implemented in kernel. Link: https://lore.kernel.org/linux-cxl/66035c2e8ba17_770232948b@dwillia2-xfh.jf.intel.com.notmuch/ Suggested-by: Dan Williams Signed-off-by: Ajay Joshi Signed-off-by: Ravi Shankar ---  drivers/cxl/core/mbox.c | 12 ++++++++++--  drivers/cxl/cxlmem.h    | 16 ++++++++++++++++  2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 5175138c4fb7..8c0144913b9e 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -733,12 +733,20 @@ static void cxl_walk_cel(struct cxl_memdev_state *mds, size_t size, u8 *cel)            for (i = 0; i < cel_entries; i++) {                  u16 opcode = le16_to_cpu(cel_entry[i].opcode); +               u16 effect = le16_to_cpu(cel_entry[i].effect);                  struct cxl_mem_command *cmd = cxl_mem_find_command(opcode);                  int enabled = 0;                    if (cmd) { -                       set_bit(cmd->info.id, mds->enabled_cmds); -                       enabled++; +                       /* +                        * For background operation commands, enable only if +                        * Request abort background operation is supported. +                        */ +                       if (!(effect & CXL_CEL_FLAG_BACKGROUND_OPERATION) || +                          (effect & CXL_CEL_FLAG_REQ_ABORT_BACKGROUND_SUPPORTED)) { +                               set_bit(cmd->info.id, mds->enabled_cmds); +                               enabled++; +                       }                  }                    if (cxl_is_poison_command(opcode)) { diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 2a25d1957ddb..d8c0894797ac 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -579,6 +579,22 @@ struct cxl_cel_entry {          __le16 effect;  } __packed;   +/* + * CEL Entry Effects + * CXL rev 3.1 Section 8.2.9.5.2.1; Table 8-75 + */ +#define        CXL_CEL_FLAG_CFG_CHANGE_AFTER_RESET BIT(0) +#define        CXL_CEL_FLAG_CFG_CHANGE_IMMEDIATE BIT(1) +#define        CXL_CEL_FLAG_DATA_CHANGE_IMMEDIATE BIT(2) +#define        CXL_CEL_FLAG_POLICY_CHANGE_IMMEDIATE BIT(3) +#define        CXL_CEL_FLAG_LOG_CHANGE_IMMEDIATE BIT(4) +#define        CXL_CEL_FLAG_SECURITY_CHANGE BIT(5) +#define        CXL_CEL_FLAG_BACKGROUND_OPERATION BIT(6) +#define        CXL_CEL_FLAG_SECONDARY_MAILBOX_SUPPORTED BIT(7) +#define        CXL_CEL_FLAG_REQ_ABORT_BACKGROUND_SUPPORTED BIT(8) +#define        CXL_CEL_FLAG_CFG_CHANGE_AFTER_CONV_RESET BIT(10) +#define        CXL_CEL_FLAG_CFG_CHANGE_AFTER_CXL_RESET BIT(11) +  struct cxl_mbox_get_log {          uuid_t uuid;          __le32 offset;