From: Lu Baolu <baolu.lu@linux.intel.com>
To: "Liu, Yi L" <yi.l.liu@intel.com>, Joerg Roedel <joro@8bytes.org>
Cc: baolu.lu@linux.intel.com, David Woodhouse <dwmw2@infradead.org>,
"Raj, Ashok" <ashok.raj@intel.com>,
"Kumar, Sanjay K" <sanjay.k.kumar@intel.com>,
"Pan, Jacob jun" <jacob.jun.pan@intel.com>,
"Tian, Kevin" <kevin.tian@intel.com>,
"Sun, Yi Y" <yi.y.sun@intel.com>,
"peterx@redhat.com" <peterx@redhat.com>,
Jean-Philippe Brucker <jean-philippe.brucker@arm.com>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jacob Pan <jacob.jun.pan@linux.intel.com>
Subject: Re: [PATCH v5 02/12] iommu/vt-d: Manage scalalble mode PASID tables
Date: Tue, 4 Dec 2018 13:58:06 +0800 [thread overview]
Message-ID: <5c81008b-30e8-177d-0182-db366608562f@linux.intel.com> (raw)
In-Reply-To: <A2975661238FB949B60364EF0F2C257439D838B9@SHSMSX104.ccr.corp.intel.com>
Hi,
On 12/4/18 1:23 AM, Liu, Yi L wrote:
> Hi Joerg,
>
>> From: Joerg Roedel [mailto:joro@8bytes.org]
>> Sent: Monday, December 3, 2018 5:44 AM
>> To: Lu Baolu <baolu.lu@linux.intel.com>
>> Subject: Re: [PATCH v5 02/12] iommu/vt-d: Manage scalalble mode PASID tables
>>
>> Hi Baolu,
>>
>> On Wed, Nov 28, 2018 at 11:54:39AM +0800, Lu Baolu wrote:
>>> @@ -2482,12 +2482,13 @@ static struct dmar_domain
>> *dmar_insert_one_dev_info(struct intel_iommu *iommu,
>>> if (dev)
>>> dev->archdata.iommu = info;
>>>
>>> - if (dev && dev_is_pci(dev) && info->pasid_supported) {
>>> + /* PASID table is mandatory for a PCI device in scalable mode. */
>>> + if (dev && dev_is_pci(dev) && sm_supported(iommu)) {
>>
>> This will also allocate a PASID table if the device does not support
>> PASIDs, right? Will the table not be used in that case or will the
>> device just use the fallback PASID? Isn't it better in that case to have
>> no PASID table?
>
> We need to allocate the PASID table in scalable mode, the reason is as below:
> In VT-d scalable mode, all address translation is done in PASID-granularity.
> For requests-with-PASID, the address translation would be subjected to the
> PASID entry specified by the PASID value in the DMA request. However, for
> requests-without-PASID, there is no PASID in the DMA request. To fulfil
> the translation logic, we've introduced RID2PASID field in sm-context-entry
> in VT-d 3.o spec. So that such DMA requests would be subjected to the pasid
> entry specified by the PASID value in the RID2PASID field of sm-context-entry.
>
> So for a device without PASID support, we need to at least to have a PASID
> entry so that its DMA request (without pasid) can be translated. Thus a PASID
> table is needed for such devices.
>
>>
>>> @@ -143,18 +143,20 @@ int intel_pasid_alloc_table(struct device *dev)
>>> return -ENOMEM;
>>> INIT_LIST_HEAD(&pasid_table->dev);
>>>
>>> - size = sizeof(struct pasid_entry);
>>> - count = min_t(int, pci_max_pasids(to_pci_dev(dev)), intel_pasid_max_id);
>>> - order = get_order(size * count);
>>> + if (info->pasid_supported)
>>> + max_pasid = min_t(int, pci_max_pasids(to_pci_dev(dev)),
>>> + intel_pasid_max_id);
>>> +
>>> + size = max_pasid >> (PASID_PDE_SHIFT - 3);
>>> + order = size ? get_order(size) : 0;
>>> pages = alloc_pages_node(info->iommu->node,
>>> - GFP_ATOMIC | __GFP_ZERO,
>>> - order);
>>> + GFP_ATOMIC | __GFP_ZERO, order);
>>
>> This is a simple data structure allocation path, does it need
>> GFP_ATOMIC?
>
This function is called in an unsleepable context.
spin_lock(&lock)
[...]
if (pasid_table_is_necessary)
allocate_pasid_table(dev)
[...]
spin_unlock(&lock)
We can move it out of the lock range.
How about
if (pasid_table_is_necessary)
pasid_table = allocate_pasid_table(dev)
spin_lock(&lock)
[...]
if (pasid_table_is_necessary)
set_up_pasid_table(pasid_table)
[...]
spin_unlock(&lock)
?
Best regards,
Lu Baolu
next prev parent reply other threads:[~2018-12-04 5:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-28 3:54 [PATCH v5 00/12] iommu/vt-d: Add scalable mode support Lu Baolu
2018-11-28 3:54 ` [PATCH v5 02/12] iommu/vt-d: Manage scalalble mode PASID tables Lu Baolu
2018-12-03 13:44 ` Joerg Roedel
[not found] ` <20181203134411.lejlkbnagxml54ro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2018-12-03 17:23 ` Liu, Yi L
2018-12-03 17:23 ` Liu, Yi L
2018-12-04 5:58 ` Lu Baolu [this message]
[not found] ` <5c81008b-30e8-177d-0182-db366608562f-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-12-05 15:50 ` Joerg Roedel
2018-12-05 15:50 ` Joerg Roedel
2018-12-06 1:13 ` Lu Baolu
2018-12-05 15:47 ` Joerg Roedel
[not found] ` <20181128035449.10226-1-baolu.lu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-11-28 3:54 ` [PATCH v5 01/12] iommu/vt-d: Enumerate the scalable mode capability Lu Baolu
2018-11-28 3:54 ` Lu Baolu
2018-11-28 3:54 ` [PATCH v5 03/12] iommu/vt-d: Move page table helpers into header Lu Baolu
2018-11-28 3:54 ` Lu Baolu
2018-11-28 3:54 ` [PATCH v5 04/12] iommu/vt-d: Add 256-bit invalidation descriptor support Lu Baolu
2018-12-03 13:48 ` Joerg Roedel
2018-12-03 17:23 ` Liu, Yi L
[not found] ` <A2975661238FB949B60364EF0F2C257439D838AB-0J0gbvR4kTg/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-12-04 6:13 ` Lu Baolu
2018-12-04 6:13 ` Lu Baolu
2018-12-05 15:56 ` Joerg Roedel
2018-12-06 1:19 ` Lu Baolu
2018-11-28 3:54 ` [PATCH v5 05/12] iommu/vt-d: Reserve a domain id for FL and PT modes Lu Baolu
2018-11-28 3:54 ` [PATCH v5 06/12] iommu/vt-d: Add second level page table interface Lu Baolu
2018-11-28 3:54 ` [PATCH v5 07/12] iommu/vt-d: Setup pasid entry for RID2PASID support Lu Baolu
2018-11-28 3:54 ` [PATCH v5 08/12] iommu/vt-d: Pass pasid table to context mapping Lu Baolu
2018-11-28 3:54 ` [PATCH v5 09/12] iommu/vt-d: Setup context and enable RID2PASID support Lu Baolu
2018-11-28 3:54 ` [PATCH v5 10/12] iommu/vt-d: Add first level page table interface Lu Baolu
2018-11-28 3:54 ` [PATCH v5 11/12] iommu/vt-d: Shared virtual address in scalable mode Lu Baolu
2018-11-28 3:54 ` [PATCH v5 12/12] iommu/vt-d: Remove deferred invalidation Lu Baolu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5c81008b-30e8-177d-0182-db366608562f@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe.brucker@arm.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=sanjay.k.kumar@intel.com \
--cc=yi.l.liu@intel.com \
--cc=yi.y.sun@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.