Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1194188rwb; Fri, 18 Nov 2022 14:21:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf6eFh7fM2NroleIuh19a9iZ1WQb2vi+FVNDXj7rtQWSQ4nplyY0RlqtC6PAs1l79RewQDGM X-Received: by 2002:a17:902:b114:b0:186:c958:6cd8 with SMTP id q20-20020a170902b11400b00186c9586cd8mr1330799plr.145.1668810111092; Fri, 18 Nov 2022 14:21:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668810111; cv=none; d=google.com; s=arc-20160816; b=UiIvDTWDFLfkKM/eLyPMD/Wev4DbMu1aXtXkYCAxHS+PLtj+X5R8TVwxZsG7HdUxDM 3VrzBiXZiT5a5XNDueW2H54wMcIxQSoSs0aC8chFQEk61Ta/P3moclDGmEl8xwvsY1JK ecQqxn6b3DxR8vsi7nt+eCYj2Kt0Gp1h0KRFazHYd57ZS+z2UeWUkY0iepaJPuMOXJRZ jnUW8OS5tYNw7P2soe2xzNXebfJR7FUHMLmkpexy6O1ZKhZOUYd17wlOxFYQmk2KaU/6 DotSOJr+I6PZijs/ywxwW42sQY6qtNj49+5kvwgcRLcvPF4dYI6iM5b4fmr5w6Hck9xg 5hlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=lnfgXd1Z1kEJz/iUidm8c/wi9GfdOU18AFgTdLiaHzQ=; b=Wes6HVH6lh0MprFUwuP7+MhSzrNj4s7ojjOYpAJs6ocV1m7xzU/dJE1+5W8dQ/kmuZ /Kwdqm5ETVvSJpv1Ew2ALBWEeOyUC1G7us5cUIn14t/ST01tTWYw8Lawc6FdGJ0KJJHK CJtsuY0SqJH55SaSxzi+z+0H4TelmLpXdYzCOysrCBe5q+Ho6Ind2GIC0klzyvfgwJmL SxG117MZAwW1msA1nFK7B3F/DrsJG/P7nXDJZvBfMo+hXV94a/mJPNldp5R+tMSxU+0L jIMWOaPMD2RAwN5GGcoUWe0e9zoXFgX0F6Ng1w2UuLlUxnUp4jKCrwKjz3I0JGd4ULV/ LWmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zyc09kpE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a17090a634100b0020d2d54066csi4016776pjs.171.2022.11.18.14.21.39; Fri, 18 Nov 2022 14:21:51 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zyc09kpE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbiKRWKN (ORCPT + 90 others); Fri, 18 Nov 2022 17:10:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbiKRWJK (ORCPT ); Fri, 18 Nov 2022 17:09:10 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C4002A247; Fri, 18 Nov 2022 14:08:58 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668809336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lnfgXd1Z1kEJz/iUidm8c/wi9GfdOU18AFgTdLiaHzQ=; b=zyc09kpEikj+0oYrNiLkiSvG9o5luUsIacAec8CTkLA1ktWLFgHIB6NS9ZfzkF11H1HY6T fEH0fU8bWxin7bquD/8CFOsBgQvwRy9cfQ9EZXHdkKJ57g+Kl35U48VSmGgOU+2EFOZKrx yRJJ8S/aNHH8uUnZ1WTFV9HPAmR0QbdT5lJ5Tlf4pSWhfHzVmEri5XUou7/gmtYOAX6yOB DwD3VZWWvLOwgw67lrDcI1lnbY77G78Nc1kNuQbzISMzsb/OhTorHW3IGQlDS22AdDdO1M L5CMFQustvn7er8uhTWsSKM+nZ5sjRu7kB2mTbtQUQNidHpZZ60B31PXY84+3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668809336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lnfgXd1Z1kEJz/iUidm8c/wi9GfdOU18AFgTdLiaHzQ=; b=gwW+7N4k+YwFIof1NRxdeJBMMVdkWDrF3YynFdWLoC2YtLMMwmVmr2iGssZHh8hWnfx4Uh fl68IDVGrHvdcgBA== To: Jason Gunthorpe Cc: LKML , x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , "Ahmed S. Darwish" , Reinette Chatre Subject: Re: [patch 19/33] genirq/msi: Provide msi_desc::msi_data In-Reply-To: References: <20221111133158.196269823@linutronix.de> <20221111135206.346985384@linutronix.de> Date: Fri, 18 Nov 2022 23:08:55 +0100 Message-ID: <871qpzkj9k.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Wed, Nov 16 2022 at 15:28, Jason Gunthorpe wrote: > On Fri, Nov 11, 2022 at 02:58:41PM +0100, Thomas Gleixner wrote: > >> +/** >> + * struct msi_desc_data - Generic MSI descriptor data >> + * @iobase: Pointer to the IOMEM base adress for interrupt callbacks >> + * @cookie: Device cookie provided at allocation time >> + * >> + * The content of this data is implementation defined, e.g. PCI/IMS >> + * implementations will define the meaning of the data. >> + */ >> +struct msi_desc_data { >> + void __iomem *iobase; >> + union msi_dev_cookie cookie; >> +}; > > It would be nice to see the pci_msi_desc converted to a domain > specific storage as well. I looked into this and it gets ugly very fast. The above has two parts: iobase is domain specific and setup by the domain code cookie is per interrupt allocation. That's where the instance queue or whatever connects to the domain. I can abuse the fields for PCI/MSI of course, but see below. > Maybe could be written > > struct pci_msi_desc { > } > static_assert(sizeof(struct pci_msi_desc) <= sizeof(((struct msi_desc *)0)->domain_data)); > > struct pci_msix_desc { > } > static_assert(sizeof(struct pci_msix_desc) <= sizeof(((struct msi_desc *)0)->domain_data)); > > ideally hidden in the pci code with some irq_chip facing export API to > snoop in the bits a few places need I can't use that for the current combo legacy PCI/MSI code as I can't split the irq chip implementations like I can with the new per device domains. And no, I'm not going to create separate code pathes which do the same thing on different data structures just to pretend that it's all shiny. > We've used 128 bits for the PCI descriptor, we might as well like > everyone have all 128 bits for whatever they want to do That's fine, but there are two parts to it: 1) Domain specific data 2) Per allocation specific data #1 is data which the domain code puts there, e.g. in the prepare_desc() callback #2 is data which the usage site hands in which gives the domain and the interrupt chip the information it needs So the data structure should look like this: struct msi_desc_data { union msi_domain_cookie dom_cookie; union msi_instance_cookie ins_cookie; }; union msi_domain_cookie { void __iomem *iobase; void *ptr; u64 value; }; union msi_instance_cookie { void *ptr; u64 value; }; Sure I could make both cookies plain u64, but I hate these forced type casts and the above is simple to handle and understand. So you get your 128 bit, but not per instance because that's a nightmare to validate versus the allocation code which has to copy the data into the msi descriptor, whatever it is (PASID, queue pointer ....). Having two cookies makes a lot of sense to have a proper separation between domain and usage site. For IDXD the domain wants to store the iobase and needs a per allocation PASID. For your queue model, the domain wants a pointer to some device or whatever specific things and the queue provides a pointer so that the domain/chip can do the right thing for that particular instance. For both sides, the domain and the allocation side something like the above is sufficient. Thanks, tglx