Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2071489rwb; Fri, 2 Dec 2022 05:14:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf6dDgLczwyXWXyIIdGdXkv7YsqM9YUyh49uLsttoDF7oPmvGL0Q5s+LZfYT9wpJ0/cJymjp X-Received: by 2002:a17:906:404:b0:781:f54c:1947 with SMTP id d4-20020a170906040400b00781f54c1947mr48254012eja.69.1669986844849; Fri, 02 Dec 2022 05:14:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669986844; cv=none; d=google.com; s=arc-20160816; b=0ZkzdcIS97rH+6E9UmGHkvfGVbekZqD2pJ0C/y0EqQcmgjs5Mn6bXywK2bboD5Fnah yOC08C+864HekABjhTZVacH8CuU/lAndHpBV1dGztxKnrH+FGUMkf+b8/BUZqBJDaTKn PGacpn78H1oZ3/x9Xcqn4dLh9AIfmHreTUPhTCW2VlF43JvyBNIYDwRqyHvYL/axboqc ZqB2M8VRlD+lae5S35kWhNo0nN6zWW/q8yweaWcepYVtkGNfEym0OOIXfbz/dTyfidCy 4sThzVPhmFGUi/qJz3qoyTvH0xd//0Jd36sAro17nu8n67kzdshvqauAYpnHlzcWCz8Y hFnQ== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=ayvMW+tLzQ2yupe6zcYTLHtFF/yb+ZIK3gr25OrKf10=; b=U51kEZ4UX1/VaN8StrlnwhIWuw3PCxMPxGnVbNETtUXWDUNk8SWoooTbcq3QrT68kc jojc0NJslmgBdNSVdyFdQPxKXRYMHNpAumxEoEITFG4kZ0+Fz2qtsIQdqdgiC9/m1fcI 0zWbusgu+YWHZ+ZDf/8qOu4wVndski1tQigGDSlefzhiR4HtOUC/+N8jIhxzWApgX5ln BqEOKW+0fEr0uB24KiGhhvpfEsLYND6Vms2yozH7zRFSeLoUhzRFsgg6ZlDkvZLsMofx 35atwQhexiv/xx+zQTFxC4Uluo2mJAMBBjdg2mGwpBJxA/17bVdr01fnsYk5h8jLK8Ru jSaw== 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 e6-20020a056402190600b00468cd2ab847si6389528edz.172.2022.12.02.05.13.43; Fri, 02 Dec 2022 05:14:04 -0800 (PST) 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 S233646AbiLBNEt (ORCPT + 83 others); Fri, 2 Dec 2022 08:04:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233651AbiLBNEs (ORCPT ); Fri, 2 Dec 2022 08:04:48 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65890D78D4; Fri, 2 Dec 2022 05:04:46 -0800 (PST) Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4NNtPc2Ct8z6H7G9; Fri, 2 Dec 2022 21:01:56 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml742-chm.china.huawei.com (10.206.15.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 2 Dec 2022 14:04:43 +0100 Received: from localhost (10.202.227.76) 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.34; Fri, 2 Dec 2022 13:04:43 +0000 Date: Fri, 2 Dec 2022 13:04:42 +0000 From: Jonathan Cameron To: Dan Williams CC: Ira Weiny , Davidlohr Bueso , Bjorn Helgaas , Alison Schofield , Vishal Verma , "Ben Widawsky" , Steven Rostedt , "Dave Jiang" , , Subject: Re: [PATCH V2 01/11] cxl/pci: Add generic MSI-X/MSI irq support Message-ID: <20221202130442.0000088a@Huawei.com> In-Reply-To: <63895c5b40770_3cbe029432@dwillia2-xfh.jf.intel.com.notmuch> References: <20221201002719.2596558-1-ira.weiny@intel.com> <20221201002719.2596558-2-ira.weiny@intel.com> <63894579bf550_3cbe029458@dwillia2-xfh.jf.intel.com.notmuch> <63895c5b40770_3cbe029432@dwillia2-xfh.jf.intel.com.notmuch> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) 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 Thu, 1 Dec 2022 18:00:59 -0800 Dan Williams wrote: > Ira Weiny wrote: > > On Thu, Dec 01, 2022 at 04:23:21PM -0800, Dan Williams wrote: > > > ira.weiny@ wrote: > > > > From: Davidlohr Bueso > > > > > > > > Currently the only CXL features targeted for irq support require their > > > > message numbers to be within the first 16 entries. The device may > > > > however support less than 16 entries depending on the support it > > > > provides. > > > > > > > > Attempt to allocate these 16 irq vectors. If the device supports less > > > > then the PCI infrastructure will allocate that number. > > > > > > What happens if the device supports 16, but irq-core allocates less? I > > > believe the answer is with the first user, but this patch does not > > > include a user. > > > > > > > Store the number of vectors actually allocated in the device state for > > > > later use by individual functions. > > > > > > The patch does not do that. > > > > Sorry missed updating this message. > > > > > > > > I know this patch has gone through a lot of discussion, but this > > > mismatch shows it should really be squashed with the first user because > > > it does not stand on its own anymore. > > > > It is separate because it was Davidlohr's to begin with. > > > > I'll squash it back. > > > > > > > > > Upon successful allocation, users can plug in their respective isr at > > > > any point thereafter, for example, if the irq setup is not done in the > > > > PCI driver, such as the case of the CXL-PMU. > > > > > > > > Cc: Bjorn Helgaas > > > > Cc: Jonathan Cameron > > > > Co-developed-by: Ira Weiny > > > > Signed-off-by: Ira Weiny > > > > Signed-off-by: Davidlohr Bueso > > > > > > > > --- > > > > Changes from V1: > > > > Jonathan > > > > pci_alloc_irq_vectors() cleans up the vectors automatically > > > > use msi_enabled rather than nr_irq_vecs > > > > > > > > Changes from Ira > > > > Remove reviews > > > > Allocate up to a static 16 vectors. > > > > Change cover letter > > > > --- > > > > drivers/cxl/cxlmem.h | 3 +++ > > > > drivers/cxl/cxlpci.h | 6 ++++++ > > > > drivers/cxl/pci.c | 23 +++++++++++++++++++++++ > > > > 3 files changed, 32 insertions(+) > > > > > > > > diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h > > > > index 88e3a8e54b6a..cd35f43fedd4 100644 > > > > --- a/drivers/cxl/cxlmem.h > > > > +++ b/drivers/cxl/cxlmem.h > > > > @@ -211,6 +211,7 @@ struct cxl_endpoint_dvsec_info { > > > > * @info: Cached DVSEC information about the device. > > > > * @serial: PCIe Device Serial Number > > > > * @doe_mbs: PCI DOE mailbox array > > > > + * @msi_enabled: MSI-X/MSI has been enabled > > > > * @mbox_send: @dev specific transport for transmitting mailbox commands > > > > * > > > > * See section 8.2.9.5.2 Capacity Configuration and Label Storage for > > > > @@ -247,6 +248,8 @@ struct cxl_dev_state { > > > > > > > > struct xarray doe_mbs; > > > > > > > > + bool msi_enabled; > > > > + > > > > > > This goes unused in this patch and it also duplicates what the core > > > offers with pdev->{msi,msix}_enabled. > > > > I tried to argue that with Jonathan and lost. What I had in V1 was to store > > the number actually allocated. Then if a function reports something higher > > later it can't be used. > > A successful pci_alloc_irq_vectors() call assigns a vector number to all > interrupt sources on the device regardless of how many interrupt sources > there are. If the device has 32 interrupt sources and 16 irqs are returned > from pci_alloc_irq_vectors() then each interrupt source will be sharing > a vector with one or more other vectors. All PCI IRQ vectors are shared. Assuming my understanding is correct... Subtle tweak to that description (not that it matters in practice). Some of the vectors will be shared. For MSI at least it is up to the device to assign msgnums in whatever way it likes such that they are fit in the number that were enabled. So it 'could' put them all on the first msgnum if it wants to, or put any that would otherwise have been greater than 16 on msgnum 15. Impdef how it decides that spread. MSIX is has a layer of indirection in control of software, so it gets more complex... > > So I do not see the point of this msi_enabled flag cxl_dev_state. If > pci_alloc_irq_vectors() returns at least 1 then you are good to go.