mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fixup! of: populate new device_d::dma_coherent attribute
@ 2024-01-11 16:19 Ahmad Fatoum
  2024-01-11 17:54 ` (subset) " Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-01-11 16:19 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

dev may be NULL, e.g. when

  dma_sync_single_for_cpu(NULL,

is called. Such instances are broken anyway, but we still have them,
e.g. in Raspberry Pi code for mailbox, so add a NULL check.

Fixes qemu-rpi0@multi_v7 CI breakage on next.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/driver.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/driver.h b/include/driver.h
index c23404ca16fb..43d002f66dbe 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -730,13 +730,15 @@ static inline struct device_node *dev_of_node(struct device *dev)
 
 static inline bool dev_is_dma_coherent(struct device *dev)
 {
-	switch (dev->dma_coherent) {
-	case DEV_DMA_NON_COHERENT:
-		return false;
-	case DEV_DMA_COHERENT:
-		return true;
-	case DEV_DMA_COHERENCE_DEFAULT:
-		break;
+	if (dev) {
+		switch (dev->dma_coherent) {
+		case DEV_DMA_NON_COHERENT:
+			return false;
+		case DEV_DMA_COHERENT:
+			return true;
+		case DEV_DMA_COHERENCE_DEFAULT:
+			break;
+		}
 	}
 
 	return IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
-- 
2.39.2




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

* Re: (subset) [PATCH] fixup! of: populate new device_d::dma_coherent attribute
  2024-01-11 16:19 [PATCH] fixup! of: populate new device_d::dma_coherent attribute Ahmad Fatoum
@ 2024-01-11 17:54 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-01-11 17:54 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 11 Jan 2024 17:19:51 +0100, Ahmad Fatoum wrote:
> dev may be NULL, e.g. when
> 
>   dma_sync_single_for_cpu(NULL,
> 
> is called. Such instances are broken anyway, but we still have them,
> e.g. in Raspberry Pi code for mailbox, so add a NULL check.
> 
> [...]

Applied, thanks!

[1/1] fixup! of: populate new device_d::dma_coherent attribute
      https://git.pengutronix.de/cgit/barebox/commit/?id=ff451448213b (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-01-11 17:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11 16:19 [PATCH] fixup! of: populate new device_d::dma_coherent attribute Ahmad Fatoum
2024-01-11 17:54 ` (subset) " Sascha Hauer

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