Skip to contentSkip to conversation

io-mapping: Indicate mapping failure

PATCH In review Michael J. Ruhl 3 participants 5 messages Jul 21, 2020 Stable branch

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 io-mapping: Indicate mapping failure

Sometimes it is good to know when your mapping failed.

Fixes cafaf14a5d8f ("io-mapping: Always create a struct to hold metadata about the io-mapping"
Cc Andrew Morton <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Chris Wilson <[email protected]>
---
 include/linux/io-mapping.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/io-mapping.h +1 -1
index 0beaa3eba155..5641e06cbcf7 100644
@@ -118,7 +118,7 @@ io_mapping_init_wc(struct io_mapping *iomap,
 	iomap->prot = pgprot_noncached(PAGE_KERNEL);
 #endif
 
-	return iomap;
+	return iomap->iomem ? iomap : NULL;
 }
 
 static inline void
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 1 line · Michael J. Ruhl

Sometimes it is good to know when your mapping failed.

Can you elaborate...

Quoted 1 line
Fixes cafaf14a5d8f ("io-mapping: Always create a struct to hold metadata about the io-mapping"

...especially taking into account that Fixes implies regression / bug?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 9 lines

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, July 21, 2020 10:47 AM
To: Ruhl, Michael J <[email protected]>
Cc: [email protected]; Andrew Morton <akpm@linux- foundation.org>; Mike Rapoport <[email protected]>; Chris Wilson <[email protected]>; [email protected]
Subject: Re: [PATCH] io-mapping: Indicate mapping failure

Quoted 4 lines
Quoted 1 line · Michael J. Ruhl

Sometimes it is good to know when your mapping failed.

Can you elaborate...

Sure, guess I was too glib. 😊

Currently the io_mapping_init_wc (the !ATOMIC_IOMAP version), function will always return success.

If the setting of the iomem (from ioremap_wc) fails, the only way for the caller to know is to check the value of iomap->iomem.

Since all of the callers expect a NULL return on error, and check for a NULL, I felt this needed a fixes (i.e. unexpected behavior).

Quoted 4 lines
Quoted 1 line
Fixes cafaf14a5d8f ("io-mapping: Always create a struct to hold metadata

about the io-mapping"

...especially taking into account that Fixes implies regression / bug?

The failure (in my case a crash) is not revealed until the address is accessed long after the init.

I will update the commit.

Mike

Quoted 4 lines

--
With Best Regards,
Andy Shevchenko

#4 lore raw
Quoted 11 lines · Michael J
Quoted 11 lines

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, July 21, 2020 10:47 AM
To: Ruhl, Michael J <[email protected]>
Cc: [email protected]; Andrew Morton <akpm@linux- foundation.org>; Mike Rapoport <[email protected]>; Chris Wilson <[email protected]>; [email protected]
Subject: Re: [PATCH] io-mapping: Indicate mapping failure

Quoted 1 line · Michael J. Ruhl

Sometimes it is good to know when your mapping failed.

I was going to say it's always a good idea ;-)

Quoted 30 lines
Quoted 1 line

Can you elaborate...

Sure, guess I was too glib. 😊

Currently the io_mapping_init_wc (the !ATOMIC_IOMAP version), function will always return success.

If the setting of the iomem (from ioremap_wc) fails, the only way for the caller to know is to check the value of iomap->iomem.

Since all of the callers expect a NULL return on error, and check for a NULL, I felt this needed a fixes (i.e. unexpected behavior).

Quoted 4 lines
Quoted 1 line
Fixes cafaf14a5d8f ("io-mapping: Always create a struct to hold metadata

about the io-mapping"

...especially taking into account that Fixes implies regression / bug?

The failure (in my case a crash) is not revealed until the address is accessed long after the init.

I will update the commit.

Mike

Quoted 4 lines

--
With Best Regards,
Andy Shevchenko

Signature · 2 lines
Sincerely yours,
Mike.