Linux IOMMU Development
 help / color / mirror / Atom feed
From: Henry Willard <henry.willard@oracle.com>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] iommu: Avoid unnecessary cache invalidations
Date: Fri, 27 Oct 2023 04:30:31 +0000	[thread overview]
Message-ID: <196E8628-C1F4-4392-BFDC-BDA2B0D0835C@oracle.com> (raw)
In-Reply-To: <20231026084942.17387-1-baolu.lu@linux.intel.com>

On Oct 26, 2023, at 1:49 AM, Lu Baolu <baolu.lu@linux.intel.com> wrote:
> 
> The iommu_create_device_direct_mappings() only needs to flush the caches
> when the mappings are changed in the affected domain. This is not true
> for non-DMA domains, or for devices attached to the domain that have no
> reserved regions. To avoid unnecessary cache invalidations, add a check
> before iommu_flush_iotlb_all().

This also fixes a boot failure on Sapphire Rapids built with 
CONFIG_IOMMU_DEFAULT_PASSTHROUGH=y or the equivalent via 
kernel command line parameters. 

> 
> Fixes: a48ce36e2786 ("iommu: Prevent RESV_DIRECT devices from blocking domains")
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by:  Henry Willard <henry.willard@oracle.com>
> ---
> drivers/iommu/iommu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 00d0a2b5d7dc..0cb676590bfa 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -1114,7 +1114,8 @@ static int iommu_create_device_direct_mappings(struct iommu_domain *domain,
> 
> 	}
> 
> -	iommu_flush_iotlb_all(domain);
> +	if (!list_empty(&mappings) && iommu_is_dma_domain(domain))
> +		iommu_flush_iotlb_all(domain);
> 
> out:
> 	iommu_put_resv_regions(dev, &mappings);
> -- 
> 2.34.1
> 
> 


  reply	other threads:[~2023-10-27  4:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26  8:49 [PATCH 1/1] iommu: Avoid unnecessary cache invalidations Lu Baolu
2023-10-27  4:30 ` Henry Willard [this message]
2023-10-27  6:57 ` Joerg Roedel

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=196E8628-C1F4-4392-BFDC-BDA2B0D0835C@oracle.com \
    --to=henry.willard@oracle.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox