linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* memcpy alignment for DEVICE_nGnRnE
       [not found] <53072343.4080505@marvell.com>
@ 2014-02-21 10:53 ` Catalin Marinas
  2014-04-08  0:35   ` Michael Bohan
  0 siblings, 1 reply; 5+ messages in thread
From: Catalin Marinas @ 2014-02-21 10:53 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Zhou,

On Fri, Feb 21, 2014 at 09:58:27AM +0000, Zhou Zhu wrote:
> We faced one issue using memcpy for memory type DEVICE_nGnRnE 
> (pgprot_noncached). If the address is not aligned, exception would 
> happen due to the alignment of this type could not be handled by hardware.

Indeed, that's expected. This memory type is the equivalent of Strongly
Ordered.

> Is there any plan and ongoing patch to support this or we need to keep 
> address aligned for memcpy using pgprot_noncached memory in drivers?

You either change the memory type to pgprot_writecombine() or use the
right API (memcpy_toio/memcpy_fromio, these could be further optimised,
similar to powerpc for example, but I didn't get there yet).

-- 
Catalin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* memcpy alignment for DEVICE_nGnRnE
  2014-02-21 10:53 ` memcpy alignment for DEVICE_nGnRnE Catalin Marinas
@ 2014-04-08  0:35   ` Michael Bohan
  2014-04-08 11:49     ` Catalin Marinas
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Bohan @ 2014-04-08  0:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Catalin,

On Fri, Feb 21, 2014 at 10:53:08AM +0000, Catalin Marinas wrote:
> On Fri, Feb 21, 2014 at 09:58:27AM +0000, Zhou Zhu wrote:
> > We faced one issue using memcpy for memory type DEVICE_nGnRnE 
> > (pgprot_noncached). If the address is not aligned, exception would 
> > happen due to the alignment of this type could not be handled by hardware.
> 
> Indeed, that's expected. This memory type is the equivalent of Strongly
> Ordered.
> 
> > Is there any plan and ongoing patch to support this or we need to keep 
> > address aligned for memcpy using pgprot_noncached memory in drivers?
> 
> You either change the memory type to pgprot_writecombine() or use the
> right API (memcpy_toio/memcpy_fromio, these could be further optimised,
> similar to powerpc for example, but I didn't get there yet).

How should we handle Device Memory with copy_from_user / copy_to_user?
Should we follow the same scheme and create
copy_from_user_io / copy_to_user_io, or rather enforce that the stock
routines handle alignment?

Thanks,
Mike

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 5+ messages in thread

* memcpy alignment for DEVICE_nGnRnE
  2014-04-08  0:35   ` Michael Bohan
@ 2014-04-08 11:49     ` Catalin Marinas
  2014-04-08 23:39       ` Michael Bohan
  0 siblings, 1 reply; 5+ messages in thread
From: Catalin Marinas @ 2014-04-08 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 08, 2014 at 01:35:47AM +0100, Michael Bohan wrote:
> On Fri, Feb 21, 2014 at 10:53:08AM +0000, Catalin Marinas wrote:
> > On Fri, Feb 21, 2014 at 09:58:27AM +0000, Zhou Zhu wrote:
> > > We faced one issue using memcpy for memory type DEVICE_nGnRnE 
> > > (pgprot_noncached). If the address is not aligned, exception would 
> > > happen due to the alignment of this type could not be handled by hardware.
> > 
> > Indeed, that's expected. This memory type is the equivalent of Strongly
> > Ordered.
> > 
> > > Is there any plan and ongoing patch to support this or we need to keep 
> > > address aligned for memcpy using pgprot_noncached memory in drivers?
> > 
> > You either change the memory type to pgprot_writecombine() or use the
> > right API (memcpy_toio/memcpy_fromio, these could be further optimised,
> > similar to powerpc for example, but I didn't get there yet).
> 
> How should we handle Device Memory with copy_from_user / copy_to_user?
> Should we follow the same scheme and create
> copy_from_user_io / copy_to_user_io, or rather enforce that the stock
> routines handle alignment?

We have generic copy_from_user_toio() and copy_to_user_fromio(). Are
these what you need? As with the memcpy_(to|from)io, they can be further
optimised.

-- 
Catalin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* memcpy alignment for DEVICE_nGnRnE
  2014-04-08 11:49     ` Catalin Marinas
@ 2014-04-08 23:39       ` Michael Bohan
  2014-04-09  8:17         ` Catalin Marinas
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Bohan @ 2014-04-08 23:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 08, 2014 at 12:49:49PM +0100, Catalin Marinas wrote:
> On Tue, Apr 08, 2014 at 01:35:47AM +0100, Michael Bohan wrote:
> > How should we handle Device Memory with copy_from_user / copy_to_user?
> > Should we follow the same scheme and create
> > copy_from_user_io / copy_to_user_io, or rather enforce that the stock
> > routines handle alignment?
> 
> We have generic copy_from_user_toio() and copy_to_user_fromio(). Are
> these what you need? As with the memcpy_(to|from)io, they can be further
> optimised.

It seems these existing routines are in sound. Were you thinking
the right approach would be to move them out of sound and make
them per-arch defined?

What about the other two use cases: copy_from_user_fromio and
copy_to_user_toio? Are those reasonable to add? These two APIs
would cover the use case I had in mind.

Then what about the strange but possible use case where both the
source and destination pointers are iomem? This same question
applies for memcpy_fromio / memcpy_toio as well.

The implementations of copy_from_user_toio and
copy_to_user_fromio are currently doing a second copy, so that
seems bad for performance. We'd probably want to improve these as
well if others are in agreement.

Thanks,
Mike
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 5+ messages in thread

* memcpy alignment for DEVICE_nGnRnE
  2014-04-08 23:39       ` Michael Bohan
@ 2014-04-09  8:17         ` Catalin Marinas
  0 siblings, 0 replies; 5+ messages in thread
From: Catalin Marinas @ 2014-04-09  8:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 09, 2014 at 12:39:37AM +0100, Michael Bohan wrote:
> On Tue, Apr 08, 2014 at 12:49:49PM +0100, Catalin Marinas wrote:
> > On Tue, Apr 08, 2014 at 01:35:47AM +0100, Michael Bohan wrote:
> > > How should we handle Device Memory with copy_from_user / copy_to_user?
> > > Should we follow the same scheme and create
> > > copy_from_user_io / copy_to_user_io, or rather enforce that the stock
> > > routines handle alignment?
> > 
> > We have generic copy_from_user_toio() and copy_to_user_fromio(). Are
> > these what you need? As with the memcpy_(to|from)io, they can be further
> > optimised.
> 
> It seems these existing routines are in sound. Were you thinking
> the right approach would be to move them out of sound and make
> them per-arch defined?

If you have a use-case outside of the sound subsystem, they can be made
more generic.

> What about the other two use cases: copy_from_user_fromio and
> copy_to_user_toio? Are those reasonable to add? These two APIs
> would cover the use case I had in mind.

What's the use case for these?

> Then what about the strange but possible use case where both the
> source and destination pointers are iomem? This same question
> applies for memcpy_fromio / memcpy_toio as well.

You can come up with many combinations but we first need to see a real
use of them, eliminate the alternatives and only then look at adding new
API.

> The implementations of copy_from_user_toio and
> copy_to_user_fromio are currently doing a second copy, so that
> seems bad for performance. We'd probably want to improve these as
> well if others are in agreement.

Yes, as I said they are not optimised (but good enough as a start).

-- 
Catalin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-09  8:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <53072343.4080505@marvell.com>
2014-02-21 10:53 ` memcpy alignment for DEVICE_nGnRnE Catalin Marinas
2014-04-08  0:35   ` Michael Bohan
2014-04-08 11:49     ` Catalin Marinas
2014-04-08 23:39       ` Michael Bohan
2014-04-09  8:17         ` Catalin Marinas

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).