Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp153870pxj; Wed, 26 May 2021 18:59:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz22N1G13xbtO2lHknIiLu7K/KAZdmynp+K1f0hai8p1vATmFwz9FPNVIXwPwG72xi6ehQt X-Received: by 2002:a05:6e02:4af:: with SMTP id e15mr1004836ils.131.1622080756257; Wed, 26 May 2021 18:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622080756; cv=none; d=google.com; s=arc-20160816; b=k2E6JhZwuGVFuTDn4PeNlc7//sJVxKrKX5l/HykVnbO9P5XDpIyM+2UYTWKm6lFBA9 WpA1Ma63XwlTGRX0bbrSZy9D2XL3QtJJ5+kc4eUrVrGU0kSHzxmL+KLnUOcsIvKo91ZN GjrJtJUREsLb2yfSMei+vdchH5+YM0hrU1n5+fFbatofvzSKG1j+jGH/nO9fFHMiRdEO py92MgI55v1m+Jj5FKK7qXpmRo0Jqagpl2a4VZvlWXCQiuHB6bZhL+CFNgLVsn6lUY2T 42yMGZo0htd4VWN1NApXZWaPGIPsQaCsqaEbwMjlNZla0wv+JZpkDi3Du7wWGRtURL8p 0/Jg== 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=5wEGblhtlP9E0lVnL6kXah2VuMsLBDpBt9ZKGd4ZIJ0=; b=UTDrCAvpdB2lVACIM44RQUOS5jVEJMikRp5G+vfHlegXQ0bJER9pqiwlQEQcorN1PN 7lpvNKUb4MCvzJJ6YAUcQVrNYpS0ggS+081hmAuMD/HoljyXjKDX0uKDcgkjU6CrypnI MZVRWfiCEXDlzc9mc0ml/++JQ6TIqLVcOP8t9Gqt1LLo44KtRo/ONGhC69TXdAHzM27+ L8L4y0k+aEwXDeTnyWy3nI7toZSo0Y7ApnmMvANsxu+i2h/kbpKSmNZB0XPM7y7QPrnw HNmUw/rRDj6YRLU93qsi1hQJwy+N0mlINLiDaQ0HOZGec4WXmtTz5Gt0pwm2kn6bM9/8 vOUw== 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 5si920311ilx.117.2021.05.26.18.58.13; Wed, 26 May 2021 18:59:16 -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 S233896AbhE0BRB (ORCPT + 99 others); Wed, 26 May 2021 21:17:01 -0400 Received: from mga05.intel.com ([192.55.52.43]:56578 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232187AbhE0BRA (ORCPT ); Wed, 26 May 2021 21:17:00 -0400 IronPort-SDR: oZ7qCx9N4vOYgPsMkZd7unBaxzTZRLkRi72h41xGaQJnzA8NZtU7Rad26aYG979ir3W+KM48w+ HfdvsQeuNqRw== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="288209041" X-IronPort-AV: E=Sophos;i="5.82,333,1613462400"; d="scan'208";a="288209041" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 18:15:19 -0700 IronPort-SDR: r5lvlq6vEkvkfvPCQqjnHcGY2peVNNIc9/QzbOYJcegwikPdzidKYdORioooW6juonuByrZhi2 IaOBaJPQp2hw== X-IronPort-AV: E=Sophos;i="5.82,333,1613462400"; d="scan'208";a="397544739" Received: from djiang5-mobl1.amr.corp.intel.com (HELO [10.212.10.31]) ([10.212.10.31]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 18:15:18 -0700 Subject: Re: [PATCH v6 15/20] vfio/mdev: idxd: ims domain setup for the vdcm 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> <162164283796.261970.11020270418798826121.stgit@djiang5-desk3.ch.intel.com> <20210523235023.GL1002214@nvidia.com> <29cec5cd-3f23-f947-4545-f507b3f70988@intel.com> <20210527005444.GV1002214@nvidia.com> From: Dave Jiang Message-ID: Date: Wed, 26 May 2021 18:15:17 -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: <20210527005444.GV1002214@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/26/2021 5:54 PM, Jason Gunthorpe wrote: > On Wed, May 26, 2021 at 05:22:22PM -0700, Dave Jiang wrote: >> On 5/23/2021 4:50 PM, Jason Gunthorpe wrote: >>> On Fri, May 21, 2021 at 05:20:37PM -0700, Dave Jiang wrote: >>>> @@ -77,8 +80,18 @@ int idxd_mdev_host_init(struct idxd_device *idxd, struct mdev_driver *drv) >>>> return rc; >>>> } >>>> + ims_info.max_slots = idxd->ims_size; >>>> + ims_info.slots = idxd->reg_base + idxd->ims_offset; >>>> + idxd->ims_domain = pci_ims_array_create_msi_irq_domain(idxd->pdev, &ims_info); >>>> + if (!idxd->ims_domain) { >>>> + dev_warn(dev, "Fail to acquire IMS domain\n"); >>>> + iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_AUX); >>>> + return -ENODEV; >>>> + } >>> I'm quite surprised that every mdev doesn't create its own ims_domain >>> in its probe function. >>> >>> This places a global total limit on the # of vectors which makes me >>> ask what was the point of using IMS in the first place ? >>> >>> The entire idea for IMS was to make the whole allocation system fully >>> dynamic based on demand. >> Hi Jason, thank you for the review of the series. >> >> My understanding is that the driver creates a single IMS domain for the >> device and provides the address base and IMS numbers for the domain based on >> device IMS resources. So the IMS region needs to be contiguous. Each mdev >> can call msi_domain_alloc_irqs() and acquire the number of IMS vectors it >> desires and the DEV MSI core code will keep track of which vectors are being >> used. This allows the mdev devices to dynamically allocate based on demand. >> If the driver allocates a domain per mdev, it'll needs to do internal >> accounting of the base and vector numbers for each of those domains that the >> MSI core already provides. Isn't that what we are trying to avoid? As mdevs >> come and go, that partitioning will become fragmented. > I suppose it depends entirely on how the HW works. > > If the HW has a fixed number of interrupt vectors organized in a > single table then by all means allocate a single domain that spans the > entire fixed HW vector space. But then why do we have a ims_size > variable here?? > > However, that really begs the question of why the HW is using IMS at > all? I'd expect needing 2x-10x the max MSI-X vector size before > reaching for IMS. > > So does IDXD really have like a 4k - 40k entry linear IMS vector table > to wrap a shared domain around? > > Basically, that isn't really "scalable" it is just "bigger". > > Fully scalable would be for every mdev to point to its own 2k entry > IMS table that is allocated on the fly. Every mdev gets a domain and > every domain is fully utilized by the mdev in emulating > MSI-X. Basically for a device like idxd every PASID would have to map > to a IMS vector table array. > > I suppose that was not what was done? At least not for first gen of hardware. DSA 1.0 has 2k of IMS entries total. ims_size is what is read from the device cap register. For MSIX, the device only has 1 misc vector and 8 I/O vectors. That's why IMS is being used for mdevs. We will discuss with our hardware people your suggestion. > > Jason