From patchwork Mon Feb 6 01:02:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 13129229 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 D17AFC636CC for ; Mon, 6 Feb 2023 01:02:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71E596B0075; Sun, 5 Feb 2023 20:02:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CEA56B007B; Sun, 5 Feb 2023 20:02:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 596F96B007D; Sun, 5 Feb 2023 20:02:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4BBD86B0075 for ; Sun, 5 Feb 2023 20:02:54 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 195E11A03FE for ; Mon, 6 Feb 2023 01:02:54 +0000 (UTC) X-FDA: 80435067468.29.73DFEE3 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf24.hostedemail.com (Postfix) with ESMTP id 19C73180002 for ; Mon, 6 Feb 2023 01:02:51 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=FTdgOzxi; spf=pass (imf24.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675645372; 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:dkim-signature; bh=Cve9O0QR++TCuVy7x01qT9ZK650rmv2E/f3LeUgFdo4=; b=wd2ZKqklzcF+sYObbfhBWzvm7jGFILC44XuqHkepctvFfGMI4buzseTCVW1EdbcviOIoUG 879o1kxgLv9tzdGIjpSxD1l4RtrJ7CnrXtC52d0y2ofT4aToK5zBg0YqvLuwPie1SwCsZG oIoQtXk8A6zlt3fVeUZ21F9BaBLwzmk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=FTdgOzxi; spf=pass (imf24.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675645372; a=rsa-sha256; cv=none; b=aSGM+xJ9eSWSsGtpxTiN8oCIDpFCumKgsB4qMEqmFmsiX/3EJAs4KSWm4TAZkfqdGdS3l8 /0ymGa/u+TKPYlLgiioEa8/6nbowIp4IUBK/oBeqR7Itu6iwqui+1gBHBRQCeoVIk3rK8m 5TLPg5ig4sIikI+kf88wyOG4Y0lfliY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675645372; x=1707181372; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yszGLPkFMXedVGllSqe6JjeO5D0jX4yLcgUfwilZAzI=; b=FTdgOzxiK/n8EQrct1NKXny2jtk1ViZwiVEpgp9OZkPYE4CXUjZBJSUj VZqMuRxyEbtehyZ11M36/P/r7n4tsbt9qu/15yhULYXKG+d0NwadZA5uE SM+sw2ibRu3KiXXkjtyL6zw95dwgLgx/KWw2mmruy7mpKlYo5yO/RQ931 Z1TkR8raZZ56FFpisyDfzoUnARRtGBkVagXqkbGJE0jhqf899RhjZMwSl PAz64pP9vJ7oILUYmdcQ/JfH3g6hgKj8YfEyejrG04X1WngqADCNrvHQe 8P1ktKEjs18+ZoWNCYjnZ9s2rjiUuqdvRREd76PUOnofiVCkEWeAWO4Ow Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="331243799" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="331243799" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 17:02:51 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="643855741" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="643855741" Received: from mkrysak-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.212.255.187]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 17:02:51 -0800 Subject: [PATCH 04/18] cxl/region: Validate region mode vs decoder mode From: Dan Williams To: linux-cxl@vger.kernel.org Cc: dave.hansen@linux.intel.com, linux-mm@kvack.org, linux-acpi@vger.kernel.org Date: Sun, 05 Feb 2023 17:02:51 -0800 Message-ID: <167564537131.847146.9020072654741860107.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <167564534874.847146.5222419648551436750.stgit@dwillia2-xfh.jf.intel.com> References: <167564534874.847146.5222419648551436750.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 19C73180002 X-Stat-Signature: xf3sfe6g3eqabkp9qjaekezn5gfpnm9k X-Rspam-User: X-HE-Tag: 1675645371-952182 X-HE-Meta: U2FsdGVkX187drxW97Ey7ZUAWDxv0oqI2xO+NF7kRcLBkkjtlVheKBamklIUX8h2T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D31ZoP/24mjMmlOai9ge/B4Pw1YdEPEfu1vmumgE763XUxAVc1Zn 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: In preparation for a new region mode, do not, for example, allow 'ram' decoders to be assigned to 'pmem' regions and vice versa. Signed-off-by: Dan Williams Reviewed-by: Jonathan Cameron Reviewed-by: Ira Weiny Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Vishal Verma --- drivers/cxl/core/region.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index c9e7f05caa0f..53d6dbe4de6d 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1217,6 +1217,12 @@ static int cxl_region_attach(struct cxl_region *cxlr, struct cxl_dport *dport; int i, rc = -ENXIO; + if (cxled->mode != cxlr->mode) { + dev_dbg(&cxlr->dev, "%s region mode: %d mismatch: %d\n", + dev_name(&cxled->cxld.dev), cxlr->mode, cxled->mode); + return -EINVAL; + } + if (cxled->mode == CXL_DECODER_DEAD) { dev_dbg(&cxlr->dev, "%s dead\n", dev_name(&cxled->cxld.dev)); return -ENODEV;