Re: [PATCH 3/4] [Patch-next] ACPI, APEI Fix the return value(==NULL) of acpi_pre_map always.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jin Dongming
Date: Monday, August 16, 2010 - 7:43 pm

(2010/08/17 10:37), Huang Ying wrote:

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.

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



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 3/4] [Patch-next] ACPI, APEI Fix the return val ..., Jin Dongming, (Mon Aug 16, 7:43 pm)