public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
@ 2011-10-21 21:42 Luck, Tony
  2011-10-25  2:48 ` Huang Ying
  2011-10-28  0:17 ` Thomas Renninger
  0 siblings, 2 replies; 9+ messages in thread
From: Luck, Tony @ 2011-10-21 21:42 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Huang Ying

Callers to __acpi_ioremap_fast() pass the bit_width that they found in the
acpi_generic_address structure. Convert from bits to bytes when passing to
__acpi_find_iomap() - as it wants to see bytes, not bits.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 drivers/acpi/atomicio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
index 252888f..70ffb71 100644
--- a/drivers/acpi/atomicio.c
+++ b/drivers/acpi/atomicio.c
@@ -78,7 +78,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
 {
 	struct acpi_iomap *map;
 
-	map = __acpi_find_iomap(paddr, size);
+	map = __acpi_find_iomap(paddr, size/8);
 	if (map)
 		return map->vaddr + (paddr - map->paddr);
 	else
-- 
1.7.3.1


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

* Re: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-10-21 21:42 [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast() Luck, Tony
@ 2011-10-25  2:48 ` Huang Ying
  2011-10-25 13:57   ` Bjorn Helgaas
  2011-10-28  0:17 ` Thomas Renninger
  1 sibling, 1 reply; 9+ messages in thread
From: Huang Ying @ 2011-10-25  2:48 UTC (permalink / raw)
  To: Luck, Tony; +Cc: Brown, Len, linux-acpi@vger.kernel.org

Sorry for late.

On 10/22/2011 05:42 AM, Luck, Tony wrote:
> Callers to __acpi_ioremap_fast() pass the bit_width that they found in the
> acpi_generic_address structure. Convert from bits to bytes when passing to
> __acpi_find_iomap() - as it wants to see bytes, not bits.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
>  drivers/acpi/atomicio.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
> index 252888f..70ffb71 100644
> --- a/drivers/acpi/atomicio.c
> +++ b/drivers/acpi/atomicio.c
> @@ -78,7 +78,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
>  {
>  	struct acpi_iomap *map;
>  
> -	map = __acpi_find_iomap(paddr, size);
> +	map = __acpi_find_iomap(paddr, size/8);
>  	if (map)
>  		return map->vaddr + (paddr - map->paddr);
>  	else

Good catch! Thanks.

Or change the caller acpi_atomic_read_mem/write_mem?

Best Regards,
Huang Ying

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

* Re: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-10-25  2:48 ` Huang Ying
@ 2011-10-25 13:57   ` Bjorn Helgaas
  2011-10-25 18:39     ` Luck, Tony
  0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2011-10-25 13:57 UTC (permalink / raw)
  To: Huang Ying; +Cc: Luck, Tony, Brown, Len, linux-acpi@vger.kernel.org

On Mon, Oct 24, 2011 at 8:48 PM, Huang Ying <ying.huang@intel.com> wrote:
> Sorry for late.
>
> On 10/22/2011 05:42 AM, Luck, Tony wrote:
>> Callers to __acpi_ioremap_fast() pass the bit_width that they found in the
>> acpi_generic_address structure. Convert from bits to bytes when passing to
>> __acpi_find_iomap() - as it wants to see bytes, not bits.
>>
>> Signed-off-by: Tony Luck <tony.luck@intel.com>
>> ---
>>  drivers/acpi/atomicio.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
>> index 252888f..70ffb71 100644
>> --- a/drivers/acpi/atomicio.c
>> +++ b/drivers/acpi/atomicio.c
>> @@ -78,7 +78,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
>>  {
>>       struct acpi_iomap *map;
>>
>> -     map = __acpi_find_iomap(paddr, size);
>> +     map = __acpi_find_iomap(paddr, size/8);
>>       if (map)
>>               return map->vaddr + (paddr - map->paddr);
>>       else
>
> Good catch! Thanks.
>
> Or change the caller acpi_atomic_read_mem/write_mem?

Myron posted a nice patch recently to remove atomicio.c altogether:
http://marc.info/?l=linux-acpi&m=131733358818849&w=2

I haven't seen any response to it, but I think it's a nice approach
and it gets rid of all this special-case pre-map, post-unmap, atomic
read/write stuff.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-10-25 13:57   ` Bjorn Helgaas
@ 2011-10-25 18:39     ` Luck, Tony
  2011-10-25 19:34       ` Bjorn Helgaas
  0 siblings, 1 reply; 9+ messages in thread
From: Luck, Tony @ 2011-10-25 18:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Huang, Ying; +Cc: Brown, Len, linux-acpi@vger.kernel.org

> Myron posted a nice patch recently to remove atomicio.c altogether:
> http://marc.info/?l=linux-acpi&m=131733358818849&w=2
>
> I haven't seen any response to it, but I think it's a nice approach
> and it gets rid of all this special-case pre-map, post-unmap, atomic
> read/write stuff.

Does that meet the needs of the:

  panic in NMI/machine check context
    kmsg_dump
      pstore
        ERST
          acpi reads & writes

call chain?  I thought that atomicio was created for paths where the normal
acpi operations had problems in NMI contexts.

-Tony
	

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

* Re: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-10-25 18:39     ` Luck, Tony
@ 2011-10-25 19:34       ` Bjorn Helgaas
  2011-10-25 20:03         ` Myron Stowe
  0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2011-10-25 19:34 UTC (permalink / raw)
  To: Luck, Tony
  Cc: Huang, Ying, Brown, Len, linux-acpi@vger.kernel.org, Myron Stowe

[+cc Myron]

On Tue, Oct 25, 2011 at 12:39 PM, Luck, Tony <tony.luck@intel.com> wrote:
>> Myron posted a nice patch recently to remove atomicio.c altogether:
>> http://marc.info/?l=linux-acpi&m=131733358818849&w=2
>>
>> I haven't seen any response to it, but I think it's a nice approach
>> and it gets rid of all this special-case pre-map, post-unmap, atomic
>> read/write stuff.
>
> Does that meet the needs of the:
>
>  panic in NMI/machine check context
>    kmsg_dump
>      pstore
>        ERST
>          acpi reads & writes
>
> call chain?  I thought that atomicio was created for paths where the normal
> acpi operations had problems in NMI contexts.

Yes, it should meet those needs.  The reason we couldn't use
acpi_read() in NMI contexts was that it did an ioremap(), which may
need to allocate memory.  Therefore, we added acpi_pre_map_gar(),
which did the ioremap() early, in process context, and
acpi_atomic_read(), which relies on that mapping to perform the
access.

Myron's work adds acpi_os_map_generic_address(), which is basically
the same as acpi_pre_map_gar().  You call this in process context, and
it does the ioremap() and saves the resulting mapping.  Then he
changed acpi_os_read_memory() (the guts of acpi_read()) so it only
does the ioremap() if there's no existing mapping.

The net result is that acpi_read() should now be safe in NMI context,
as long as you are reading things you've previously mapped with
acpi_os_map_generic_address().

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-10-25 19:34       ` Bjorn Helgaas
@ 2011-10-25 20:03         ` Myron Stowe
  0 siblings, 0 replies; 9+ messages in thread
From: Myron Stowe @ 2011-10-25 20:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Luck, Tony, Huang, Ying, Brown, Len, linux-acpi@vger.kernel.org,
	Myron Stowe

On Tue, Oct 25, 2011 at 1:34 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> [+cc Myron]
>
> On Tue, Oct 25, 2011 at 12:39 PM, Luck, Tony <tony.luck@intel.com> wrote:
>>> Myron posted a nice patch recently to remove atomicio.c altogether:
>>> http://marc.info/?l=linux-acpi&m=131733358818849&w=2
>>>
>>> I haven't seen any response to it, but I think it's a nice approach
>>> and it gets rid of all this special-case pre-map, post-unmap, atomic
>>> read/write stuff.
>>
>> Does that meet the needs of the:
>>
>>  panic in NMI/machine check context
>>    kmsg_dump
>>      pstore
>>        ERST
>>          acpi reads & writes
>>
>> call chain?  I thought that atomicio was created for paths where the normal
>> acpi operations had problems in NMI contexts.
>
> Yes, it should meet those needs.  The reason we couldn't use
> acpi_read() in NMI contexts was that it did an ioremap(), which may
> need to allocate memory.  Therefore, we added acpi_pre_map_gar(),
> which did the ioremap() early, in process context, and
> acpi_atomic_read(), which relies on that mapping to perform the
> access.
>
> Myron's work adds acpi_os_map_generic_address(), which is basically
> the same as acpi_pre_map_gar().  You call this in process context, and
> it does the ioremap() and saves the resulting mapping.  Then he
> changed acpi_os_read_memory() (the guts of acpi_read()) so it only
> does the ioremap() if there's no existing mapping.
>
> The net result is that acpi_read() should now be safe in NMI context,
> as long as you are reading things you've previously mapped with
> acpi_os_map_generic_address().
>
> Bjorn

Thanks for seeing this and bringing up the recent patch to remove
atomicio.c Bjorn.

If for some reason the atomicio.c removal patch is not taken then the
fix here should follow what was done earlier in drivers/acpi/osl.c - see
commit b3ba1efec2a

Myron

> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-10-21 21:42 [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast() Luck, Tony
  2011-10-25  2:48 ` Huang Ying
@ 2011-10-28  0:17 ` Thomas Renninger
  2011-11-07  1:29   ` Len Brown
  1 sibling, 1 reply; 9+ messages in thread
From: Thomas Renninger @ 2011-10-28  0:17 UTC (permalink / raw)
  To: Luck, Tony; +Cc: Len Brown, linux-acpi, Huang Ying

On Friday 21 October 2011 23:42:55 Luck, Tony wrote:
> Callers to __acpi_ioremap_fast() pass the bit_width that they found in the
> acpi_generic_address structure. Convert from bits to bytes when passing to
> __acpi_find_iomap() - as it wants to see bytes, not bits.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>
This one should get:
CC: stable@kernel.org
added.

   Thomas
> ---
>  drivers/acpi/atomicio.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
> index 252888f..70ffb71 100644
> --- a/drivers/acpi/atomicio.c
> +++ b/drivers/acpi/atomicio.c
> @@ -78,7 +78,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
>  {
>  	struct acpi_iomap *map;
>  
> -	map = __acpi_find_iomap(paddr, size);
> +	map = __acpi_find_iomap(paddr, size/8);
>  	if (map)
>  		return map->vaddr + (paddr - map->paddr);
>  	else
> -- 
> 1.7.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-10-28  0:17 ` Thomas Renninger
@ 2011-11-07  1:29   ` Len Brown
  2011-11-07  3:28     ` Luck, Tony
  0 siblings, 1 reply; 9+ messages in thread
From: Len Brown @ 2011-11-07  1:29 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Luck, Tony, linux-acpi, Huang Ying

> This one should get:
> CC: stable@kernel.org

Tony,
What kind of failures are seen with this bug un-patched?
(and thus, what kind of urgency do distros have to back-port this fix?)

thanks
-- 
Len Brown, Intel Open Source Technology Center

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

* RE: [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast()
  2011-11-07  1:29   ` Len Brown
@ 2011-11-07  3:28     ` Luck, Tony
  0 siblings, 0 replies; 9+ messages in thread
From: Luck, Tony @ 2011-11-07  3:28 UTC (permalink / raw)
  To: Len Brown, Thomas Renninger; +Cc: linux-acpi@vger.kernel.org, Huang, Ying

> What kind of failures are seen with this bug un-patched?
> (and thus, what kind of urgency do distros have to back-port this fix?)

Just noticed it was wrong when reading code - It hadn't caused me a
problem - and in most cases I don't think there is an issue - since
we actually round up all mappings to pages anyway, whether we have
the size in bits or bytes will generally not make any difference.

There might be some issues with addresses near the end of a page,
where using 64 as bytes would mean addr+size overflows onto the
next page, where addr+size/8 doesn't.  But I haven't looked hard
enough to see what would happen in this case.

-Tony

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

end of thread, other threads:[~2011-11-07  3:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-21 21:42 [PATCH] Convert width in bits to bytes in __acpi_ioremap_fast() Luck, Tony
2011-10-25  2:48 ` Huang Ying
2011-10-25 13:57   ` Bjorn Helgaas
2011-10-25 18:39     ` Luck, Tony
2011-10-25 19:34       ` Bjorn Helgaas
2011-10-25 20:03         ` Myron Stowe
2011-10-28  0:17 ` Thomas Renninger
2011-11-07  1:29   ` Len Brown
2011-11-07  3:28     ` Luck, Tony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox