Skip to contentSkip to conversation

dma-mapping: add unlikely hint to error path in dma_mapping_error

PATCH In review Heiner Kallweit 3 participants 5 messages Mar 26, 2021 – Apr 2, 2021 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-mapping: add unlikely hint to error path in dma_mapping_error

Zillions of drivers use the unlikely() hint when checking the result of dma_mapping_error(). This is an inline function anyway, so we can move the hint into the function and remove it from drivers over time.

---
This is a resend of a patch from Dec 2020 when I tried to do it tree-wide. Now start with the actual change, drivers can be changed afterwards, maybe per subsystem.

---
 include/linux/dma-mapping.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/dma-mapping.h +1 -1
index e9d19b974..183e7103a 100644
@@ -95,7 +95,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
 	debug_dma_mapping_error(dev, dma_addr);
 
-	if (dma_addr == DMA_MAPPING_ERROR)
+	if (unlikely(dma_addr == DMA_MAPPING_ERROR))
 		return -ENOMEM;
 	return 0;
 }
Signature · 6 lines
2.31.0

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
reviewer
#1 lore raw
Quoted 3 lines · Heiner Kallweit

Zillions of drivers use the unlikely() hint when checking the result of dma_mapping_error(). This is an inline function anyway, so we can move the hint into the function and remove it from drivers over time.

I'm pretty sure I reviewed this last time - please remember to pick up tags from previous versions when reposting.

Thanks,
Robin.

Quoted 15 lines

---
This is a resend of a patch from Dec 2020 when I tried to do it tree-wide. Now start with the actual change, drivers can be changed afterwards, maybe per subsystem.

---
  include/linux/dma-mapping.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/dma-mapping.h +0 -0
index e9d19b974..183e7103a 100644

include/linux/dma-mapping.h static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) · line 101

Quoted 8 lines
include/linux/dma-mapping.h +1 -1
@@ -95,7 +95,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
  {
  	debug_dma_mapping_error(dev, dma_addr);
 
-	if (dma_addr == DMA_MAPPING_ERROR)
+	if (unlikely(dma_addr == DMA_MAPPING_ERROR))
  		return -ENOMEM;
  	return 0;
  }

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#2 lore raw
Quoted 7 lines · Robin Murphy
Quoted 3 lines · Heiner Kallweit

Zillions of drivers use the unlikely() hint when checking the result of dma_mapping_error(). This is an inline function anyway, so we can move the hint into the function and remove it from drivers over time.

I'm pretty sure I reviewed this last time - please remember to pick up tags from previous versions when reposting.

Right, you did. My bad.

Quoted 12 lines

Thanks,
Robin.

Quoted 9 lines

---
This is a resend of a patch from Dec 2020 when I tried to do it tree-wide. Now start with the actual change, drivers can be changed afterwards, maybe per subsystem.
---
  include/linux/dma-mapping.h | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

include/linux/dma-mapping.h static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) · line 101

Quoted 13 lines
include/linux/dma-mapping.h +1 -0
index e9d19b974..183e7103a 100644
@@ -95,7 +95,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
   {
       debug_dma_mapping_error(dev, dma_addr);
   -    if (dma_addr == DMA_MAPPING_ERROR)
+    if (unlikely(dma_addr == DMA_MAPPING_ERROR))
           return -ENOMEM;
       return 0;
   }

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author Reviewed-by Robin Murphy on v1 1/1
#3 lore raw
In reply to Heiner Kallweit
Quoted 19 lines · Heiner Kallweit

Zillions of drivers use the unlikely() hint when checking the result of dma_mapping_error(). This is an inline function anyway, so we can move the hint into the function and remove it from drivers over time.

---
This is a resend of a patch from Dec 2020 when I tried to do it tree-wide. Now start with the actual change, drivers can be changed afterwards, maybe per subsystem.

---
 include/linux/dma-mapping.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/dma-mapping.h +0 -0
index e9d19b974..183e7103a 100644

include/linux/dma-mapping.h static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) · line 101

Quoted 8 lines
include/linux/dma-mapping.h +1 -1
@@ -95,7 +95,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
 	debug_dma_mapping_error(dev, dma_addr);
 
-	if (dma_addr == DMA_MAPPING_ERROR)
+	if (unlikely(dma_addr == DMA_MAPPING_ERROR))
 		return -ENOMEM;
 	return 0;
 }

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu