io-mapping: Indicate mapping failure
I found this when my system crashed long after the mapping failure. The expected behavior should have been driver exit.
Since this is almost exclusively used for drm, I am posting to the dri mailing list. Should this go to another list as well?
Thanks,
Mike
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 io-mapping: Indicate mapping failure
Sometimes it is good to know when your mapping failed.
--- include/linux/io-mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/io-mapping.h +1 -1
@@ -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
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
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 metadataabout 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
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 failureQuoted 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 ofiomap->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 metadataabout 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.