Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3134007ybz; Sun, 3 May 2020 18:11:09 -0700 (PDT) X-Google-Smtp-Source: APiQypJIfkuoK7uctKr0qO5CKwXmO+N1sbhgdHeG1QE4QnyDQd/37ER+haz1W9Bv2Rjxh8mcytOT X-Received: by 2002:a17:906:328f:: with SMTP id 15mr13503413ejw.33.1588554669095; Sun, 03 May 2020 18:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588554669; cv=none; d=google.com; s=arc-20160816; b=u1y2AmrdZNBiFbjHwrxwQ+vf/WTl2GXGvfmSalMaNWhjMKvKoMS5Io/00p7RWeeCvV o3Jg++knY51ktPeLiSjnCCqzJURapl0Bz4nIXAqhQSUxJIapWvNyXJZnGTl1fTxKu0FP WaXXUwFCtGaHVro25gE2C9TJb1JpVKkSNHni6nYBoQS79YiIYW+eYUKsttGkqCuFmsIb oDY95jKMeqzxOJ9939M6oJwJXGJcOW+9qqHWPbSCIwb89zObWseVXTpu43TL+WeyTgnm eaGXP3EJQnQjEIghL7ubsDCMBw+fcelgJJpL6iQyD2uFq5co8GTh6li9B4U+kmgeStPq pq8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=sTa4++f9TVt86F+A3QrJUtHRBZHViONSjNyWZnjnlNM=; b=GbjPfC59OsizYIxY9MDyclUynA9bk7s7yO4S6/QQnFJhGRm8PbtMRTpm94CnzIIuYu TbSW7y3AeQ1o847RM9lVZQK7/V7BLth9uKr2CROE3CDbKnazzBqTxPLA/hYnGLTRWoQ9 FVPjIhjkUmZQerQT/SKi8rCCkUoNPT3o5FQx7kONeqrCoays3e0f0t6px8YENzeg7qJW nHkl4+gClhew+n0M8LheHAIEMXlZtvizwEqILzgv9IHU8YkO6K9lmbGgLOU6brVXGNX/ zT4cIVf2oMjTKpTw/eTNEKrvih8GO5nOY1NZV7oOAyj7XwpqVYuXau9kFPVOJCEWg0VK qqEw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u30si7329572edi.376.2020.05.03.18.10.27; Sun, 03 May 2020 18:11:09 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726864AbgEDAZb (ORCPT + 99 others); Sun, 3 May 2020 20:25:31 -0400 Received: from mga17.intel.com ([192.55.52.151]:3314 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbgEDAZb (ORCPT ); Sun, 3 May 2020 20:25:31 -0400 IronPort-SDR: sjCE19S3GHl4ZJ2nNglSm5xGNFVlUadqn6UxDQUSCh49u2sydvpvYjFG0C+cKXyRnCoHcrZz3g 5shLJ8w/S68g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 May 2020 17:25:30 -0700 IronPort-SDR: brpGf6YOXbEiaJ5u/jdtv1LzsE30+9enUNeIpNQ7635oSAodFRTy7A78KoBtp1FXaDlFJm3nHb 8k1Wj+osPKrQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,350,1583222400"; d="scan'208";a="406317151" Received: from meghadey-mobl1.amr.corp.intel.com (HELO [10.212.197.87]) ([10.212.197.87]) by orsmga004.jf.intel.com with ESMTP; 03 May 2020 17:25:29 -0700 Subject: Re: [PATCH RFC 04/15] drivers/base: Add support for a new IMS irq domain To: Jason Gunthorpe Cc: Dave Jiang , vkoul@kernel.org, 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 References: <158751095889.36773.6009825070990637468.stgit@djiang5-desk3.ch.intel.com> <158751205175.36773.1874642824360728883.stgit@djiang5-desk3.ch.intel.com> <20200423201118.GA29567@ziepe.ca> <35f701d9-1034-09c7-8117-87fb8796a017@linux.intel.com> <20200503222513.GS26002@ziepe.ca> <1ededeb8-deff-4db7-40e5-1d5e8a800f52@linux.intel.com> <20200503224659.GU26002@ziepe.ca> From: "Dey, Megha" Message-ID: <8ff2aace-0697-b8ef-de68-1bcc49d6727f@linux.intel.com> Date: Sun, 3 May 2020 17:25:28 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200503224659.GU26002@ziepe.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/3/2020 3:46 PM, Jason Gunthorpe wrote: > On Sun, May 03, 2020 at 03:40:44PM -0700, Dey, Megha wrote: >> On 5/3/2020 3:25 PM, Jason Gunthorpe wrote: >>> On Fri, May 01, 2020 at 03:30:02PM -0700, Dey, Megha wrote: >>>> Hi Jason, >>>> >>>> On 4/23/2020 1:11 PM, Jason Gunthorpe wrote: >>>>> 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. >>>> >>>> Basically what I am trying to do here is to determine if the device is an >>>> mdev device or not. >>> >>> Why? mdev devices are virtual they don't have HW elements. >> >> Hmm yeah exactly, since they are virtual, they do not have an associated IRQ >> domain right? So they use the irq domain of the parent device.. >> >>> >>> The caller should use the concrete pci_device to allocate >>> platform_msi? What is preventing this? >> >> hmmm do you mean to say all platform-msi adhere to the rules of a PCI >> device? > > I mean where a platform-msi can work should be defined by the arch, > and probably is related to things like having an irq_domain attached > > So, like pci, drivers must only try to do platfor_msi stuff on > particular devices. eg on pci_device and platform_device types. > > Even so it may not even work, but I can't think of any reason why it > should be made to work on a virtual device like mdev. > >> The use case if when we have a device assigned to a guest and we >> want to allocate IMS(platform-msi) interrupts for that >> guest-assigned device. Currently, this is abstracted through a mdev >> interface. > > And the mdev has the pci_device internally, so it should simply pass > that pci_device to the platform_msi machinery. hmm i am not sure I follow this. mdev has a pci_device internally? which struct are you referring to here? mdev is merely a micropartitioned PCI device right, which no real PCI resource backing. I am not how else we can find the IRQ domain associated with an mdev.. > > This is no different from something like pci_iomap() which must be > used with the pci_device. > > Jason >