From patchwork Fri Jun 14 03:21:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xingtao Yao (Fujitsu)" X-Patchwork-Id: 13697824 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (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 0C2195CB8 for ; Fri, 14 Jun 2024 03:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.139.117 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718335310; cv=none; b=J+24F37FkNmtI1P0gwgSILZZnVOtkri89dRkpU4M2lEu4sWbfq4aLk6sKNmvPjGZ/mBBJ/6NKU+se3xztBMime+alF2p0qgQmHQ5zBBRf1tjHbGRu9Oz/hgmc+sOGH6iNmtwLnJmzmDwl6lwiZyeWBGWJIoLyvZ9eamgm3vDvo0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718335310; c=relaxed/simple; bh=GgNqY0mHozLL6/U+YP0dcaJTH5h+5zyuMZvOkgJpk7w=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=WGsqSVkxRjCCH19FkCcjq3+uEG0MsNHmYkHnPUqd7+wWL5Zr1ptDU7DDwngBQWvboMvdRYiS3Ni5whiI+z683Exs4dq28jK6oXlMHeGB0JQm/V6mk9/c3aqswxc9uFDpyGd+9PEjNEfT+nQ1GyToFfTCZJ5aZ1xyTOWOz7VOAxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=GiqbY4At; arc=none smtp.client-ip=68.232.139.117 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="GiqbY4At" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1718335308; x=1749871308; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GgNqY0mHozLL6/U+YP0dcaJTH5h+5zyuMZvOkgJpk7w=; b=GiqbY4AtZUSpAWSgMn9eMK2z+nDc8PWs0AgXyQEL8lY7tW9HMoHp2zxk i1NPa5Sc6fYdZObn04PUdPGUQtfU1aAKXjE5iWhfVyNCaTBIDDsWMXouj 8QBmmwqB2VBvQ8QTAV7/PWlMwFmOMQdTncPU9L/Uf81WR4TjW/iwzuV4v iT8pqEvLFErZFNSY5T2UBXVdntyde2yejHfEgnc8JjieM+m64ar2D0JMx FCMEempW21JIBOnnryCS8hDE4aep3wpsFp90BPzl5b1vACsegXHmmfWnw EY7dZMQsZzefPTiDEpXqFKlQPTyYsrdOH5SZCrVdhHEOrylPjM6JPMsGi g==; X-IronPort-AV: E=McAfee;i="6700,10204,11102"; a="163243912" X-IronPort-AV: E=Sophos;i="6.08,236,1712588400"; d="scan'208";a="163243912" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2024 12:21:39 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id C0463C9160 for ; Fri, 14 Jun 2024 12:21:36 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 08704D5606 for ; Fri, 14 Jun 2024 12:21:36 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 6D800E51A8 for ; Fri, 14 Jun 2024 12:21:35 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.225.88]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 6190A1A0002; Fri, 14 Jun 2024 11:21:34 +0800 (CST) From: Yao Xingtao To: dave@stgolabs.net, jonathan.cameron@huawei.com, dave.jiang@intel.com, alison.schofield@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com, dan.j.williams@intel.com, jim.harris@samsung.com Cc: linux-cxl@vger.kernel.org, Yao Xingtao Subject: [PATCH v8 0/3] check interleave capability Date: Thu, 13 Jun 2024 23:21:30 -0400 Message-Id: <20240614032133.45365-1-yaoxt.fnst@fujitsu.com> X-Mailer: git-send-email 2.37.3 Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28452.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28452.004 X-TMASE-Result: 10--8.369800-10.000000 X-TMASE-MatchedRID: vUS6K+jSHAsc0dnT9XswpR1kSRHxj+Z5g8vk+C7vzx6a9Zo7TJaDsIr/ BixjtpkT10Vp4KHcMAFiJsbEDHUAbTMH3wWOx57nqhcdnP91eXH0swHSFcVJ6Ez5vzLEGq8DWPB 5gJ72ENYw1PYcQ48wS9hesu+M4ONN7yClTVv2c3a/mux8PsfamZHcXE2JOFJtyPRAwD/3abaUfD H3TE2AyGqREDgJ0Nwm7icOXRyDqaoS5iXdhf8hbrnHu4BcYSmtrzl8sNiWClKbKItl61J/yZ+in TK0bC9eKrauXd3MZDWvl10AkC/AxfEtlPIoiPZVZj1NpsIClh6GWAlp9IWXKKwc4u02WcQC X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Currently, the cxl driver does not check the interleave capability of devices (such as host bridges, switches, cxl_mem, etc.) when creating a region. When the driver adds a device to the region and sets its decoder, if the device does not support the specified interleave ways or interleave granularity, the device may ignore unsupported bits, causing the configured decoder to be inconsistent with expectations. During memory access, the decoder may decode the HPA into an incorrect DPA, ultimately leading to memory access failure. Checking the interleave capability of a device early in the process of adding it to a region can quickly prevent this issue from occurring. Changes: V7[7] -> V8: -- drop the redundant check in check_interleave_cap() -- add cxlmem.h to kernel-doc (newly add) -- fixup cxl_test (newly add) V6[6] -> V7: -- update comment. V5[5] -> V6: -- fix some typo. -- update comment. -- set rc when check failed in cxl_port_attach_region(). V4[4] -> V5: -- update comment. -- add nr_targets check while attaching a port to switch. -- delete passthrough flag and allow all the capabilities for passthrough decoders. V3[3] -> V4: -- update comment. -- optimize the code. -- add a passthrough flag to mark the passthrough decoder. V2[2] -> V3: -- revert ig_cap_mask to interleave_mask. -- fix the interleave bits check logical. V1[1] -> V2: -- rename interleave_mask to ig_cap_mask. -- add a check for interleave granularity. -- update commit. -- move hdm caps init to parse_hdm_decoder_caps(). [1] https://lore.kernel.org/linux-cxl/20240401075635.9333-1-yaoxt.fnst@fujitsu.com [2] https://lore.kernel.org/linux-cxl/20240403021747.17260-1-yaoxt.fnst@fujitsu.com [3] https://lore.kernel.org/linux-cxl/20240409022621.29115-1-yaoxt.fnst@fujitsu.com [4] https://lore.kernel.org/linux-cxl/20240422091350.4701-1-yaoxt.fnst@fujitsu.com [5] https://lore.kernel.org/linux-cxl/20240524092740.4260-1-yaoxt.fnst@fujitsu.com [6] https://lore.kernel.org/linux-cxl/20240611021511.35315-1-yaoxt.fnst@fujitsu.com [7] https://lore.kernel.org/linux-cxl/20240612032544.39149-1-yaoxt.fnst@fujitsu.com Yao Xingtao (3): cxl/region: check interleave capability cxl: documentation: add cxlmem.h to cxl driver-api cxl_test: fix the 'create region failed' error .../driver-api/cxl/memory-devices.rst | 3 + drivers/cxl/core/hdm.c | 13 +++ drivers/cxl/core/region.c | 89 +++++++++++++++++++ drivers/cxl/cxl.h | 2 + drivers/cxl/cxlmem.h | 10 +++ tools/testing/cxl/test/cxl.c | 4 + 6 files changed, 121 insertions(+)