From patchwork Fri Feb 10 09:05: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: 13135552 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 EEA2BC05027 for ; Fri, 10 Feb 2023 09:05:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85EA86B011A; Fri, 10 Feb 2023 04:05:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 80EE46B011D; Fri, 10 Feb 2023 04:05:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AFD66B011E; Fri, 10 Feb 2023 04:05:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4A1516B011A for ; Fri, 10 Feb 2023 04:05:57 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 00CBA1C6D31 for ; Fri, 10 Feb 2023 09:05:56 +0000 (UTC) X-FDA: 80450799954.23.F39D24F Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf19.hostedemail.com (Postfix) with ESMTP id E2EA21A0005 for ; Fri, 10 Feb 2023 09:05:54 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JzWgV6G0; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676019955; 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=sXevTYWZEFDu/kuHSXYci1sYVSQvNQ6E8gmnztP0Loo=; b=bYEpfHnz3OEenYn8UzfNtMS2oIOiHlwizFQ02OUaifVPKIn0K3YCXQfkuOd+ZpMtrJ2nZD hJhQPzFq1og9iKKxd9zQPNir0+WZqm7dnL9E5sD1nzwMWniGWCZI6/L9tR6u3DSwLavGML GTPgBPDyhyEF9ES387oUSLhHrmmM4xE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JzWgV6G0; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676019955; a=rsa-sha256; cv=none; b=o1Kdln9wdVuETKO/Ciz+V4qrLKKFpLs5MFxRLZeet8sKI4cZ7F67YYe4NRrDvs0gpVDYUB Q1xRXlm0uFi1BJ3HG+SPlGatLflAQYLMe4hfduP+lliU9pB6+oc0qjbD0+64mjgm6RzzCF s8nyf3X4vCnJc85tZxLuuRtSFGJCGwU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676019955; x=1707555955; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pOZoUMpBUKRLc8QIK289XEjoJsII4YkEt62Y5Arb8us=; b=JzWgV6G0ISbYIOXom1ktU4OHQDxZeIOX2xVXRHG3i9wchIBfVBdm+D7i x/JuyofdkJuhov9BQSr+5Mq+aFGUKDUx9iUYws35xEZyjC72nUiQfJZqn LUbUrjL1dw9yLfjwMm4ywPdfJvcCYUQOBv+qR4zsjkczxk0h7OmK7aZs9 rBjBKn5gDxzdCqOZ0UpcE94nqjvTrkvVEGxtVzzgl0uE3W4R12i9feAbw wVqYBPwlC5JITuGp0QdnV4VkV3WDKxaoqPtflGiwYAT2RmonWVMSTv9NM s6nRyUmFv+d3VvlaqXmw/tUjejbfcLpc8eHH72SLeagMEco9BcSqSMBUw w==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="416600013" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="416600013" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 01:05:53 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="669930208" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="669930208" Received: from hrchavan-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.46.42]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 01:05:51 -0800 Subject: [PATCH v2 05/20] cxl/region: Validate region mode vs decoder mode From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Vishal Verma , Gregory Price , Dave Jiang , Ira Weiny , Jonathan Cameron , Fan Ni , dave.hansen@linux.intel.com, linux-mm@kvack.org, linux-acpi@vger.kernel.org Date: Fri, 10 Feb 2023 01:05:51 -0800 Message-ID: <167601995111.1924368.7459128614177994602.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <167601992097.1924368.18291887895351917895.stgit@dwillia2-xfh.jf.intel.com> References: <167601992097.1924368.18291887895351917895.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E2EA21A0005 X-Stat-Signature: r64h7yatmdzooafbpj13nh1uhortiz6w X-HE-Tag: 1676019954-205034 X-HE-Me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Ne+CbcxmlPXfVMNOQKNOGqSX7LBpE0Gucw/MErSFJqxElqq3eEeWomlYpkbO4SBslimQ3CzIMxkmU9sGijQocV93s83R6084vf7bkddkPr2rbTvG5/bYKOujjPZNSqv35hnc+9c11iEwyMyMRUdTunxKhJEUCCV/qTLX441tB9KQ/7+4X6R9ARlWsuLDhW1ysiP9f6pdzfYmM1emFtLMeKd4H/x9hn+gGJJU6+F9yOWatnSyLTH8CUauhbOEMTEPMP/4ixwX6XyGeTYlZz9IyHxU6 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. Reviewed-by: Vishal Verma Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Ira Weiny Reviewed-by: Jonathan Cameron Tested-by: Fan Ni Link: https://lore.kernel.org/r/167564537131.847146.9020072654741860107.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams --- 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 0fc80478ff6b..285835145e9b 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1221,6 +1221,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;