Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2189835ybz; Thu, 23 Apr 2020 13:15:06 -0700 (PDT) X-Google-Smtp-Source: APiQypLTGwfz4o2Yb3H7RZnNOJJgcjufl7vSAEqMduzdrJyEtxbbg/35QMJt1QI16/Zo8ggrQb88 X-Received: by 2002:a05:6402:30ae:: with SMTP id df14mr4042500edb.86.1587672906712; Thu, 23 Apr 2020 13:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587672906; cv=none; d=google.com; s=arc-20160816; b=cINixrGhE5YxD5gi2Wl3rt9wftIjAUS7Okj2K7fizH7B0qUNC3Kh2ZsLiHO06ElIdd 9x/kAbdXsadbOrJiQm8N9VU6RTMgQT91dqhm6OHP6A43yTbhhlEFFKcZ5jYVvX4cDtJc bOfzSpER8UNON477mD4SwZ2jOyimPljdTYVVKrEL+cSXYHKNJCJkm8BdUcTSwdCN0464 yF9oDYkERtGmx/wix2RgWCJV6gMD86UT1vdiVMBCZrdS/sOGY/HwdVVMSEC4/PsTZklx lfYMmH0vBEHLhF+oIacnXPug4xhn+7CAS4P0DpmTMOtl+OkFiqxVRu0227xvzcnq/h3k OBBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lWtwv24Nfi0axiyCp3rc/Sxd+Qy0bmZpIX4zlE10TGU=; b=Q+XmbOUS11DBrX1OSTnzpsLIwIONFKGjFuJ8xHJXqQJ15v8dn/CKtFWsA0GpaKYm+r 3/Phavu2z4nkSeK3qOixp379649WhnFafYeWiwUPBdxsRvNylzyR6zExLGrFV+8AcvNz EyRZJU+g3MS+Ta9Ey0e5nQ/c7ZpbsVQA6iYVDMgRmNpv3aAzxQ8B5bob1I7I0srizg18 1puK6XJtPTV/geNHemzc0CMhzjdZ6xpyUBcsD7EG+BYiLY0nEuyq6MhnqoIq2+nXnBG8 X1kms7tyRQhgbVY4b4fDsIezUdJTBmKknTtXkMZpaeZ80+3IL/6u/fZQBxTC1f1e3lLp z9tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=E8SsOA0Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y4si1787023edv.549.2020.04.23.13.14.35; Thu, 23 Apr 2020 13:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=E8SsOA0Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726057AbgDWULV (ORCPT + 99 others); Thu, 23 Apr 2020 16:11:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbgDWULU (ORCPT ); Thu, 23 Apr 2020 16:11:20 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33828C09B043 for ; Thu, 23 Apr 2020 13:11:20 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id h6so3567706qvz.8 for ; Thu, 23 Apr 2020 13:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=lWtwv24Nfi0axiyCp3rc/Sxd+Qy0bmZpIX4zlE10TGU=; b=E8SsOA0QTJuBO3ylcTS2xJsVATuHuxVjAatduicQzuspBirkZTmaN7KsZ6488gy1x5 hVMem2vuSKMAm6WRqtcHA6AsKeB38+XVlUj65g41PzO7wqQmIkfYnc2xIFfFiCi3FR5T KEIKtRoxDy1RwWlu4xSglVFmVpQaVyMah7amYQi1rnQ6+Vagd86hWwWBpsVcvLLcnf0+ gjs9BvZD18tfGRTrq/znf09Tpnxqx+67K7tH6cdI0WV2BACgOO+d6z10Eqk7uiRX9HaU 3FY1WkZCCbU6ggo/3Mj+g2XNtO0IyDlH6QN7vxfIKFJnUTzvceAGGaI7L40VJpEcn/TR oq5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=lWtwv24Nfi0axiyCp3rc/Sxd+Qy0bmZpIX4zlE10TGU=; b=dJx6B/FpEUfNl8CDFGAsYm+bW1cZH8b6gYR8lVRW1pEi88jNlBLm5jb+atpApGPf9J i1kZV/g0/MgTAXisLxhQPQ2ty+WTR2rAPdwPXwtUXzDeFCzQH+yHBhZcpR7BRnruMYdO 55cRIsU4PNes/2fBNFu1MJMwzxgL83lnkHNkY2B0Fr69WTwSY0LCiuorPL97CGBdnyxp lwNe5VYCbHEEUAA70XbJhoXxLrkSI+s1j01EEQrGXi1kdqxZmPURly0r0iR7nYBvGjLU gUeE9+UJmYViKiqNM3eyy2kvyvYN4XweUmAaE3IQlL/oTCJeDd7j8yIQRlzkmoowhTDw eopQ== X-Gm-Message-State: AGi0PubUSyhoVA1vs2xki+JD193rMjwt4M8oM8YshoKdNzwLgMFiYCfC KqYhBSJVZfV6Q8DEDTRiO/cz+w== X-Received: by 2002:a0c:ed42:: with SMTP id v2mr5911795qvq.94.1587672679177; Thu, 23 Apr 2020 13:11:19 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id g12sm2476558qtu.69.2020.04.23.13.11.18 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Apr 2020 13:11:18 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jRiBq-0007lh-1P; Thu, 23 Apr 2020 17:11:18 -0300 Date: Thu, 23 Apr 2020 17:11:18 -0300 From: Jason Gunthorpe To: Dave Jiang Cc: vkoul@kernel.org, megha.dey@linux.intel.com, maz@kernel.org, bhelgaas@google.com, rafael@kernel.org, gregkh@linuxfoundation.org, tglx@linutronix.de, hpa@zytor.com, alex.williamson@redhat.com, jacob.jun.pan@intel.com, ashok.raj@intel.com, yi.l.liu@intel.com, baolu.lu@intel.com, kevin.tian@intel.com, sanjay.k.kumar@intel.com, tony.luck@intel.com, jing.lin@intel.com, dan.j.williams@intel.com, kwankhede@nvidia.com, eric.auger@redhat.com, parav@mellanox.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH RFC 04/15] drivers/base: Add support for a new IMS irq domain Message-ID: <20200423201118.GA29567@ziepe.ca> References: <158751095889.36773.6009825070990637468.stgit@djiang5-desk3.ch.intel.com> <158751205175.36773.1874642824360728883.stgit@djiang5-desk3.ch.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <158751205175.36773.1874642824360728883.stgit@djiang5-desk3.ch.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 21, 2020 at 04:34:11PM -0700, Dave Jiang wrote: > diff --git a/drivers/base/ims-msi.c b/drivers/base/ims-msi.c > new file mode 100644 > index 000000000000..738f6d153155 > +++ b/drivers/base/ims-msi.c > @@ -0,0 +1,100 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Support for Device Specific IMS interrupts. > + * > + * Copyright © 2019 Intel Corporation. > + * > + * Author: Megha Dey > + */ > + > +#include > +#include > +#include > +#include > + > +/* > + * Determine if a dev is mdev or not. Return NULL if not mdev device. > + * Return mdev's parent dev if success. > + */ > +static inline struct device *mdev_to_parent(struct device *dev) > +{ > + struct device *ret = NULL; > + struct device *(*fn)(struct device *dev); > + struct bus_type *bus = symbol_get(mdev_bus_type); > + > + if (bus && dev->bus == bus) { > + fn = symbol_get(mdev_dev_to_parent_dev); > + ret = fn(dev); > + symbol_put(mdev_dev_to_parent_dev); > + symbol_put(mdev_bus_type); No, things like this are not OK in the drivers/base Whatever this is doing needs to be properly architected in some generic way. > +static int dev_ims_prepare(struct irq_domain *domain, struct device *dev, > + int nvec, msi_alloc_info_t *arg) > +{ > + if (dev_is_mdev(dev)) > + dev = mdev_to_parent(dev); Like maybe the caller shouldn't be passing in a mdev in the first place, or some generic driver layer scheme is needed to go from a child device (eg a mdev or one of these new virtual bus things) to the struct device that owns the IRQ interface. > + init_irq_alloc_info(arg, NULL); > + arg->dev = dev; > + arg->type = X86_IRQ_ALLOC_TYPE_IMS; Also very bewildering to see X86_* in drivers/base > +struct irq_domain *arch_create_ims_irq_domain(struct irq_domain *parent, > + const char *name) > +{ > + struct fwnode_handle *fn; > + struct irq_domain *domain; > + > + fn = irq_domain_alloc_named_fwnode(name); > + if (!fn) > + return NULL; > + > + domain = msi_create_irq_domain(fn, &ims_ir_domain_info, parent); > + if (!domain) > + return NULL; > + > + irq_domain_update_bus_token(domain, DOMAIN_BUS_PLATFORM_MSI); > + irq_domain_free_fwnode(fn); > + > + return domain; > +} I'm still not really clear why all this is called IMS.. This looks like the normal boilerplate to setup an IRQ domain? What is actually 'ims' in here? > diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h > index 7d922950caaf..c21f1305a76b 100644 > +++ b/drivers/vfio/mdev/mdev_private.h > @@ -36,7 +36,6 @@ struct mdev_device { > }; > > #define to_mdev_device(dev) container_of(dev, struct mdev_device, dev) > -#define dev_is_mdev(d) ((d)->bus == &mdev_bus_type) > > struct mdev_type { > struct kobject kobj; > diff --git a/include/linux/mdev.h b/include/linux/mdev.h > index 0ce30ca78db0..fa2344e239ef 100644 > +++ b/include/linux/mdev.h > @@ -144,5 +144,8 @@ void mdev_unregister_driver(struct mdev_driver *drv); > struct device *mdev_parent_dev(struct mdev_device *mdev); > struct device *mdev_dev(struct mdev_device *mdev); > struct mdev_device *mdev_from_dev(struct device *dev); > +struct device *mdev_dev_to_parent_dev(struct device *dev); > + > +#define dev_is_mdev(dev) ((dev)->bus == symbol_get(mdev_bus_type)) NAK on the symbol_get Jason