Skip to contentSkip to conversation

ACPI, APEI Fix the return value(==NULL) of acpi_pre_map().

PATCH In review Jin Dongming 2 participants 3 messages Sep 2, 2010 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ACPI, APEI Fix the return value(==NULL) of acpi_pre_map().

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 that when (paddr - pg_off) equals 0, no matter whether I/O remapping is successful or not, the function returns NULL.

In acpi_pre_map(), after the physical address is remapped sucessfully, it will check whether the physical address has been added into acpi_iomaps list again.
- If the physical address has beed added into acpi_iomaps, the virtual address will be saved in vaddr.
- Otherwise, NULL be saved in vaddr.

So if the physical address is the first time to be remapped, vaddr will be NULL always.

In many cases, (paddr - pg_off) may not equal 0. So the function could work well. In our machine, (paddr - pg_off) equals 0, so the return value of acpi_pre_map() is NULL.

This patch fixed it and I confirmed it on x86_64 next-tree.

---
 drivers/acpi/atomicio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/atomicio.c +2 -2
index 8f8bd73..1bc2614 100644
@@ -133,7 +133,7 @@ static void __iomem *acpi_pre_map(phys_addr_t paddr,
 
 	spin_lock_irqsave(&acpi_iomaps_lock, flags);
 	vaddr = __acpi_try_ioremap(paddr, size);
-	if (vaddr) {
+	if (unlikely(vaddr)) {
 		spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
 		iounmap(map->vaddr);
 		kfree(map);
@@ -142,7 +142,7 @@ static void __iomem *acpi_pre_map(phys_addr_t paddr,
 	list_add_tail_rcu(&map->list, &acpi_iomaps);
 	spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
 
-	return vaddr + (paddr - pg_off);
+	return map->vaddr + (paddr - pg_off);
 err_unmap:
 	iounmap(vaddr);
 	return NULL;

-- 1.7.1.1

Acked-by on v1 1/2
#1 lore raw
Quoted 15 lines · Jin Dongming

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 that when (paddr - pg_off) equals 0, no matter whether I/O remapping is successful or not, the function returns NULL.

In acpi_pre_map(), after the physical address is remapped sucessfully, it will check whether the physical address has been added into acpi_iomaps list again.
- If the physical address has beed added into acpi_iomaps, the virtual address will be saved in vaddr.
- Otherwise, NULL be saved in vaddr.

So if the physical address is the first time to be remapped, vaddr will be NULL always.

Quoted 7 lines

In many cases, (paddr - pg_off) may not equal 0. So the function could work well. In our machine, (paddr - pg_off) equals 0, so the return value of acpi_pre_map() is NULL.

This patch fixed it and I confirmed it on x86_64 next-tree.

Best Regards,
Huang Ying

#2 lore raw
In reply to Jin Dongming

Hi, All,

I am very sorry for my miss. Please cancel these two patches. I will send the new patches.

Best Regards,
Jin Dongming.

Quoted 57 lines · Jin Dongming

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 that when (paddr - pg_off) equals 0, no matter whether I/O remapping is successful or not, the function returns NULL.

In acpi_pre_map(), after the physical address is remapped sucessfully, it will check whether the physical address has been added into acpi_iomaps list again.
- If the physical address has beed added into acpi_iomaps, the virtual address will be saved in vaddr.
- Otherwise, NULL be saved in vaddr.

So if the physical address is the first time to be remapped, vaddr will be NULL always.

In many cases, (paddr - pg_off) may not equal 0. So the function could work well. In our machine, (paddr - pg_off) equals 0, so the return value of acpi_pre_map() is NULL.

This patch fixed it and I confirmed it on x86_64 next-tree.

---
 drivers/acpi/atomicio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/atomicio.c +2 -4
index 8f8bd73..1bc2614 100644
@@ -133,7 +133,7 @@ static void __iomem *acpi_pre_map(phys_addr_t paddr,
 
 	spin_lock_irqsave(&acpi_iomaps_lock, flags);
 	vaddr = __acpi_try_ioremap(paddr, size);
-	if (vaddr) {
+	if (unlikely(vaddr)) {
 		spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
 		iounmap(map->vaddr);
 		kfree(map);
@@ -142,7 +142,7 @@ static void __iomem *acpi_pre_map(phys_addr_t paddr,
 	list_add_tail_rcu(&map->list, &acpi_iomaps);
 	spin_unlock_irqrestore(&acpi_iomaps_lock, flags);
 
-	return vaddr + (paddr - pg_off);
+	return map->vaddr + (paddr - pg_off);
 err_unmap:
 	iounmap(vaddr);
 	return NULL;
-- 1.7.1.1 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/