linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Don Dutile <ddutile@redhat.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, Joerg Roedel <jroedel@suse.de>,
	David Woodhouse <dwmw2@infradead.org>,
	iommu@lists.linux-foundation.org,
	Gregor Dick <gdick@solarflare.com>
Subject: Re: [PATCH v2 10/11] PCI: Stop caching ATS Invalidate Queue Depth
Date: Mon, 27 Jul 2015 19:13:14 -0400	[thread overview]
Message-ID: <55B6BB0A.80904@redhat.com> (raw)
In-Reply-To: <20150727222726.GA24401@google.com>

On 07/27/2015 06:27 PM, Bjorn Helgaas wrote:
> Hi Don,
>
> On Mon, Jul 27, 2015 at 10:00:53AM -0400, Don Dutile wrote:
>> On 07/20/2015 08:15 PM, Bjorn Helgaas wrote:
>>> Stop caching the Invalidate Queue Depth in struct pci_dev.
>>> pci_ats_queue_depth() is typically called only once per device, and it
>>> returns a fixed value per-device, so callers who need the value frequently
>>> can cache it themselves.
>>>
>>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>>> ---
>>>   drivers/pci/ats.c   |    9 ++++-----
>>>   include/linux/pci.h |    1 -
>>>   2 files changed, 4 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
>>> index 67524a7..bdb1383 100644
>>> --- a/drivers/pci/ats.c
>>> +++ b/drivers/pci/ats.c
>>> @@ -20,16 +20,12 @@
>>>   void pci_ats_init(struct pci_dev *dev)
>>>   {
>>>   	int pos;
>>> -	u16 cap;
>>>
>>>   	pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS);
>>>   	if (!pos)
>>>   		return;
>>>
>>>   	dev->ats_cap = pos;
>>> -	pci_read_config_word(dev, dev->ats_cap + PCI_ATS_CAP, &cap);
>>> -	dev->ats_qdep = PCI_ATS_CAP_QDEP(cap) ? PCI_ATS_CAP_QDEP(cap) :
>>> -					    PCI_ATS_MAX_QDEP;
>>>   }
>>>
>>>   /**
>>> @@ -131,13 +127,16 @@ EXPORT_SYMBOL_GPL(pci_restore_ats_state);
>>>    */
>>>   int pci_ats_queue_depth(struct pci_dev *dev)
>>>   {
>>> +	u16 cap;
>>> +
>>>   	if (!dev->ats_cap)
>>>   		return -EINVAL;
>>>
>>>   	if (dev->is_virtfn)
>>>   		return 0;
>>>
>> hmmm, isn't one of the fixes in this patch set to
>> change the caching of ats queue depth ?  won't above
>> make it 0 for all VF's ?  is that correct, or desired (virtual) value?
>
> Per spec (SR-IOV r1.1., sec 3.7.4), the ATS queue depth register on a VF
> always contains zero.
>
> Here's the v4.1 code:
>
>      int pci_ats_queue_depth(struct pci_dev *dev)
>      {
>          if (dev->is_virtfn)
>                  return 0;
>
>          if (dev->ats)
>                  return dev->ats->qdep;
>
> 	...
>
>
> In v4.1, pci_ats_queue_depth() always returned 0 for a VF.  For VFs, we
> didn't look at the dev->ats->qdep cache.  So I don't think this changes
> anything for the caller.
>
> A previous patch changed this path so we return -EINVAL instead of 0 for
> VFs that don't support ATS.  I think the previous behavior there was wrong,
> but I doubt anybody noticed.
>
> Bjorn
>
ok. thanks for the sanity check.

>>> -	return dev->ats_qdep;
>>> +	pci_read_config_word(dev, dev->ats_cap + PCI_ATS_CAP, &cap);
>>> +	return PCI_ATS_CAP_QDEP(cap) ? PCI_ATS_CAP_QDEP(cap) : PCI_ATS_MAX_QDEP;
>>>   }
>>>   EXPORT_SYMBOL_GPL(pci_ats_queue_depth);
>>>
>>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>>> index 307f96a..4b484fd 100644
>>> --- a/include/linux/pci.h
>>> +++ b/include/linux/pci.h
>>> @@ -378,7 +378,6 @@ struct pci_dev {
>>>   	};
>>>   	u16		ats_cap;	/* ATS Capability offset */
>>>   	u8		ats_stu;	/* ATS Smallest Translation Unit */
>>> -	u8		ats_qdep;	/* ATS Invalidate Queue Depth */
>>>   	atomic_t	ats_ref_cnt;	/* number of VFs with ATS enabled */
>>>   #endif
>>>   	phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>


  reply	other threads:[~2015-07-27 23:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21  0:13 [PATCH v2 00/11] PCI: Fix ATS deadlock Bjorn Helgaas
2015-07-21  0:13 ` [PATCH v2 01/11] iommu/vt-d: Cache PCI ATS state and Invalidate Queue Depth Bjorn Helgaas
2015-07-27 13:08   ` Joerg Roedel
2015-07-27 22:54     ` Bjorn Helgaas
2015-07-28  7:14       ` Joerg Roedel
2015-07-21  0:14 ` [PATCH v2 02/11] PCI: Allocate ATS struct during enumeration Bjorn Helgaas
2015-07-27 12:40   ` Joerg Roedel
2015-07-21  0:14 ` [PATCH v2 03/11] PCI: Embed ATS info directly into struct pci_dev Bjorn Helgaas
2015-07-27 12:45   ` Joerg Roedel
2015-07-21  0:14 ` [PATCH v2 04/11] PCI: Reduce size of ATS structure elements Bjorn Helgaas
2015-07-21  0:14 ` [PATCH v2 05/11] PCI: Rationalize pci_ats_queue_depth() error checking Bjorn Helgaas
2015-07-21  0:14 ` [PATCH v2 06/11] PCI: Inline the ATS setup code into pci_ats_init() Bjorn Helgaas
2015-07-21  0:14 ` [PATCH v2 07/11] PCI: Use pci_physfn() rather than looking up physfn by hand Bjorn Helgaas
2015-07-21  0:14 ` [PATCH v2 08/11] PCI: Clean up ATS error handling Bjorn Helgaas
2015-07-27 12:56   ` Joerg Roedel
2015-07-21  0:15 ` [PATCH v2 09/11] PCI: Move ATS declarations to linux/pci.h so they're all together Bjorn Helgaas
2015-07-21  0:15 ` [PATCH v2 10/11] PCI: Stop caching ATS Invalidate Queue Depth Bjorn Helgaas
2015-07-27 12:57   ` Joerg Roedel
2015-07-27 14:00   ` Don Dutile
2015-07-27 22:27     ` Bjorn Helgaas
2015-07-27 23:13       ` Don Dutile [this message]
2015-07-21  0:15 ` [PATCH v2 11/11] PCI: Remove pci_ats_enabled() Bjorn Helgaas
2015-07-27 12:58   ` Joerg Roedel
2015-07-28 15:16 ` [PATCH v2 00/11] PCI: Fix ATS deadlock Joerg Roedel
2015-07-29 16:07 ` Bjorn Helgaas
2015-08-06 16:03   ` Yinghai Lu
2015-08-07  1:06     ` Yinghai Lu
2015-08-10 17:33       ` Bjorn Helgaas
2015-08-10 22:54         ` Yinghai Lu

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=55B6BB0A.80904@redhat.com \
    --to=ddutile@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=dwmw2@infradead.org \
    --cc=gdick@solarflare.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jroedel@suse.de \
    --cc=linux-pci@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).