Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp577873pxj; Fri, 28 May 2021 10:19:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJ4Iz1FWEqmHAyL/i0e5G319uE3S2nSrA8dGZVDT/RYPQazZP4d+01futz79SydkQ7kH8C X-Received: by 2002:a92:2004:: with SMTP id j4mr8317421ile.53.1622222361080; Fri, 28 May 2021 10:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622222361; cv=none; d=google.com; s=arc-20160816; b=avF7XScoFJCABTM4tpIpnYwajtZf8esOVXEv8D476oX7NzDvCddJ7YRQY1C26Fv5HH Mb+zw1VncbiRKt5780JeaesTTHnoxw9NRf0Lj+l1T34SjVV30wlQF6oYzu4Kdw5GAkyC nSGWdcNWlGHNuYCzbOY0HpP/gX4UDJt1G9uqTmxaTbU4qomKDajmhO/ydsUtJizVQ8fk Msd/0GWZ9FD4pBFZQIE8rzJ+Y4C9M6Pb7lhO3ETmcLXAfQdRpBhb07xHNOsX6xUwufqo DUZXv7PmUmIOKFUevuM4Gu453X+njDAnbaFHHjT3prjz1QJbdv8ptmQTlTBjPPdJmQFl dRDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=vBIACVUsIb2NTxQG6c0Ig6pjMwlmefWIVF0YSWcO+is=; b=MoC9pnuIownEvsVU9oN/2zf+Q5TE/UDx2MCwChGfomlvtP6NsaZys/8rQAkix9SHU1 ajV43RCrmIsNC+kahxJ5rjMGluxZmMOJES/YK93re/ABf/zr97LlvBOkfIPp/e8w5Ir8 uPB2U4B8F6PUlW1yh3o79COlN1ogM+ZTe+ddV6dUmlg26WQs7ZBiNPFRMC4SQZIbj/Dx VVGUXqQXwV4i+lNZwmAeu76JByC5z/KRIT4UL9vtVXebG475O79vIT469F1UeDJHT3xv ph/seqvHkIgwErBCUUBFFqBB3RUSqBbKzHHIxSQ40vF1t4jitbuQPY4/BraFdFXsVQDj dscQ== 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 t12si7101307jaj.66.2021.05.28.10.18.46; Fri, 28 May 2021 10:19:21 -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 S234892AbhE1Qjf (ORCPT + 99 others); Fri, 28 May 2021 12:39:35 -0400 Received: from mga09.intel.com ([134.134.136.24]:56761 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbhE1Qje (ORCPT ); Fri, 28 May 2021 12:39:34 -0400 IronPort-SDR: GPE9xYbcxpjl1Rp1doAT6AXMNa43L8h7FOpGpn1iu8jREE+svNqDjnowe+OygFXSIsvzxBT+QR EwoP/PxpYXPg== X-IronPort-AV: E=McAfee;i="6200,9189,9998"; a="202990024" X-IronPort-AV: E=Sophos;i="5.83,229,1616482800"; d="scan'208";a="202990024" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2021 09:37:59 -0700 IronPort-SDR: nuprb2pRUyvSOcpQNsBLmhDvS3EkTuTjQqMQIkVZhwz0/P/zOJUm0tPg+guCxZfOzw4cL/j45f rAeLqRpsmU7g== X-IronPort-AV: E=Sophos;i="5.83,229,1616482800"; d="scan'208";a="473140693" Received: from djiang5-mobl1.amr.corp.intel.com (HELO [10.251.147.238]) ([10.251.147.238]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2021 09:37:57 -0700 Subject: Re: [PATCH v6 05/20] vfio: mdev: common lib code for setting up Interrupt Message Store To: Jason Gunthorpe Cc: alex.williamson@redhat.com, kwankhede@nvidia.com, tglx@linutronix.de, vkoul@kernel.org, megha.dey@intel.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, dan.j.williams@intel.com, eric.auger@redhat.com, pbonzini@redhat.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <162164243591.261970.3439987543338120797.stgit@djiang5-desk3.ch.intel.com> <162164277624.261970.7989190254803052804.stgit@djiang5-desk3.ch.intel.com> <20210524000257.GN1002214@nvidia.com> <44ba4c5f-aa40-3149-85a5-3e382f9c2eae@intel.com> <20210528122145.GK1002214@nvidia.com> From: Dave Jiang Message-ID: Date: Fri, 28 May 2021 09:37:56 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210528122145.GK1002214@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/28/2021 5:21 AM, Jason Gunthorpe wrote: > On Thu, May 27, 2021 at 06:49:59PM -0700, Dave Jiang wrote: >>>> +static int mdev_msix_enable(struct mdev_irq *mdev_irq, int nvec) >>>> +{ >>>> + struct mdev_device *mdev = irq_to_mdev(mdev_irq); >>>> + struct device *dev; >>>> + int rc; >>>> + >>>> + if (nvec != mdev_irq->num) >>>> + return -EINVAL; >>>> + >>>> + if (mdev_irq->ims_num) { >>>> + dev = &mdev->dev; >>>> + rc = msi_domain_alloc_irqs(dev_get_msi_domain(dev), dev, mdev_irq->ims_num); >>> Huh? The PCI device should be the only device touching IRQ stuff. I'm >>> nervous to see you mix in the mdev struct device into this function. >> As we talked about in the other thread. We have a single IMS domain per >> device. The domain is set to the mdev 'struct device' and we allocate the >> vectors to each mdev 'struct device' so we can manage those IMS vectors >> specifically for that mdev. > That is not the point, I'm asking if you should be calling > dev_set_msi_domain(mdev) at all I'm not familiar with the standard way of doing this. Should I not set the domain to the mdev 'struct device' because I can have multiple mdev using the same domain? With the domain set, I am able to retrieve it and call the msi_domain_alloc_irqs() in common code. Alternatively we can pass in the domain during init and not rely on dev->msi_domain. > > Jason