public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
@ 2024-10-14 14:46 Christoph Hellwig
  2024-10-15  7:38 ` Jiri Slaby
  2024-10-15  7:47 ` Jiri Slaby
  0 siblings, 2 replies; 11+ messages in thread
From: Christoph Hellwig @ 2024-10-14 14:46 UTC (permalink / raw)
  To: stefani; +Cc: jassisinghbrar, jirislaby, linux-kernel

Nothing in kfifo.h needs dma-mapping.h.  Drop the include to
reduce include bloat.

Fixes: d52b761e4b1a ("kfifo: add kfifo_dma_out_prepare_mapped()")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mailbox/omap-mailbox.c | 1 +
 include/linux/kfifo.h          | 1 -
 samples/kfifo/dma-example.c    | 1 +
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
index 6797770474a55d..680243751d625f 100644
--- a/drivers/mailbox/omap-mailbox.c
+++ b/drivers/mailbox/omap-mailbox.c
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/kfifo.h>
 #include <linux/err.h>
+#include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 564868bdce898b..fd743d4c4b4bdc 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -37,7 +37,6 @@
  */
 
 #include <linux/array_size.h>
-#include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
 #include <linux/stddef.h>
 #include <linux/types.h>
diff --git a/samples/kfifo/dma-example.c b/samples/kfifo/dma-example.c
index 48df719dac8c6d..8076ac410161a3 100644
--- a/samples/kfifo/dma-example.c
+++ b/samples/kfifo/dma-example.c
@@ -9,6 +9,7 @@
 #include <linux/kfifo.h>
 #include <linux/module.h>
 #include <linux/scatterlist.h>
+#include <linux/dma-mapping.h>
 
 /*
  * This module shows how to handle fifo dma operations.
-- 
2.45.2


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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-14 14:46 [PATCH] kfifo: don't include dma-mapping.h in kfifo.h Christoph Hellwig
@ 2024-10-15  7:38 ` Jiri Slaby
  2024-10-15  7:40   ` Christoph Hellwig
  2024-10-15  7:47 ` Jiri Slaby
  1 sibling, 1 reply; 11+ messages in thread
From: Jiri Slaby @ 2024-10-15  7:38 UTC (permalink / raw)
  To: Christoph Hellwig, stefani; +Cc: jassisinghbrar, linux-kernel

On 14. 10. 24, 16:46, Christoph Hellwig wrote:
> Nothing in kfifo.h needs dma-mapping.h.  Drop the include to
> reduce include bloat.

Except DMA_MAPPING_ERROR.

The header should stay self-contained.

-- 
js
suse labs


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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:38 ` Jiri Slaby
@ 2024-10-15  7:40   ` Christoph Hellwig
  2024-10-15  7:53     ` Jiri Slaby
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2024-10-15  7:40 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Christoph Hellwig, stefani, jassisinghbrar, linux-kernel

On Tue, Oct 15, 2024 at 09:38:24AM +0200, Jiri Slaby wrote:
> On 14. 10. 24, 16:46, Christoph Hellwig wrote:
>> Nothing in kfifo.h needs dma-mapping.h.  Drop the include to
>> reduce include bloat.
>
> Except DMA_MAPPING_ERROR.

DMA_MAPPING_ERROR is never used by kfifo.h itself.  It is used
by user of the header that instanciate one of the macros that use
it.

> The header should stay self-contained.

It does with this patch.  You can include it as the only header
in a source file and will work fine.  I've actually tried that.

>
> -- 
> js
> suse labs
---end quoted text---

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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-14 14:46 [PATCH] kfifo: don't include dma-mapping.h in kfifo.h Christoph Hellwig
  2024-10-15  7:38 ` Jiri Slaby
@ 2024-10-15  7:47 ` Jiri Slaby
  2024-10-15  7:50   ` Christoph Hellwig
  1 sibling, 1 reply; 11+ messages in thread
From: Jiri Slaby @ 2024-10-15  7:47 UTC (permalink / raw)
  To: Christoph Hellwig, stefani; +Cc: jassisinghbrar, linux-kernel

On 14. 10. 24, 16:46, Christoph Hellwig wrote:
> Nothing in kfifo.h needs dma-mapping.h.  Drop the include to
> reduce include bloat.
> 
> Fixes: d52b761e4b1a ("kfifo: add kfifo_dma_out_prepare_mapped()")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/mailbox/omap-mailbox.c | 1 +
>   include/linux/kfifo.h          | 1 -
>   samples/kfifo/dma-example.c    | 1 +
>   3 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
> index 6797770474a55d..680243751d625f 100644
> --- a/drivers/mailbox/omap-mailbox.c
> +++ b/drivers/mailbox/omap-mailbox.c
> @@ -15,6 +15,7 @@
>   #include <linux/slab.h>
>   #include <linux/kfifo.h>
>   #include <linux/err.h>
> +#include <linux/io.h>

Oh, I've just noticed this. Why io.h?

-- 
js
suse labs


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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:47 ` Jiri Slaby
@ 2024-10-15  7:50   ` Christoph Hellwig
  2024-10-15  7:55     ` Jiri Slaby
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2024-10-15  7:50 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Christoph Hellwig, stefani, jassisinghbrar, linux-kernel

On Tue, Oct 15, 2024 at 09:47:31AM +0200, Jiri Slaby wrote:
>> diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
>> index 6797770474a55d..680243751d625f 100644
>> --- a/drivers/mailbox/omap-mailbox.c
>> +++ b/drivers/mailbox/omap-mailbox.c
>> @@ -15,6 +15,7 @@
>>   #include <linux/slab.h>
>>   #include <linux/kfifo.h>
>>   #include <linux/err.h>
>> +#include <linux/io.h>
>
> Oh, I've just noticed this. Why io.h?

Because it would not comple with out it.  To be specific: asm/io.h is
where __raw_readl and __raw_writel are defined, and we generally prefer
the Linux over the asm headers.

>
> -- 
> js
> suse labs
---end quoted text---

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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:40   ` Christoph Hellwig
@ 2024-10-15  7:53     ` Jiri Slaby
  2024-10-15  7:56       ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Jiri Slaby @ 2024-10-15  7:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: stefani, jassisinghbrar, linux-kernel

On 15. 10. 24, 9:40, Christoph Hellwig wrote:
> On Tue, Oct 15, 2024 at 09:38:24AM +0200, Jiri Slaby wrote:
>> On 14. 10. 24, 16:46, Christoph Hellwig wrote:
>>> Nothing in kfifo.h needs dma-mapping.h.  Drop the include to
>>> reduce include bloat.
>>
>> Except DMA_MAPPING_ERROR.
> 
> DMA_MAPPING_ERROR is never used by kfifo.h itself.  It is used
> by user of the header that instanciate one of the macros that use
> it.

Well, I don't understand. Looking at:
#define kfifo_dma_in_prepare(fifo, sgl, nents, len) \
         kfifo_dma_in_prepare_mapped(fifo, sgl, nents, len, 
DMA_MAPPING_ERROR)

You'd have to include dma-mapping.h if you used this macro. Even though 
you do not explicitly use any other def from the dma header.

I know one will very likely include dma-mapping.h when using the macro. 
But that might not be a rule.

>> The header should stay self-contained.
> 
> It does with this patch.  You can include it as the only header
> in a source file and will work fine.  I've actually tried that.

Well, this is not a definition of self-containment. If you use every 
macro from a header and it does not need any other include, then it is 
self-contained.

-- 
js
suse labs


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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:50   ` Christoph Hellwig
@ 2024-10-15  7:55     ` Jiri Slaby
  2024-10-15  7:57       ` Christoph Hellwig
  0 siblings, 1 reply; 11+ messages in thread
From: Jiri Slaby @ 2024-10-15  7:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: stefani, jassisinghbrar, linux-kernel

On 15. 10. 24, 9:50, Christoph Hellwig wrote:
> On Tue, Oct 15, 2024 at 09:47:31AM +0200, Jiri Slaby wrote:
>>> diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
>>> index 6797770474a55d..680243751d625f 100644
>>> --- a/drivers/mailbox/omap-mailbox.c
>>> +++ b/drivers/mailbox/omap-mailbox.c
>>> @@ -15,6 +15,7 @@
>>>    #include <linux/slab.h>
>>>    #include <linux/kfifo.h>
>>>    #include <linux/err.h>
>>> +#include <linux/io.h>
>>
>> Oh, I've just noticed this. Why io.h?
> 
> Because it would not comple with out it.  To be specific: asm/io.h is
> where __raw_readl and __raw_writel are defined, and we generally prefer
> the Linux over the asm headers.

OK, but how does this relate to "kfifo: don't include dma-mapping.h in 
kfifo.h"?

-- 
js
suse labs


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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:53     ` Jiri Slaby
@ 2024-10-15  7:56       ` Christoph Hellwig
  2024-10-15  8:19         ` Jiri Slaby
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2024-10-15  7:56 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Christoph Hellwig, stefani, jassisinghbrar, linux-kernel

On Tue, Oct 15, 2024 at 09:53:52AM +0200, Jiri Slaby wrote:
>> DMA_MAPPING_ERROR is never used by kfifo.h itself.  It is used
>> by user of the header that instanciate one of the macros that use
>> it.
>
> Well, I don't understand. Looking at:
> #define kfifo_dma_in_prepare(fifo, sgl, nents, len) \
>         kfifo_dma_in_prepare_mapped(fifo, sgl, nents, len, 
> DMA_MAPPING_ERROR)
>
> You'd have to include dma-mapping.h if you used this macro.

Yes, obviously.

> Even though you 
> do not explicitly use any other def from the dma header.

Sure.

> Well, this is not a definition of self-containment.

Yes, it is the exact definition of it.

> If you use every macro 
> from a header and it does not need any other include, then it is 
> self-contained.

No, that goes way beyond the self containedness.  In fact these days
the main reason to use macros is exactly to avoid these kinds of
dependencies.


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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:55     ` Jiri Slaby
@ 2024-10-15  7:57       ` Christoph Hellwig
  2024-10-15  8:03         ` Jiri Slaby
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2024-10-15  7:57 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Christoph Hellwig, stefani, jassisinghbrar, linux-kernel

On Tue, Oct 15, 2024 at 09:55:06AM +0200, Jiri Slaby wrote:
>> Because it would not comple with out it.  To be specific: asm/io.h is
>> where __raw_readl and __raw_writel are defined, and we generally prefer
>> the Linux over the asm headers.
>
> OK, but how does this relate to "kfifo: don't include dma-mapping.h in 
> kfifo.h"?

Because before that it get io.h pulled in through our batshit crazy
header depency chain. 

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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:57       ` Christoph Hellwig
@ 2024-10-15  8:03         ` Jiri Slaby
  0 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2024-10-15  8:03 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: stefani, jassisinghbrar, linux-kernel

On 15. 10. 24, 9:57, Christoph Hellwig wrote:
> On Tue, Oct 15, 2024 at 09:55:06AM +0200, Jiri Slaby wrote:
>>> Because it would not comple with out it.  To be specific: asm/io.h is
>>> where __raw_readl and __raw_writel are defined, and we generally prefer
>>> the Linux over the asm headers.
>>
>> OK, but how does this relate to "kfifo: don't include dma-mapping.h in
>> kfifo.h"?
> 
> Because before that it get io.h pulled in through our batshit crazy
> header depency chain.

Good fix then. But you somehow forgot to mention this in the commit message.

-- 
js
suse labs


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

* Re: [PATCH] kfifo: don't include dma-mapping.h in kfifo.h
  2024-10-15  7:56       ` Christoph Hellwig
@ 2024-10-15  8:19         ` Jiri Slaby
  0 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2024-10-15  8:19 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: stefani, jassisinghbrar, linux-kernel

On 15. 10. 24, 9:56, Christoph Hellwig wrote:
> On Tue, Oct 15, 2024 at 09:53:52AM +0200, Jiri Slaby wrote:
>>> DMA_MAPPING_ERROR is never used by kfifo.h itself.  It is used
>>> by user of the header that instanciate one of the macros that use
>>> it.
>>
>> Well, I don't understand. Looking at:
>> #define kfifo_dma_in_prepare(fifo, sgl, nents, len) \
>>          kfifo_dma_in_prepare_mapped(fifo, sgl, nents, len,
>> DMA_MAPPING_ERROR)
>>
>> You'd have to include dma-mapping.h if you used this macro.
> 
> Yes, obviously.
> 
>> Even though you
>> do not explicitly use any other def from the dma header.
> 
> Sure.
> 
>> Well, this is not a definition of self-containment.
> 
> Yes, it is the exact definition of it.

Then it depends on which one, apparently.

So I disagree, but I don't mind either (meaning: I don't oppose to the 
patch any longer either).

>> If you use every macro
>> from a header and it does not need any other include, then it is
>> self-contained.
> 
> No, that goes way beyond the self containedness.  In fact these days
> the main reason to use macros is exactly to avoid these kinds of
> dependencies.


-- 
js
suse labs


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

end of thread, other threads:[~2024-10-15  8:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 14:46 [PATCH] kfifo: don't include dma-mapping.h in kfifo.h Christoph Hellwig
2024-10-15  7:38 ` Jiri Slaby
2024-10-15  7:40   ` Christoph Hellwig
2024-10-15  7:53     ` Jiri Slaby
2024-10-15  7:56       ` Christoph Hellwig
2024-10-15  8:19         ` Jiri Slaby
2024-10-15  7:47 ` Jiri Slaby
2024-10-15  7:50   ` Christoph Hellwig
2024-10-15  7:55     ` Jiri Slaby
2024-10-15  7:57       ` Christoph Hellwig
2024-10-15  8:03         ` Jiri Slaby

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