All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: will@kernel.org, robh+dt@kernel.org, joro@8bytes.org,
	baolu.lu@linux.intel.com, sudeep.holla@arm.com,
	linux-doc@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org,
	lorenzo.pieralisi@arm.com, corbet@lwn.net, mark.rutland@arm.com,
	liviu.dudau@arm.com, guohanjun@huawei.com, rjw@rjwysocki.net,
	lenb@kernel.org, robin.murphy@arm.com, dwmw2@infradead.org,
	amurray@thegoodpenguin.co.uk, frowand.list@gmail.com
Subject: Re: [PATCH v2 05/11] PCI/ATS: Gather checks into pci_ats_supported()
Date: Thu, 12 Mar 2020 16:01:57 -0500	[thread overview]
Message-ID: <20200312210157.GA180471@google.com> (raw)
In-Reply-To: <20200311124506.208376-6-jean-philippe@linaro.org>

On Wed, Mar 11, 2020 at 01:45:00PM +0100, Jean-Philippe Brucker wrote:
> IOMMU drivers need to perform several tests when checking if a device
> supports ATS.  Move them all into a new function that returns true when
> a device and its host bridge support ATS.
> 
> Since pci_enable_ats() now calls pci_ats_supported(), the following
> new checks are now common:
> * whether a device is trusted.  Devices plugged into external-facing
>   ports such as thunderbolt are untrusted.
> * whether the host bridge supports ATS, which defaults to true unless
>   the firmware description states that ATS isn't supported by the host
>   bridge.
> 
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/ats.c       | 30 +++++++++++++++++++++++++++++-
>  include/linux/pci-ats.h |  3 +++
>  2 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
> index 390e92f2d8d1..bbfd0d42b8b9 100644
> --- a/drivers/pci/ats.c
> +++ b/drivers/pci/ats.c
> @@ -30,6 +30,34 @@ void pci_ats_init(struct pci_dev *dev)
>  	dev->ats_cap = pos;
>  }
>  
> +/**
> + * pci_ats_supported - check if the device can use ATS
> + * @dev: the PCI device
> + *
> + * Returns true if the device supports ATS and is allowed to use it, false
> + * otherwise.
> + */
> +bool pci_ats_supported(struct pci_dev *dev)
> +{
> +	struct pci_host_bridge *bridge;
> +
> +	if (!dev->ats_cap)
> +		return false;
> +
> +	if (dev->untrusted)
> +		return false;
> +
> +	bridge = pci_find_host_bridge(dev->bus);
> +	if (!bridge)
> +		return false;
> +
> +	if (!bridge->ats_supported)
> +		return false;
> +
> +	return true;

I assume this is the same as

  return bridge->ats_supported;

Only "assuming" because I'm not a C language lawyer, but I assume it
does the obvious conversion from unsigned:1 to bool.

> +}

WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <helgaas@kernel.org>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: mark.rutland@arm.com, linux-doc@vger.kernel.org,
	linux-pci@vger.kernel.org, liviu.dudau@arm.com,
	guohanjun@huawei.com, frowand.list@gmail.com, corbet@lwn.net,
	will@kernel.org, linux-acpi@vger.kernel.org, lenb@kernel.org,
	devicetree@vger.kernel.org, robh+dt@kernel.org,
	linux-arm-kernel@lists.infradead.org, dwmw2@infradead.org,
	rjw@rjwysocki.net, iommu@lists.linux-foundation.org,
	sudeep.holla@arm.com, robin.murphy@arm.com,
	amurray@thegoodpenguin.co.uk
Subject: Re: [PATCH v2 05/11] PCI/ATS: Gather checks into pci_ats_supported()
Date: Thu, 12 Mar 2020 16:01:57 -0500	[thread overview]
Message-ID: <20200312210157.GA180471@google.com> (raw)
In-Reply-To: <20200311124506.208376-6-jean-philippe@linaro.org>

On Wed, Mar 11, 2020 at 01:45:00PM +0100, Jean-Philippe Brucker wrote:
> IOMMU drivers need to perform several tests when checking if a device
> supports ATS.  Move them all into a new function that returns true when
> a device and its host bridge support ATS.
> 
> Since pci_enable_ats() now calls pci_ats_supported(), the following
> new checks are now common:
> * whether a device is trusted.  Devices plugged into external-facing
>   ports such as thunderbolt are untrusted.
> * whether the host bridge supports ATS, which defaults to true unless
>   the firmware description states that ATS isn't supported by the host
>   bridge.
> 
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/ats.c       | 30 +++++++++++++++++++++++++++++-
>  include/linux/pci-ats.h |  3 +++
>  2 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
> index 390e92f2d8d1..bbfd0d42b8b9 100644
> --- a/drivers/pci/ats.c
> +++ b/drivers/pci/ats.c
> @@ -30,6 +30,34 @@ void pci_ats_init(struct pci_dev *dev)
>  	dev->ats_cap = pos;
>  }
>  
> +/**
> + * pci_ats_supported - check if the device can use ATS
> + * @dev: the PCI device
> + *
> + * Returns true if the device supports ATS and is allowed to use it, false
> + * otherwise.
> + */
> +bool pci_ats_supported(struct pci_dev *dev)
> +{
> +	struct pci_host_bridge *bridge;
> +
> +	if (!dev->ats_cap)
> +		return false;
> +
> +	if (dev->untrusted)
> +		return false;
> +
> +	bridge = pci_find_host_bridge(dev->bus);
> +	if (!bridge)
> +		return false;
> +
> +	if (!bridge->ats_supported)
> +		return false;
> +
> +	return true;

I assume this is the same as

  return bridge->ats_supported;

Only "assuming" because I'm not a C language lawyer, but I assume it
does the obvious conversion from unsigned:1 to bool.

> +}
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <helgaas@kernel.org>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: mark.rutland@arm.com, linux-doc@vger.kernel.org,
	linux-pci@vger.kernel.org, liviu.dudau@arm.com,
	guohanjun@huawei.com, frowand.list@gmail.com,
	lorenzo.pieralisi@arm.com, corbet@lwn.net, will@kernel.org,
	joro@8bytes.org, linux-acpi@vger.kernel.org, lenb@kernel.org,
	devicetree@vger.kernel.org, robh+dt@kernel.org,
	linux-arm-kernel@lists.infradead.org, dwmw2@infradead.org,
	rjw@rjwysocki.net, iommu@lists.linux-foundation.org,
	sudeep.holla@arm.com, baolu.lu@linux.intel.com,
	robin.murphy@arm.com, amurray@thegoodpenguin.co.uk
Subject: Re: [PATCH v2 05/11] PCI/ATS: Gather checks into pci_ats_supported()
Date: Thu, 12 Mar 2020 16:01:57 -0500	[thread overview]
Message-ID: <20200312210157.GA180471@google.com> (raw)
In-Reply-To: <20200311124506.208376-6-jean-philippe@linaro.org>

On Wed, Mar 11, 2020 at 01:45:00PM +0100, Jean-Philippe Brucker wrote:
> IOMMU drivers need to perform several tests when checking if a device
> supports ATS.  Move them all into a new function that returns true when
> a device and its host bridge support ATS.
> 
> Since pci_enable_ats() now calls pci_ats_supported(), the following
> new checks are now common:
> * whether a device is trusted.  Devices plugged into external-facing
>   ports such as thunderbolt are untrusted.
> * whether the host bridge supports ATS, which defaults to true unless
>   the firmware description states that ATS isn't supported by the host
>   bridge.
> 
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/ats.c       | 30 +++++++++++++++++++++++++++++-
>  include/linux/pci-ats.h |  3 +++
>  2 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
> index 390e92f2d8d1..bbfd0d42b8b9 100644
> --- a/drivers/pci/ats.c
> +++ b/drivers/pci/ats.c
> @@ -30,6 +30,34 @@ void pci_ats_init(struct pci_dev *dev)
>  	dev->ats_cap = pos;
>  }
>  
> +/**
> + * pci_ats_supported - check if the device can use ATS
> + * @dev: the PCI device
> + *
> + * Returns true if the device supports ATS and is allowed to use it, false
> + * otherwise.
> + */
> +bool pci_ats_supported(struct pci_dev *dev)
> +{
> +	struct pci_host_bridge *bridge;
> +
> +	if (!dev->ats_cap)
> +		return false;
> +
> +	if (dev->untrusted)
> +		return false;
> +
> +	bridge = pci_find_host_bridge(dev->bus);
> +	if (!bridge)
> +		return false;
> +
> +	if (!bridge->ats_supported)
> +		return false;
> +
> +	return true;

I assume this is the same as

  return bridge->ats_supported;

Only "assuming" because I'm not a C language lawyer, but I assume it
does the obvious conversion from unsigned:1 to bool.

> +}

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-03-12 21:02 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 12:44 [PATCH v2 00/11] PCI/ATS: Device-tree support and other improvements Jean-Philippe Brucker
2020-03-11 12:44 ` Jean-Philippe Brucker
2020-03-11 12:44 ` Jean-Philippe Brucker
2020-03-11 12:44 ` [PATCH v2 01/11] dt-bindings: PCI: generic: Add ats-supported property Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-11 12:44 ` [PATCH v2 02/11] PCI: Add ats_supported host bridge flag Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-12 21:21   ` Bjorn Helgaas
2020-03-12 21:21     ` Bjorn Helgaas
2020-03-12 21:21     ` Bjorn Helgaas
2020-03-11 12:44 ` [PATCH v2 03/11] PCI: OF: Check whether the host bridge supports ATS Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-12 20:45   ` Bjorn Helgaas
2020-03-12 20:45     ` Bjorn Helgaas
2020-03-12 20:45     ` Bjorn Helgaas
2020-03-11 12:44 ` [PATCH v2 04/11] ACPI/IORT: Check ATS capability in root complex node Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-11 12:44   ` Jean-Philippe Brucker
2020-03-12 20:58   ` Bjorn Helgaas
2020-03-12 20:58     ` Bjorn Helgaas
2020-03-12 20:58     ` Bjorn Helgaas
2020-03-11 12:45 ` [PATCH v2 05/11] PCI/ATS: Gather checks into pci_ats_supported() Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-12 21:01   ` Bjorn Helgaas [this message]
2020-03-12 21:01     ` Bjorn Helgaas
2020-03-12 21:01     ` Bjorn Helgaas
2020-03-11 12:45 ` [PATCH v2 06/11] iommu/amd: Use pci_ats_supported() Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45 ` [PATCH v2 07/11] iommu/arm-smmu-v3: " Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-18 21:49   ` Will Deacon
2020-03-18 21:49     ` Will Deacon
2020-03-18 21:49     ` Will Deacon
2020-03-11 12:45 ` [PATCH v2 08/11] iommu/vt-d: " Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-12  1:44   ` Lu Baolu
2020-03-12  1:44     ` Lu Baolu
2020-03-12  1:44     ` Lu Baolu
2020-03-12  7:54     ` Jean-Philippe Brucker
2020-03-12  7:54       ` Jean-Philippe Brucker
2020-03-12  7:54       ` Jean-Philippe Brucker
2020-03-12  8:18       ` Lu Baolu
2020-03-12  8:18         ` Lu Baolu
2020-03-12  8:18         ` Lu Baolu
2020-03-11 12:45 ` [PATCH v2 09/11] ACPI/IORT: Drop ATS fwspec flag Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45 ` [PATCH v2 10/11] arm64: dts: fast models: Enable PCIe ATS for Base RevC FVP Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45 ` [PATCH v2 11/11] Documentation: Generalize the "pci=noats" boot parameter Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker
2020-03-11 12:45   ` Jean-Philippe Brucker

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=20200312210157.GA180471@google.com \
    --to=helgaas@kernel.org \
    --cc=amurray@thegoodpenguin.co.uk \
    --cc=baolu.lu@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=frowand.list@gmail.com \
    --cc=guohanjun@huawei.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jean-philippe@linaro.org \
    --cc=joro@8bytes.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=sudeep.holla@arm.com \
    --cc=will@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 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.