iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Lu Baolu <baolu.lu@linux.intel.com>,
	Joerg Roedel <joro@8bytes.org>, Tom Murphy <murphyt7@tcd.ie>,
	David Woodhouse <dwmw2@infradead.org>,
	Christoph Hellwig <hch@infradead.org>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	Intel-gfx@lists.freedesktop.org, Ashok Raj <ashok.raj@intel.com>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/7] iommu: Add quirk for Intel graphic devices in map_sg
Date: Tue, 3 Nov 2020 12:00:33 +0000	[thread overview]
Message-ID: <281f22ed-8b36-fc20-4b08-27ef168f941d@arm.com> (raw)
In-Reply-To: <20200927063437.13988-5-baolu.lu@linux.intel.com>

On 2020-09-27 07:34, Lu Baolu wrote:
> Combining the sg segments exposes a bug in the Intel i915 driver which
> causes visual artifacts and the screen to freeze. This is most likely
> because of how the i915 handles the returned list. It probably doesn't
> respect the returned value specifying the number of elements in the list
> and instead depends on the previous behaviour of the Intel iommu driver
> which would return the same number of elements in the output list as in
> the input list.
> 
> Signed-off-by: Tom Murphy <murphyt7@tcd.ie>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>   drivers/iommu/dma-iommu.c | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 3526db774611..e7e4d758f51a 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -879,6 +879,33 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,
>   	unsigned int cur_len = 0, max_len = dma_get_max_seg_size(dev);
>   	int i, count = 0;
>   
> +	/*
> +	 * The Intel graphic driver is used to assume that the returned
> +	 * sg list is not combound. This blocks the efforts of converting
> +	 * Intel IOMMU driver to dma-iommu api's. Add this quirk to make the
> +	 * device driver work and should be removed once it's fixed in i915
> +	 * driver.
> +	 */
> +	if (IS_ENABLED(CONFIG_DRM_I915) && dev_is_pci(dev) &&
> +	    to_pci_dev(dev)->vendor == PCI_VENDOR_ID_INTEL &&
> +	    (to_pci_dev(dev)->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
> +		for_each_sg(sg, s, nents, i) {
> +			unsigned int s_iova_off = sg_dma_address(s);
> +			unsigned int s_length = sg_dma_len(s);
> +			unsigned int s_iova_len = s->length;
> +
> +			s->offset += s_iova_off;
> +			s->length = s_length;
> +			sg_dma_address(s) = dma_addr + s_iova_off;
> +			sg_dma_len(s) = s_length;
> +			dma_addr += s_iova_len;
> +
> +			pr_info_once("sg combining disabled due to i915 driver\n");
> +		}
> +
> +		return nents;
> +	}

BTW, a much less invasive workaround would be to simply override 
seg_mask to 0. That's enough to make sure that no segment looks eligible 
for merging.

Robin.

> +
>   	for_each_sg(sg, s, nents, i) {
>   		/* Restore this segment's original unaligned fields first */
>   		unsigned int s_iova_off = sg_dma_address(s);
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2020-11-03 12:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-27  6:34 [PATCH v4 0/7] Convert the intel iommu driver to the dma-iommu api Lu Baolu
2020-09-27  6:34 ` [PATCH v4 1/7] iommu: Handle freelists when using deferred flushing in iommu drivers Lu Baolu
2020-09-27  6:34 ` [PATCH v4 2/7] iommu: Add iommu_dma_free_cpu_cached_iovas() Lu Baolu
2020-09-27  6:34 ` [PATCH v4 3/7] iommu: Allow the dma-iommu api to use bounce buffers Lu Baolu
2020-09-27  6:34 ` [PATCH v4 4/7] iommu: Add quirk for Intel graphic devices in map_sg Lu Baolu
2020-11-03 12:00   ` Robin Murphy [this message]
2020-09-27  6:34 ` [PATCH v4 5/7] iommu/vt-d: Update domain geometry in iommu_ops.at(de)tach_dev Lu Baolu
2020-09-27  6:34 ` [PATCH v4 6/7] iommu/vt-d: Convert intel iommu driver to the iommu ops Lu Baolu
2020-09-27  6:34 ` [PATCH v4 7/7] iommu/vt-d: Cleanup after converting to dma-iommu ops Lu Baolu
2020-09-28  9:44 ` [PATCH v4 0/7] Convert the intel iommu driver to the dma-iommu api Tvrtko Ursulin
2020-09-29  0:11   ` Lu Baolu
2020-10-01 12:17     ` Joerg Roedel
2020-10-02 11:59       ` Lu Baolu
2020-10-12  8:44     ` Tvrtko Ursulin
2020-10-13  0:32       ` Lu Baolu
2020-11-02  2:00       ` Lu Baolu
2020-11-02 11:52         ` Tvrtko Ursulin
2020-11-03  2:53           ` Lu Baolu
2020-11-03  9:14             ` Tvrtko Ursulin
2020-11-03  9:58               ` Joonas Lahtinen
2020-11-03 10:54                 ` Joerg Roedel
2020-11-20 10:20                   ` Lu Baolu
2020-10-01 21:17 ` Logan Gunthorpe

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=281f22ed-8b36-fc20-4b08-27ef168f941d@arm.com \
    --to=robin.murphy@arm.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=ashok.raj@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=hch@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=murphyt7@tcd.ie \
    --cc=tvrtko.ursulin@linux.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 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).