Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp977695rwb; Tue, 27 Sep 2022 07:01:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Xm9KPGEzgz3+c4BswTJ9UGL76H/I0mK2FWSvhCRx5RIqivkqW8eCRduDmCgkBxmgDT5Hg X-Received: by 2002:a17:90a:6441:b0:203:6aa1:56f8 with SMTP id y1-20020a17090a644100b002036aa156f8mr4646654pjm.25.1664287319567; Tue, 27 Sep 2022 07:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664287319; cv=none; d=google.com; s=arc-20160816; b=r76gFI7gImGoPt+iIYrdpJjKRV+uPFtBBzpTEgc2urw3DqIcoWunf8/ghfv6Z67nGX MM2DKEokNgDCkj7lnxtWXThdnvrw+HNIcf/CzxC7UYthJ5U+kj/Vxb/hrKidYvD9BXyL YL/Rhrm9PTTgP4iZgWUN/b8pCYvrsQUVi/0aTK9f+A6kdRh4xFgkcPMiw/4qkps93yBr 3Oe3uBZqH6klbd+qDEwa1IPjFqLKSa5v7hfSGql3J214X2S+4PRbHIcL8X3sbwLW0o9y XvYReJL2TiwWip2pxvEGXI21dcIXehvn22iV3lepa8+YWy3VVl+SLNtKXskVRAhZRixm skkA== 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=zoMyXCUS5E0vxaXha8aBXWEVSEQ4aTI3K1nf6BNXMCY=; b=jbGk51LNLaspX2gv7ZpJdkFCAZNxARO5C0oH+Qiu06wuh5R2a3xw+d2ZOTpmsKbDFp x22bOb7XrnsRNeKBhk/yBJ8vmyw30OzUfsQjW5yNr09c9/L4nDXqLRsiFVRl7He4YK48 0G+XBzy3JSiAFO0n/O2IpEzGGH1Q0GTzfP7nTrIBywKLAHXmoGMhRAqjIcI1Kvkt7w3E TkqaJnpYWGkbroyNePClpyQtNTt91Dvycw53KC37GnuRFgoDbPdZ1Fq0P7VMhNl47xFj fA00HLKOZCLXg5GscOXOfr1kJ6DOyvwuB/YHKLGflCqUpoixPvsDe+TP9xfNAOYxEqkM tWuA== 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 ip6-20020a17090b314600b0020317f7907bsi16561246pjb.4.2022.09.27.07.01.45; Tue, 27 Sep 2022 07:01:59 -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 S233052AbiI0N71 (ORCPT + 99 others); Tue, 27 Sep 2022 09:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233009AbiI0N6k (ORCPT ); Tue, 27 Sep 2022 09:58:40 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50C38146610; Tue, 27 Sep 2022 06:58:39 -0700 (PDT) Received: from fraeml738-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4McLm45ks9z688Z6; Tue, 27 Sep 2022 21:57:24 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml738-chm.china.huawei.com (10.206.15.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 15:58:37 +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.31; Tue, 27 Sep 2022 14:58:37 +0100 Date: Tue, 27 Sep 2022 14:58:36 +0100 From: Jonathan Cameron To: CC: Dan Williams , Alison Schofield , Vishal Verma , "Ben Widawsky" , , , Subject: Re: [PATCH V3 2/2] cxl/doe: Request exclusive DOE access Message-ID: <20220927145836.0000572e@huawei.com> In-Reply-To: <20220926215711.2893286-3-ira.weiny@intel.com> References: <20220926215711.2893286-1-ira.weiny@intel.com> <20220926215711.2893286-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: lhrpeml500004.china.huawei.com (7.191.163.9) 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 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 Mon, 26 Sep 2022 14:57:11 -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 I wonder a bit on whether the failure should be fatal given that something very odd would be required for it to fail. I'm not that bothered though. Reviewed-by: Jonathan Cameron > > --- > 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