Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp103302rwb; Mon, 26 Sep 2022 15:30:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sTzOiQLxkmmY0c2eS4Id6QoQmnnNbbYjEeT6pY1GAG/bfSLfj10HJzlE5cq/yU44nAA+0 X-Received: by 2002:a17:90b:3b8e:b0:202:6f3d:539e with SMTP id pc14-20020a17090b3b8e00b002026f3d539emr960170pjb.205.1664231445850; Mon, 26 Sep 2022 15:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664231445; cv=none; d=google.com; s=arc-20160816; b=ykJry+fQJzbv6r/a/J3PqFF2Ym+3EGnFPocUuPoAdP/I2WJWGwDLGVx5p3Z57FlxHt iXdU3je2LnSwvGbqEx7Rby/IfGiiN86Xb7hEJ6dYhNxCor4cXlpz3NSVBJ9REYNrGU+y BJy4nRhbAVcppW/0Ooy5jI9RAvG0jByFH5wBKy0r2xdMefwBNeVhZR0sFaCzYNrMUcCg raUKHHqj5h66UUyxT5yKiWNkehFkoSZTLdC6TjeetH7NbRyvpilKsyaNRBpjDeDJ3RBB jbYVyzFPtyxPlDZ6DLgOInyRWKxy2mPyPe4M7x59q1A7tgvviBb3dQW3dLXg1URb71WK FPDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BiNp6vznG/ue/EdhSIx5vJO0IBiR0tUGAMulzM4G7xY=; b=Fy+a7nTm0eWnfB2axkO1+Y9bb6+ZK+OunTVCE1P9t+WW5LXyGHVNCmoV1jsu+zB35Z +9Nf2jzaD58EPVm44rmS9trgUiMXw7BoojMWUI9hYkbenYD+VAJafJWsysxRbGd+O1u6 BYpB0FNFA668jgWYCnLcK2c/k26nOMnA9adMvanfU34/K6GllziJCuOzsk1nYIURu9Q/ JTNBC5Vb9Vi/4d5JbEtr3UzJzYBdV57ny5J/HLWKmNBRt1EWBQfweTCTLSj9Dn+K6AFj KKIy5vpkVNA5d+v8mhGPZJT9UBegIxGC2mfb4rMCO9DByihxP8rrLBMB9kIH54DvkhxW ltSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mmyZfrj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r69-20020a632b48000000b0043a0121bb28si18923686pgr.811.2022.09.26.15.30.34; Mon, 26 Sep 2022 15:30:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mmyZfrj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbiIZV5b (ORCPT + 99 others); Mon, 26 Sep 2022 17:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbiIZV5X (ORCPT ); Mon, 26 Sep 2022 17:57:23 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98596D1EA1; Mon, 26 Sep 2022 14:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664229442; x=1695765442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7mhGF9QNeYv3EmWFVfkw9VlFnNtzfRGpHZffuH3vsgY=; b=mmyZfrj+pb6XyazRf0pG/JwXTq+ytzxLJ0PfhViYZEfnC1zG+By23h41 o0B336wp3IhRVLtRQbDvAQZxh8TbJc2M5hkmdUp2yqHo052zVQrEaUca0 R/lw5vGHILEEySe0cghqRr1vYctxKvTFuqcQVKewvDuyrmp+7Dx1dArwR qf/oKM3yH9mSITSNSTogglu8L/hpSqTF/yc5x/IvowUl2oeCZZ19rLQEi mfdEJZbkLsmKLF2NBNdHRBby5IAUq12uiNIq1eMoasYk2uVjzcQWr4Flt j6YDGpG8kTJ6xqmnsm+ztrlMhZaJD2i0snWNwFbawvvptqZ6SXm8yUawi Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="302057561" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="302057561" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 14:57:21 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="598911432" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="598911432" Received: from iweiny-desk3.amr.corp.intel.com (HELO localhost) ([10.209.75.159]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 14:57:21 -0700 From: ira.weiny@intel.com To: Dan Williams Cc: Ira Weiny , Alison Schofield , Vishal Verma , Ben Widawsky , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH V3 2/2] cxl/doe: Request exclusive DOE access Date: Mon, 26 Sep 2022 14:57:11 -0700 Message-Id: <20220926215711.2893286-3-ira.weiny@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220926215711.2893286-1-ira.weiny@intel.com> References: <20220926215711.2893286-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ira Weiny The PCIE Data Object Exchange (DOE) mailbox is a protocol run over configuration cycles. It assumes one initiator at a time. While the kernel has control of the mailbox user space writes could interfere with the kernel access. Mark DOE mailbox config space exclusive when iterated by the CXL driver. Signed-off-by: Ira Weiny --- Changes from V2: Jonathan: s/PCI_DOE_CAP_SIZE/PCI_DOE_CAP_SIZEOF Set PCI_DOE_CAP_SIZEOF directly --- drivers/cxl/pci.c | 5 +++++ include/uapi/linux/pci_regs.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index faeb5d9d7a7a..621a0522b554 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -418,6 +418,11 @@ static void devm_cxl_pci_create_doe(struct cxl_dev_state *cxlds) continue; } + if (!pci_request_config_region_exclusive(pdev, off, + PCI_DOE_CAP_SIZEOF, + dev_name(dev))) + pci_err(pdev, "Failed to exclude DOE registers\n"); + if (xa_insert(&cxlds->doe_mbs, off, doe_mb, GFP_KERNEL)) { dev_err(dev, "xa_insert failed to insert MB @ %x\n", off); diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 57b8e2ffb1dd..82a03ea954af 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -1119,6 +1119,7 @@ #define PCI_DOE_STATUS_DATA_OBJECT_READY 0x80000000 /* Data Object Ready */ #define PCI_DOE_WRITE 0x10 /* DOE Write Data Mailbox Register */ #define PCI_DOE_READ 0x14 /* DOE Read Data Mailbox Register */ +#define PCI_DOE_CAP_SIZEOF 0x18 /* Size of DOE register block */ /* DOE Data Object - note not actually registers */ #define PCI_DOE_DATA_OBJECT_HEADER_1_VID 0x0000ffff -- 2.37.2