Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp766427rwe; Thu, 25 Aug 2022 08:45:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6l8cQSZChkyuJTVK+maqryaOMH7kPzyzX6RWZ9MLAlLFprnmxuqvyJILWKqtjTaAWfjK2j X-Received: by 2002:a63:5945:0:b0:41d:8ca6:48cd with SMTP id j5-20020a635945000000b0041d8ca648cdmr3748641pgm.311.1661442348699; Thu, 25 Aug 2022 08:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661442348; cv=none; d=google.com; s=arc-20160816; b=tflDg6ubZfYAMEzry4CrbAFX4s2G0I6Y0b/3cj7j51qp1WgLdrfJnj9xVqjWKu79SZ cMHTxp0G4TXtP1fhHf3JqQoFicVJzfqGISULAdW9WSiGLu8Zi2vfUGj08AmkFRpzGjLL 743/qlvSpPiVymyEg+KPq07ae/c9Sh6cjotYo6kW+BTTTMOtNj42iWw7dHdFpy8dgsIT gXDc5mMozCQ7jz5qYZ3l+xhBSPyDkFBzomUJsq3DeZbPDFZZWIPotVrYVDjMfm9V2++A N+pyZqqusm1u8T/9QdAwMJipBWkf4nRMT8P4h/xibzDTdU03rozIvS5FuGsNyGgiiTDV ZuNg== 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:subject:cc:to:from:date; bh=HC0xZq9aVeukJlGeIPNvkWUPqE1lnNfoRmKbxH8e4aY=; b=s9yxflTJiv/E2YsOe8eydVlzrren+eZboNxc8z6bm0TE4kemNwSDWE/Kbk8YbbBpeH 0/7UiUz94D/PpPaGx10dT9EUptRfvEqtYxiUUjZ0abgnxGTr4evGwmMy0rJyaV9mr46c pSG7eEkUc6uCWY75wnX05P6dagiIllZILKaOzz46javtgJDOGXiVS4+q1C3oTgGH2SCK +X9SkxHV7+OmpPPYndq9+xgZXf4dmI4XlkR/q9gKpcxnaN64khDBjgf8Cr85wGw0BBwR mdcvK5aB2nyAyqZTV8grdDf2JuXw99fBhU0wJeHgYtc19SM7meAe3DZpOIPkHPLYKn9d Lk8A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a63e805000000b0041be5a0c345si18310199pgh.52.2022.08.25.08.45.36; Thu, 25 Aug 2022 08:45:48 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241532AbiHYO71 (ORCPT + 99 others); Thu, 25 Aug 2022 10:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235495AbiHYO70 (ORCPT ); Thu, 25 Aug 2022 10:59:26 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E56CB56EB; Thu, 25 Aug 2022 07:59:24 -0700 (PDT) Received: from fraeml712-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MD5hK055cz67y8R; Thu, 25 Aug 2022 22:58:57 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml712-chm.china.huawei.com (10.206.15.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 25 Aug 2022 16:59:19 +0200 Received: from localhost (10.202.226.42) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 25 Aug 2022 15:59:19 +0100 Date: Thu, 25 Aug 2022 15:59:18 +0100 From: Jonathan Cameron To: CC: Dan Williams , Bjorn Helgaas , Greg Kroah-Hartman , Alison Schofield , Vishal Verma , Ben Widawsky , , , Subject: Re: [PATCH V2 2/2] cxl/doe: Request exclusive DOE access Message-ID: <20220825155918.00000d42@huawei.com> In-Reply-To: <20220824232450.723179-3-ira.weiny@intel.com> References: <20220824232450.723179-1-ira.weiny@intel.com> <20220824232450.723179-3-ira.weiny@intel.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.42] X-ClientProxiedBy: lhrpeml100006.china.huawei.com (7.191.160.224) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, 24 Aug 2022 16:24:50 -0700 ira.weiny@intel.com wrote: > 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 > --- > 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..5b833eb91543 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_SIZE, > + 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..f2396bcd09cc 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_SIZE (0x14 + 4) /* Size of this register block */ Equivalents in this file don't build _SIZE from previous register - they just give it directly. Hence change this to 0x18. Also, it seems that _SIZEOF is the common naming for this in this file. There are a few _SIZE such as PCI_MSIX_ENTRY_SIZE but many more _SIZEOF > > /* DOE Data Object - note not actually registers */ > #define PCI_DOE_DATA_OBJECT_HEADER_1_VID 0x0000ffff