From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
To: Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
sakari.ailus-X3B1VOXEql0@public.gmane.org,
Shuah Khan <shuahkhan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [RFC/PATCH] media: omap3isp: Set maximum DMA segment size
Date: Mon, 9 Nov 2015 15:27:04 +0000 [thread overview]
Message-ID: <5640BB48.60706@arm.com> (raw)
In-Reply-To: <1560214.1Y1q0qLZA4@avalon>
Hi Laurent,
On 09/11/15 14:18, Laurent Pinchart wrote:
> Hello everybody,
>
> Ping ?
Apologies, I did start writing a response a while ago, but it ended up
getting subsumed into the bigger DMA API discussion thread.
> On Tuesday 13 October 2015 16:18:36 Laurent Pinchart wrote:
>> The maximum DMA segment size controls the IOMMU mapping granularity. Its
>> default value is 64kB, resulting in potentially non-contiguous IOMMU
>> mappings. Configure it to 4GB to ensure that buffers get mapped
>> contiguously.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
>> ---
>> drivers/media/platform/omap3isp/isp.c | 4 ++++
>> drivers/media/platform/omap3isp/isp.h | 1 +
>> 2 files changed, 5 insertions(+)
>>
>> I'm posting this as an RFC because I'm not happy with the patch, even if it
>> gets the job done.
>>
>> On ARM the maximum DMA segment size is used when creating IOMMU mappings. As
>> a large number of devices require contiguous memory buffers (this is a very
>> common requirement for video-related embedded devices) the default 64kB
>> value doesn't work.
Per the initial patch (6b7b65105522), dma_parms was intended to expose
hardware limitations of scatter-gather-capable devices, to prevent DMA
API implementations from merging segments beyond a device's limits. Thus
the way 32-bit ARM (and seemingly noone else) is taking it as something
to apply to non-scatter-gather-capable devices in order to force the DMA
API implementation to merge segments seems very questionable.
There's nothing in the streaming DMA API which gives any guarantee of a
contiguous mapping, so it's the incorrect assumption that it does which
needs fixing. Whether we rework the callers or the API itself is the
open question there, I think.
>> I haven't investigated the history behind this API in details but I have a
>> feeling something is not quite right. We force most drivers to explicitly
>> set the maximum segment size from a default that seems valid for specific
>> use cases only. Furthermore, as the DMA parameters are not stored directly
>> in struct device this require allocation of external memory for which we
>> have no proper management rule, making automatic handling of the DMA
>> parameters in frameworks or helper functions cumbersome (for a discussion
>> on this topic see http://www.spinics.net/lists/linux-media/msg92467.html
>> and http://lists.infradead.org/pipermail/linux-arm-kernel/2014-> November/305913.html).
>>
>> Is it time to fix this mess ?
I agree that it would certainly be preferable to tackle the underlying
issue instead of adding more point hacks to further entrench
non-portable code into the kernel. In terms of modifying the API, the
most reasonable idea which comes to mind would be a DMA attribute, and
on closer inspection, I see that DMA_ATTR_FORCE_CONTIGUOUS is already a
thing - perhaps we should weigh up whether coherent and streaming DMA
could overload the same attribute with subtly different meanings, or
whether we'd want e.g. DMA_ATTR_FORCE_PHYS_CONTIGUOUS and
DMA_ATTR_FORCE_DMA_CONTIGUOUS to coexist.
Robin.
>> diff --git a/drivers/media/platform/omap3isp/isp.c
>> b/drivers/media/platform/omap3isp/isp.c index 17430a6ed85a..ebf7dc76e94d
>> 100644
>> --- a/drivers/media/platform/omap3isp/isp.c
>> +++ b/drivers/media/platform/omap3isp/isp.c
>> @@ -2444,6 +2444,10 @@ static int isp_probe(struct platform_device *pdev)
>> if (ret)
>> goto error;
>>
>> + isp->dev->dma_parms = &isp->dma_parms;
>> + dma_set_max_seg_size(isp->dev, DMA_BIT_MASK(32));
>> + dma_set_seg_boundary(isp->dev, 0xffffffff);
Whatever happens, 002edb6f6f2a should now make this line redundant :D
>> +
>> platform_set_drvdata(pdev, isp);
>>
>> /* Regulators */
>> diff --git a/drivers/media/platform/omap3isp/isp.h
>> b/drivers/media/platform/omap3isp/isp.h index e579943175c4..4b2231cf01be
>> 100644
>> --- a/drivers/media/platform/omap3isp/isp.h
>> +++ b/drivers/media/platform/omap3isp/isp.h
>> @@ -193,6 +193,7 @@ struct isp_device {
>> u32 syscon_offset;
>> u32 phy_type;
>>
>> + struct device_dma_parameters dma_parms;
>> struct dma_iommu_mapping *mapping;
>>
>> /* ISP Obj */
>
WARNING: multiple messages have this Message-ID (diff)
From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC/PATCH] media: omap3isp: Set maximum DMA segment size
Date: Mon, 9 Nov 2015 15:27:04 +0000 [thread overview]
Message-ID: <5640BB48.60706@arm.com> (raw)
In-Reply-To: <1560214.1Y1q0qLZA4@avalon>
Hi Laurent,
On 09/11/15 14:18, Laurent Pinchart wrote:
> Hello everybody,
>
> Ping ?
Apologies, I did start writing a response a while ago, but it ended up
getting subsumed into the bigger DMA API discussion thread.
> On Tuesday 13 October 2015 16:18:36 Laurent Pinchart wrote:
>> The maximum DMA segment size controls the IOMMU mapping granularity. Its
>> default value is 64kB, resulting in potentially non-contiguous IOMMU
>> mappings. Configure it to 4GB to ensure that buffers get mapped
>> contiguously.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> ---
>> drivers/media/platform/omap3isp/isp.c | 4 ++++
>> drivers/media/platform/omap3isp/isp.h | 1 +
>> 2 files changed, 5 insertions(+)
>>
>> I'm posting this as an RFC because I'm not happy with the patch, even if it
>> gets the job done.
>>
>> On ARM the maximum DMA segment size is used when creating IOMMU mappings. As
>> a large number of devices require contiguous memory buffers (this is a very
>> common requirement for video-related embedded devices) the default 64kB
>> value doesn't work.
Per the initial patch (6b7b65105522), dma_parms was intended to expose
hardware limitations of scatter-gather-capable devices, to prevent DMA
API implementations from merging segments beyond a device's limits. Thus
the way 32-bit ARM (and seemingly noone else) is taking it as something
to apply to non-scatter-gather-capable devices in order to force the DMA
API implementation to merge segments seems very questionable.
There's nothing in the streaming DMA API which gives any guarantee of a
contiguous mapping, so it's the incorrect assumption that it does which
needs fixing. Whether we rework the callers or the API itself is the
open question there, I think.
>> I haven't investigated the history behind this API in details but I have a
>> feeling something is not quite right. We force most drivers to explicitly
>> set the maximum segment size from a default that seems valid for specific
>> use cases only. Furthermore, as the DMA parameters are not stored directly
>> in struct device this require allocation of external memory for which we
>> have no proper management rule, making automatic handling of the DMA
>> parameters in frameworks or helper functions cumbersome (for a discussion
>> on this topic see http://www.spinics.net/lists/linux-media/msg92467.html
>> and http://lists.infradead.org/pipermail/linux-arm-kernel/2014-> November/305913.html).
>>
>> Is it time to fix this mess ?
I agree that it would certainly be preferable to tackle the underlying
issue instead of adding more point hacks to further entrench
non-portable code into the kernel. In terms of modifying the API, the
most reasonable idea which comes to mind would be a DMA attribute, and
on closer inspection, I see that DMA_ATTR_FORCE_CONTIGUOUS is already a
thing - perhaps we should weigh up whether coherent and streaming DMA
could overload the same attribute with subtly different meanings, or
whether we'd want e.g. DMA_ATTR_FORCE_PHYS_CONTIGUOUS and
DMA_ATTR_FORCE_DMA_CONTIGUOUS to coexist.
Robin.
>> diff --git a/drivers/media/platform/omap3isp/isp.c
>> b/drivers/media/platform/omap3isp/isp.c index 17430a6ed85a..ebf7dc76e94d
>> 100644
>> --- a/drivers/media/platform/omap3isp/isp.c
>> +++ b/drivers/media/platform/omap3isp/isp.c
>> @@ -2444,6 +2444,10 @@ static int isp_probe(struct platform_device *pdev)
>> if (ret)
>> goto error;
>>
>> + isp->dev->dma_parms = &isp->dma_parms;
>> + dma_set_max_seg_size(isp->dev, DMA_BIT_MASK(32));
>> + dma_set_seg_boundary(isp->dev, 0xffffffff);
Whatever happens, 002edb6f6f2a should now make this line redundant :D
>> +
>> platform_set_drvdata(pdev, isp);
>>
>> /* Regulators */
>> diff --git a/drivers/media/platform/omap3isp/isp.h
>> b/drivers/media/platform/omap3isp/isp.h index e579943175c4..4b2231cf01be
>> 100644
>> --- a/drivers/media/platform/omap3isp/isp.h
>> +++ b/drivers/media/platform/omap3isp/isp.h
>> @@ -193,6 +193,7 @@ struct isp_device {
>> u32 syscon_offset;
>> u32 phy_type;
>>
>> + struct device_dma_parameters dma_parms;
>> struct dma_iommu_mapping *mapping;
>>
>> /* ISP Obj */
>
WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
linux-media@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
Marek Szyprowski <m.szyprowski@samsung.com>,
Lars-Peter Clausen <lars@metafoo.de>,
sakari.ailus@iki.fi, Shuah Khan <shuahkhan@gmail.com>
Subject: Re: [RFC/PATCH] media: omap3isp: Set maximum DMA segment size
Date: Mon, 9 Nov 2015 15:27:04 +0000 [thread overview]
Message-ID: <5640BB48.60706@arm.com> (raw)
In-Reply-To: <1560214.1Y1q0qLZA4@avalon>
Hi Laurent,
On 09/11/15 14:18, Laurent Pinchart wrote:
> Hello everybody,
>
> Ping ?
Apologies, I did start writing a response a while ago, but it ended up
getting subsumed into the bigger DMA API discussion thread.
> On Tuesday 13 October 2015 16:18:36 Laurent Pinchart wrote:
>> The maximum DMA segment size controls the IOMMU mapping granularity. Its
>> default value is 64kB, resulting in potentially non-contiguous IOMMU
>> mappings. Configure it to 4GB to ensure that buffers get mapped
>> contiguously.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> ---
>> drivers/media/platform/omap3isp/isp.c | 4 ++++
>> drivers/media/platform/omap3isp/isp.h | 1 +
>> 2 files changed, 5 insertions(+)
>>
>> I'm posting this as an RFC because I'm not happy with the patch, even if it
>> gets the job done.
>>
>> On ARM the maximum DMA segment size is used when creating IOMMU mappings. As
>> a large number of devices require contiguous memory buffers (this is a very
>> common requirement for video-related embedded devices) the default 64kB
>> value doesn't work.
Per the initial patch (6b7b65105522), dma_parms was intended to expose
hardware limitations of scatter-gather-capable devices, to prevent DMA
API implementations from merging segments beyond a device's limits. Thus
the way 32-bit ARM (and seemingly noone else) is taking it as something
to apply to non-scatter-gather-capable devices in order to force the DMA
API implementation to merge segments seems very questionable.
There's nothing in the streaming DMA API which gives any guarantee of a
contiguous mapping, so it's the incorrect assumption that it does which
needs fixing. Whether we rework the callers or the API itself is the
open question there, I think.
>> I haven't investigated the history behind this API in details but I have a
>> feeling something is not quite right. We force most drivers to explicitly
>> set the maximum segment size from a default that seems valid for specific
>> use cases only. Furthermore, as the DMA parameters are not stored directly
>> in struct device this require allocation of external memory for which we
>> have no proper management rule, making automatic handling of the DMA
>> parameters in frameworks or helper functions cumbersome (for a discussion
>> on this topic see http://www.spinics.net/lists/linux-media/msg92467.html
>> and http://lists.infradead.org/pipermail/linux-arm-kernel/2014-> November/305913.html).
>>
>> Is it time to fix this mess ?
I agree that it would certainly be preferable to tackle the underlying
issue instead of adding more point hacks to further entrench
non-portable code into the kernel. In terms of modifying the API, the
most reasonable idea which comes to mind would be a DMA attribute, and
on closer inspection, I see that DMA_ATTR_FORCE_CONTIGUOUS is already a
thing - perhaps we should weigh up whether coherent and streaming DMA
could overload the same attribute with subtly different meanings, or
whether we'd want e.g. DMA_ATTR_FORCE_PHYS_CONTIGUOUS and
DMA_ATTR_FORCE_DMA_CONTIGUOUS to coexist.
Robin.
>> diff --git a/drivers/media/platform/omap3isp/isp.c
>> b/drivers/media/platform/omap3isp/isp.c index 17430a6ed85a..ebf7dc76e94d
>> 100644
>> --- a/drivers/media/platform/omap3isp/isp.c
>> +++ b/drivers/media/platform/omap3isp/isp.c
>> @@ -2444,6 +2444,10 @@ static int isp_probe(struct platform_device *pdev)
>> if (ret)
>> goto error;
>>
>> + isp->dev->dma_parms = &isp->dma_parms;
>> + dma_set_max_seg_size(isp->dev, DMA_BIT_MASK(32));
>> + dma_set_seg_boundary(isp->dev, 0xffffffff);
Whatever happens, 002edb6f6f2a should now make this line redundant :D
>> +
>> platform_set_drvdata(pdev, isp);
>>
>> /* Regulators */
>> diff --git a/drivers/media/platform/omap3isp/isp.h
>> b/drivers/media/platform/omap3isp/isp.h index e579943175c4..4b2231cf01be
>> 100644
>> --- a/drivers/media/platform/omap3isp/isp.h
>> +++ b/drivers/media/platform/omap3isp/isp.h
>> @@ -193,6 +193,7 @@ struct isp_device {
>> u32 syscon_offset;
>> u32 phy_type;
>>
>> + struct device_dma_parameters dma_parms;
>> struct dma_iommu_mapping *mapping;
>>
>> /* ISP Obj */
>
next prev parent reply other threads:[~2015-11-09 15:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-13 13:18 [RFC/PATCH] media: omap3isp: Set maximum DMA segment size Laurent Pinchart
2015-10-13 13:18 ` Laurent Pinchart
2015-10-13 13:18 ` Laurent Pinchart
[not found] ` <1444742316-27986-1-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2015-11-09 14:18 ` Laurent Pinchart
2015-11-09 14:18 ` Laurent Pinchart
2015-11-09 14:18 ` Laurent Pinchart
2015-11-09 15:27 ` Robin Murphy [this message]
2015-11-09 15:27 ` Robin Murphy
2015-11-09 15:27 ` Robin Murphy
2015-11-17 12:15 ` Marek Szyprowski
2015-11-17 12:15 ` Marek Szyprowski
2015-11-17 12:15 ` Marek Szyprowski
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=5640BB48.60706@arm.com \
--to=robin.murphy-5wv7dgnigg8@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sakari.ailus-X3B1VOXEql0@public.gmane.org \
--cc=shuahkhan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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.