All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [GIT PULL] ARM fixes
       [not found] <20140217234644.GA5171@rmk-PC.arm.linux.org.uk>
@ 2014-02-18 23:49   ` Linus Torvalds
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2014-02-18 23:49 UTC (permalink / raw)
  To: Russell King, Linux Kernel Mailing List, linux-mm,
	James Bottomley, Linux SCSI List
  Cc: Andrew Morton, ARM SoC

On Mon, Feb 17, 2014 at 3:46 PM, Russell King <rmk@arm.linux.org.uk> wrote:
>
> One fix touches code outside of arch/arm, which is related to sorting
> out the DMA masks correctly.  There is a long standing issue with the
> conversion from PFNs to addresses where people assume that shifting an
> unsigned long left by PAGE_SHIFT results in a correct address.

You should probably have used PFN_PHYS(), which does this correctly.
Your explicit u64 isn't exactly wrong, but phys_addr_t is really the
right type for the result.

That said, it's admittedly a disgusting name, and I wonder if we
should introduce a nicer-named "pfn_to_phys()" that matches the other
"xyz_to_abc()" functions we have (including "pfn_to_virt()")

Looking at it, the Xen people then do this disgusting thing:
"__va(PFN_PHYS(pfn))" which is both ugly and pointless (__va() isn't
going to work for a phys_addr_t anyway). And <linux/mm.h> has this
gem:

  __va(PFN_PHYS(page_to_pfn(page)));

Ugh. The ugly - it burns. that really should be
"pfn_to_virt(page_to_pfn())", I think.  Adding a few mailing lists in
the hope that some sucker^Whumanitarian person would want to take a
look.

Anyway, I pulled your change to scsi_lib.c, since it's certainly no
worse than what we used to have, but James and company cc'd too.

          Linus

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

* Re: [GIT PULL] ARM fixes
@ 2014-02-18 23:49   ` Linus Torvalds
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2014-02-18 23:49 UTC (permalink / raw)
  To: Russell King, Linux Kernel Mailing List, linux-mm,
	James Bottomley, Linux SCSI List
  Cc: Andrew Morton, ARM SoC

On Mon, Feb 17, 2014 at 3:46 PM, Russell King <rmk@arm.linux.org.uk> wrote:
>
> One fix touches code outside of arch/arm, which is related to sorting
> out the DMA masks correctly.  There is a long standing issue with the
> conversion from PFNs to addresses where people assume that shifting an
> unsigned long left by PAGE_SHIFT results in a correct address.

You should probably have used PFN_PHYS(), which does this correctly.
Your explicit u64 isn't exactly wrong, but phys_addr_t is really the
right type for the result.

That said, it's admittedly a disgusting name, and I wonder if we
should introduce a nicer-named "pfn_to_phys()" that matches the other
"xyz_to_abc()" functions we have (including "pfn_to_virt()")

Looking at it, the Xen people then do this disgusting thing:
"__va(PFN_PHYS(pfn))" which is both ugly and pointless (__va() isn't
going to work for a phys_addr_t anyway). And <linux/mm.h> has this
gem:

  __va(PFN_PHYS(page_to_pfn(page)));

Ugh. The ugly - it burns. that really should be
"pfn_to_virt(page_to_pfn())", I think.  Adding a few mailing lists in
the hope that some sucker^Whumanitarian person would want to take a
look.

Anyway, I pulled your change to scsi_lib.c, since it's certainly no
worse than what we used to have, but James and company cc'd too.

          Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [GIT PULL] ARM fixes
  2014-02-18 23:49   ` Linus Torvalds
@ 2014-02-19  0:03     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 7+ messages in thread
From: Russell King - ARM Linux @ 2014-02-19  0:03 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Linux Kernel Mailing List, linux-mm, James Bottomley,
	Linux SCSI List, Andrew Morton, ARM SoC

On Tue, Feb 18, 2014 at 03:49:03PM -0800, Linus Torvalds wrote:
> On Mon, Feb 17, 2014 at 3:46 PM, Russell King <rmk@arm.linux.org.uk> wrote:
> >
> > One fix touches code outside of arch/arm, which is related to sorting
> > out the DMA masks correctly.  There is a long standing issue with the
> > conversion from PFNs to addresses where people assume that shifting an
> > unsigned long left by PAGE_SHIFT results in a correct address.
> 
> You should probably have used PFN_PHYS(), which does this correctly.
> Your explicit u64 isn't exactly wrong, but phys_addr_t is really the
> right type for the result.

Almost, but not quite.  If we're going to avoid u64, then dma_addr_t
woudl be the right type here because we're talking about DMA addresses.
We could also switch to keeping this as PFNs - block internally converts
it to a PFN anyway:

void blk_queue_bounce_limit(struct request_queue *q, u64 max_addr)
{
        unsigned long b_pfn = max_addr >> PAGE_SHIFT;
...

and that is ultimately assigned to q->limits.bounce_pfn.  So, if we
arranged for blk_queue_bounce_limit() to take a PFN, and then modified
it's two callers, then we don't need to care about converting between
phys and pfns.

Maybe blk_queue_bounce_pfn_limit() so we ensure all users get caught?

> That said, it's admittedly a disgusting name, and I wonder if we
> should introduce a nicer-named "pfn_to_phys()" that matches the other
> "xyz_to_abc()" functions we have (including "pfn_to_virt()")

We have these on ARM:

arch/arm/include/asm/memory.h:#define	__pfn_to_phys(pfn)	((phys_addr_t)(pfn) << PAGE_SHIFT)
arch/arm/include/asm/memory.h:#define	__phys_to_pfn(paddr)	((unsigned long)((paddr) >> PAGE_SHIFT))

it probably makes sense to pick those right out, maybe losing the
__ prefix on them.

> Looking at it, the Xen people then do this disgusting thing:
> "__va(PFN_PHYS(pfn))" which is both ugly and pointless (__va() isn't
> going to work for a phys_addr_t anyway). And <linux/mm.h> has this
> gem:
> 
>   __va(PFN_PHYS(page_to_pfn(page)));

Wow.  Two things spring to mind there... highmem pages, and don't we
already have page_address() for that?

> Anyway, I pulled your change to scsi_lib.c, since it's certainly no
> worse than what we used to have, but James and company cc'd too.

Thanks.  I do worry about all the other places which I also found -
but the first step is getting concensus on what the macro should be.

-- 
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".

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

* Re: [GIT PULL] ARM fixes
@ 2014-02-19  0:03     ` Russell King - ARM Linux
  0 siblings, 0 replies; 7+ messages in thread
From: Russell King - ARM Linux @ 2014-02-19  0:03 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Linux Kernel Mailing List, linux-mm, James Bottomley,
	Linux SCSI List, Andrew Morton, ARM SoC

On Tue, Feb 18, 2014 at 03:49:03PM -0800, Linus Torvalds wrote:
> On Mon, Feb 17, 2014 at 3:46 PM, Russell King <rmk@arm.linux.org.uk> wrote:
> >
> > One fix touches code outside of arch/arm, which is related to sorting
> > out the DMA masks correctly.  There is a long standing issue with the
> > conversion from PFNs to addresses where people assume that shifting an
> > unsigned long left by PAGE_SHIFT results in a correct address.
> 
> You should probably have used PFN_PHYS(), which does this correctly.
> Your explicit u64 isn't exactly wrong, but phys_addr_t is really the
> right type for the result.

Almost, but not quite.  If we're going to avoid u64, then dma_addr_t
woudl be the right type here because we're talking about DMA addresses.
We could also switch to keeping this as PFNs - block internally converts
it to a PFN anyway:

void blk_queue_bounce_limit(struct request_queue *q, u64 max_addr)
{
        unsigned long b_pfn = max_addr >> PAGE_SHIFT;
...

and that is ultimately assigned to q->limits.bounce_pfn.  So, if we
arranged for blk_queue_bounce_limit() to take a PFN, and then modified
it's two callers, then we don't need to care about converting between
phys and pfns.

Maybe blk_queue_bounce_pfn_limit() so we ensure all users get caught?

> That said, it's admittedly a disgusting name, and I wonder if we
> should introduce a nicer-named "pfn_to_phys()" that matches the other
> "xyz_to_abc()" functions we have (including "pfn_to_virt()")

We have these on ARM:

arch/arm/include/asm/memory.h:#define	__pfn_to_phys(pfn)	((phys_addr_t)(pfn) << PAGE_SHIFT)
arch/arm/include/asm/memory.h:#define	__phys_to_pfn(paddr)	((unsigned long)((paddr) >> PAGE_SHIFT))

it probably makes sense to pick those right out, maybe losing the
__ prefix on them.

> Looking at it, the Xen people then do this disgusting thing:
> "__va(PFN_PHYS(pfn))" which is both ugly and pointless (__va() isn't
> going to work for a phys_addr_t anyway). And <linux/mm.h> has this
> gem:
> 
>   __va(PFN_PHYS(page_to_pfn(page)));

Wow.  Two things spring to mind there... highmem pages, and don't we
already have page_address() for that?

> Anyway, I pulled your change to scsi_lib.c, since it's certainly no
> worse than what we used to have, but James and company cc'd too.

Thanks.  I do worry about all the other places which I also found -
but the first step is getting concensus on what the macro should be.

-- 
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [GIT PULL] ARM fixes
  2014-02-19  0:03     ` Russell King - ARM Linux
@ 2014-02-19  0:23       ` Linus Torvalds
  -1 siblings, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2014-02-19  0:23 UTC (permalink / raw)
  To: Russell King - ARM Linux, Konrad Rzeszutek Wilk
  Cc: Linux Kernel Mailing List, linux-mm, James Bottomley,
	Linux SCSI List, Andrew Morton, ARM SoC, xen-devel

On Tue, Feb 18, 2014 at 4:03 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
>
> Almost, but not quite.  If we're going to avoid u64, then dma_addr_t
> woudl be the right type here because we're talking about DMA addresses.

Well, phys_addr_t had better be as big as dma_addr_t, because that's
what the resource management handles.

> We could also switch to keeping this as PFNs - block internally converts
> it to a PFN anyway:

Yeah, that definitely sounds like it would be a good idea.

> Maybe blk_queue_bounce_pfn_limit() so we ensure all users get caught?
>
>> That said, it's admittedly a disgusting name, and I wonder if we
>> should introduce a nicer-named "pfn_to_phys()" that matches the other
>> "xyz_to_abc()" functions we have (including "pfn_to_virt()")
>
> We have these on ARM:
>
> arch/arm/include/asm/memory.h:#define   __pfn_to_phys(pfn)      ((phys_addr_t)(pfn) << PAGE_SHIFT)
> arch/arm/include/asm/memory.h:#define   __phys_to_pfn(paddr)    ((unsigned long)((paddr) >> PAGE_SHIFT))
>
> it probably makes sense to pick those right out, maybe losing the
> __ prefix on them.

Yup.

>>   __va(PFN_PHYS(page_to_pfn(page)));
>
> Wow.  Two things spring to mind there... highmem pages, and don't we
> already have page_address() for that?

Well, that code clearly cannot handle highmem anyway, but yes, it
really smells like xen should use page_address().

Adding Xen people who I didn't add the last time around.

             Linus

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

* Re: [GIT PULL] ARM fixes
@ 2014-02-19  0:23       ` Linus Torvalds
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2014-02-19  0:23 UTC (permalink / raw)
  To: Russell King - ARM Linux, Konrad Rzeszutek Wilk
  Cc: Linux Kernel Mailing List, linux-mm, James Bottomley,
	Linux SCSI List, Andrew Morton, ARM SoC, xen-devel

On Tue, Feb 18, 2014 at 4:03 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
>
> Almost, but not quite.  If we're going to avoid u64, then dma_addr_t
> woudl be the right type here because we're talking about DMA addresses.

Well, phys_addr_t had better be as big as dma_addr_t, because that's
what the resource management handles.

> We could also switch to keeping this as PFNs - block internally converts
> it to a PFN anyway:

Yeah, that definitely sounds like it would be a good idea.

> Maybe blk_queue_bounce_pfn_limit() so we ensure all users get caught?
>
>> That said, it's admittedly a disgusting name, and I wonder if we
>> should introduce a nicer-named "pfn_to_phys()" that matches the other
>> "xyz_to_abc()" functions we have (including "pfn_to_virt()")
>
> We have these on ARM:
>
> arch/arm/include/asm/memory.h:#define   __pfn_to_phys(pfn)      ((phys_addr_t)(pfn) << PAGE_SHIFT)
> arch/arm/include/asm/memory.h:#define   __phys_to_pfn(paddr)    ((unsigned long)((paddr) >> PAGE_SHIFT))
>
> it probably makes sense to pick those right out, maybe losing the
> __ prefix on them.

Yup.

>>   __va(PFN_PHYS(page_to_pfn(page)));
>
> Wow.  Two things spring to mind there... highmem pages, and don't we
> already have page_address() for that?

Well, that code clearly cannot handle highmem anyway, but yes, it
really smells like xen should use page_address().

Adding Xen people who I didn't add the last time around.

             Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [GIT PULL] ARM fixes
  2014-02-19  0:03     ` Russell King - ARM Linux
  (?)
  (?)
@ 2014-02-19  0:23     ` Linus Torvalds
  -1 siblings, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2014-02-19  0:23 UTC (permalink / raw)
  To: Russell King - ARM Linux, Konrad Rzeszutek Wilk
  Cc: Linux SCSI List, James Bottomley, Linux Kernel Mailing List,
	linux-mm, ARM SoC, xen-devel, Andrew Morton

On Tue, Feb 18, 2014 at 4:03 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
>
> Almost, but not quite.  If we're going to avoid u64, then dma_addr_t
> woudl be the right type here because we're talking about DMA addresses.

Well, phys_addr_t had better be as big as dma_addr_t, because that's
what the resource management handles.

> We could also switch to keeping this as PFNs - block internally converts
> it to a PFN anyway:

Yeah, that definitely sounds like it would be a good idea.

> Maybe blk_queue_bounce_pfn_limit() so we ensure all users get caught?
>
>> That said, it's admittedly a disgusting name, and I wonder if we
>> should introduce a nicer-named "pfn_to_phys()" that matches the other
>> "xyz_to_abc()" functions we have (including "pfn_to_virt()")
>
> We have these on ARM:
>
> arch/arm/include/asm/memory.h:#define   __pfn_to_phys(pfn)      ((phys_addr_t)(pfn) << PAGE_SHIFT)
> arch/arm/include/asm/memory.h:#define   __phys_to_pfn(paddr)    ((unsigned long)((paddr) >> PAGE_SHIFT))
>
> it probably makes sense to pick those right out, maybe losing the
> __ prefix on them.

Yup.

>>   __va(PFN_PHYS(page_to_pfn(page)));
>
> Wow.  Two things spring to mind there... highmem pages, and don't we
> already have page_address() for that?

Well, that code clearly cannot handle highmem anyway, but yes, it
really smells like xen should use page_address().

Adding Xen people who I didn't add the last time around.

             Linus

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

end of thread, other threads:[~2014-02-19  0:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20140217234644.GA5171@rmk-PC.arm.linux.org.uk>
2014-02-18 23:49 ` [GIT PULL] ARM fixes Linus Torvalds
2014-02-18 23:49   ` Linus Torvalds
2014-02-19  0:03   ` Russell King - ARM Linux
2014-02-19  0:03     ` Russell King - ARM Linux
2014-02-19  0:23     ` Linus Torvalds
2014-02-19  0:23       ` Linus Torvalds
2014-02-19  0:23     ` Linus Torvalds

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.