From: Jin Dongming <jin.dongming@np.css.fujitsu.com>
To: Huang Ying <ying.huang@intel.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>,
Stephen Rothwell <sfr@canb.auug.org.au>,
Andi Kleen <andi@firstfloor.org>,
Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
ACPI <linux-acpi@vger.kernel.org>,
LKLM <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] [Patch-next] ACPI, APEI Fix the return value(==NULL) of acpi_pre_map always.
Date: Tue, 17 Aug 2010 13:47:40 +0900 [thread overview]
Message-ID: <4C6A146C.5030807@np.css.fujitsu.com> (raw)
In-Reply-To: <1282018540.2744.1505.camel@yhuang-dev>
(2010/08/17 13:15), Huang Ying wrote:
> On Tue, 2010-08-17 at 10:43 +0800, Jin Dongming wrote:
>> (2010/08/17 10:37), Huang Ying wrote:
>>> On Tue, 2010-08-17 at 08:56 +0800, Jin Dongming wrote:
>>>> acpi_pre_map() is used for remapping the physical address of I/O, so
>>>> it should be return NULL or remapped virtual address. The problem
>>>> is whether I/O remapping is successful or not, the function returns
>>>> NULL always.
>>>
>>> No. NULL is returned for error path only. Please check the code again.
>>
>> There three places used the local variable vaddr in acpi_pre_map() in next-tree.
>> 1. 115 vaddr = __acpi_try_ioremap(paddr, size);
>> 2. 122 vaddr = ioremap(pg_off, pg_sz);
>> 3. 135 vaddr = __acpi_try_ioremap(paddr, size);
>>
>> Let's think about the following statement.
>> Assumption: the physical address has never been remapped.
>> Step:
>> 1. vaddr == NULL
>> Because the physical address is not registered in the acpi_iomaps,
>> it should be returned NULL from __acpi_try_ioremap().
>>
>> 2. vaddr == the virtual address of the physical address.
>> Here if ioremap is successful, the value of vaddr should be
>> the virtual address returned from ioremap().
>>
>> 3. vaddr == NULL <== IMPORTANT
>> Here it is because the physical address has not been registered
>> in the acpi_iomaps yet, it still return NULL from __acpi_try_ioremap().
>> So it is why vaddr == NULL, even if the physical address has never
>> been remapped.
>>
>> Result: vaddr == NULL.
>
> return vaddr + (paddr - pg_off), is not NULL for common cases.
>
>> And if the vaddr is not NULL, it could not be added into acpi_iomaps.
>> Codes in acpi_pre_map() is like following.
>>
>> 134 spin_lock_irqsave(&acpi_iomaps_lock, flags);
>> 135 vaddr = __acpi_try_ioremap(paddr, size); <== the 3rd step
>> 136 if (vaddr) {
>> 137 spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
>> 138 iounmap(map->vaddr);
>> 139 kfree(map);
>> 140 return vaddr;
>> 141 }
>> 142 list_add_tail_rcu(&map->list, &acpi_iomaps); <== add into acpi_iomaps.
>> 143 spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
>
> Oops, this is a bug, and your patch really fix it. But I think you
> should change the patch description. NULL is not returned in almost all
> cases. Because (paddr - pg_off) is not zero in common cases.
>
> Best Regards,
> Huang Ying
>
OK. I will modify the description of this patch and resend it.
Best Regards,
Jin Dongming
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>
prev parent reply other threads:[~2010-08-17 4:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-17 0:56 [PATCH 3/4] [Patch-next] ACPI, APEI Fix the return value(==NULL) of acpi_pre_map always Jin Dongming
2010-08-17 1:37 ` Huang Ying
2010-08-17 2:43 ` Jin Dongming
2010-08-17 4:15 ` Huang Ying
2010-08-17 4:47 ` Jin Dongming [this message]
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=4C6A146C.5030807@np.css.fujitsu.com \
--to=jin.dongming@np.css.fujitsu.com \
--cc=andi@firstfloor.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=randy.dunlap@oracle.com \
--cc=seto.hidetoshi@jp.fujitsu.com \
--cc=sfr@canb.auug.org.au \
--cc=ying.huang@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 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.