2023-10-13 10:06:32

by MD Danish Anwar

[permalink] [raw]
Subject: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
the expected CFLAGS are different between builtins and modules.

The build system is complaining about the following:

k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
ti-am65-cpsw-nuss

Introduce the new module, k3-cppi-desc-pool, to provide the common
functions to ti-am65-cpsw-nuss and icssg-prueth.

Signed-off-by: MD Danish Anwar <[email protected]>
---
drivers/net/ethernet/ti/Kconfig | 5 +++++
drivers/net/ethernet/ti/Makefile | 7 ++++---
drivers/net/ethernet/ti/k3-cppi-desc-pool.c | 7 +++++++
3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index 0784a3d0bbff..e60b557d59b9 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -90,12 +90,16 @@ config TI_CPTS
The unit can time stamp PTP UDP/IPv4 and Layer 2 packets, and the
driver offers a PTP Hardware Clock.

+config TI_K3_CPPI_DESC_POOL
+ tristate
+
config TI_K3_AM65_CPSW_NUSS
tristate "TI K3 AM654x/J721E CPSW Ethernet driver"
depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
select NET_DEVLINK
select TI_DAVINCI_MDIO
select PHYLINK
+ select TI_K3_CPPI_DESC_POOL
imply PHY_TI_GMII_SEL
depends on TI_K3_AM65_CPTS || !TI_K3_AM65_CPTS
help
@@ -180,6 +184,7 @@ config TI_ICSSG_PRUETH
tristate "TI Gigabit PRU Ethernet driver"
select PHYLIB
select TI_ICSS_IEP
+ select TI_K3_CPPI_DESC_POOL
depends on PRU_REMOTEPROC
depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
help
diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
index e38ec9d6c99b..27de1d697134 100644
--- a/drivers/net/ethernet/ti/Makefile
+++ b/drivers/net/ethernet/ti/Makefile
@@ -23,14 +23,15 @@ keystone_netcp-y := netcp_core.o cpsw_ale.o
obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o
keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.o

+obj-$(CONFIG_TI_K3_CPPI_DESC_POOL) += k3-cppi-desc-pool.o
+
obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
-ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o k3-cppi-desc-pool.o am65-cpsw-qos.o
+ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o am65-cpsw-qos.o
ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o
obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o

obj-$(CONFIG_TI_ICSSG_PRUETH) += icssg-prueth.o
-icssg-prueth-y := k3-cppi-desc-pool.o \
- icssg/icssg_prueth.o \
+icssg-prueth-y := icssg/icssg_prueth.o \
icssg/icssg_classifier.o \
icssg/icssg_queues.o \
icssg/icssg_config.o \
diff --git a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
index 38cc12f9f133..1d9b456edff4 100644
--- a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
+++ b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
@@ -39,6 +39,7 @@ void k3_cppi_desc_pool_destroy(struct k3_cppi_desc_pool *pool)

gen_pool_destroy(pool->gen_pool); /* frees pool->name */
}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_destroy);

struct k3_cppi_desc_pool *
k3_cppi_desc_pool_create_name(struct device *dev, size_t size,
@@ -98,29 +99,35 @@ k3_cppi_desc_pool_create_name(struct device *dev, size_t size,
devm_kfree(pool->dev, pool);
return ERR_PTR(ret);
}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_create_name);

dma_addr_t k3_cppi_desc_pool_virt2dma(struct k3_cppi_desc_pool *pool,
void *addr)
{
return addr ? pool->dma_addr + (addr - pool->cpumem) : 0;
}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_virt2dma);

void *k3_cppi_desc_pool_dma2virt(struct k3_cppi_desc_pool *pool, dma_addr_t dma)
{
return dma ? pool->cpumem + (dma - pool->dma_addr) : NULL;
}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_dma2virt);

void *k3_cppi_desc_pool_alloc(struct k3_cppi_desc_pool *pool)
{
return (void *)gen_pool_alloc(pool->gen_pool, pool->desc_size);
}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_alloc);

void k3_cppi_desc_pool_free(struct k3_cppi_desc_pool *pool, void *addr)
{
gen_pool_free(pool->gen_pool, (unsigned long)addr, pool->desc_size);
}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_free);

size_t k3_cppi_desc_pool_avail(struct k3_cppi_desc_pool *pool)
{
return gen_pool_avail(pool->gen_pool) / pool->desc_size;
}
+EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_avail);

base-commit: e8c127b0576660da9195504fe8393fe9da3de9ce
--
2.34.1


2023-10-13 10:39:01

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

On Fri, Oct 13, 2023, at 12:05, MD Danish Anwar wrote:
> With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
> k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
> the expected CFLAGS are different between builtins and modules.
>
> The build system is complaining about the following:
>
> k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
> ti-am65-cpsw-nuss
>
> Introduce the new module, k3-cppi-desc-pool, to provide the common
> functions to ti-am65-cpsw-nuss and icssg-prueth.
>
> Signed-off-by: MD Danish Anwar <[email protected]>

I submitted a different patch for this a while ago:
https://lore.kernel.org/lkml/[email protected]/

I think I never sent a v2 of that, but I still have a
working version in my local tree. I've replaced my version
with yours for testing now, to see if you still need something
beyond that.

Arnd

2023-10-13 11:12:00

by MD Danish Anwar

[permalink] [raw]
Subject: Re: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

Hi Arnd,

On 13/10/23 16:08, Arnd Bergmann wrote:
> On Fri, Oct 13, 2023, at 12:05, MD Danish Anwar wrote:
>> With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
>> k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
>> the expected CFLAGS are different between builtins and modules.
>>
>> The build system is complaining about the following:
>>
>> k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
>> ti-am65-cpsw-nuss
>>
>> Introduce the new module, k3-cppi-desc-pool, to provide the common
>> functions to ti-am65-cpsw-nuss and icssg-prueth.
>>
>> Signed-off-by: MD Danish Anwar <[email protected]>
>
> I submitted a different patch for this a while ago:
> https://lore.kernel.org/lkml/[email protected]/
>
> I think I never sent a v2 of that, but I still have a
> working version in my local tree. I've replaced my version
> with yours for testing now, to see if you still need something
> beyond that.
>

I see your patch addresses different modules. My patch introduces a new
module for k3-cppi-desc-pool which is used by both am65-cpsw-nuss and
icssg-prueth driver. Where as your patch addresses modules common across
different cpsw drivers (davinci-emac, cpsw, cpsw-switchdev, netcp,
netcp_ethss and am65-cpsw-nuss). So I think that both these patches are
addressing differet warnings.

> Arnd

--
Thanks and Regards,
Danish

2023-10-13 15:28:59

by Alexander Lobakin

[permalink] [raw]
Subject: Re: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

From: Md Danish Anwar <[email protected]>
Date: Fri, 13 Oct 2023 15:35:49 +0530

> With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
> k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
> the expected CFLAGS are different between builtins and modules.
>
> The build system is complaining about the following:
>
> k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
> ti-am65-cpsw-nuss

I also fixed a bunch of these in the ethernet/ti/ folder a year ago[0],
you can take a look. I never made it to the upstream branches since I
took a rest from my home Linux projects and never got back to them yet :P

>
> Introduce the new module, k3-cppi-desc-pool, to provide the common
> functions to ti-am65-cpsw-nuss and icssg-prueth.

[...]

[0] https://lore.kernel.org/all/[email protected]

Thanks,
Olek

2023-10-17 11:07:25

by Paolo Abeni

[permalink] [raw]
Subject: Re: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

On Fri, 2023-10-13 at 15:35 +0530, MD Danish Anwar wrote:
> With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
> k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
> the expected CFLAGS are different between builtins and modules.
>
> The build system is complaining about the following:
>
> k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
> ti-am65-cpsw-nuss
>
> Introduce the new module, k3-cppi-desc-pool, to provide the common
> functions to ti-am65-cpsw-nuss and icssg-prueth.
>
> Signed-off-by: MD Danish Anwar <[email protected]>

Given that you target the -net tree, please include a suitable fixes
tag, thanks!

Paolo

2023-10-17 11:38:55

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

On Fri, Oct 13, 2023, at 13:10, MD Danish Anwar wrote:
> On 13/10/23 16:08, Arnd Bergmann wrote:
>> On Fri, Oct 13, 2023, at 12:05, MD Danish Anwar wrote:
>>> With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
>>> k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
>>> the expected CFLAGS are different between builtins and modules.
>>>
>>> The build system is complaining about the following:
>>>
>>> k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
>>> ti-am65-cpsw-nuss
>>>
>>> Introduce the new module, k3-cppi-desc-pool, to provide the common
>>> functions to ti-am65-cpsw-nuss and icssg-prueth.
>>>
>>> Signed-off-by: MD Danish Anwar <[email protected]>
>>
>> I submitted a different patch for this a while ago:
>> https://lore.kernel.org/lkml/[email protected]/
>>
>> I think I never sent a v2 of that, but I still have a
>> working version in my local tree. I've replaced my version
>> with yours for testing now, to see if you still need something
>> beyond that.
>>
>
> I see your patch addresses different modules. My patch introduces a new
> module for k3-cppi-desc-pool which is used by both am65-cpsw-nuss and
> icssg-prueth driver. Where as your patch addresses modules common across
> different cpsw drivers (davinci-emac, cpsw, cpsw-switchdev, netcp,
> netcp_ethss and am65-cpsw-nuss). So I think that both these patches are
> addressing differet warnings.

Right, I can resend my patch (or Alexander Lobakin can rebase his version)
after yours makes it in. Note that your patch introduces a warning about
a missing license and description for the new module, so you should
probably include this hunk:

--- a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
+++ b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
@@ -131,3 +131,6 @@ size_t k3_cppi_desc_pool_avail(struct k3_cppi_desc_pool *pool)
return gen_pool_avail(pool->gen_pool) / pool->desc_size;
}
EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_avail);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("TI K3 CPPI5 descriptors pool API");

2023-10-18 04:29:00

by MD Danish Anwar

[permalink] [raw]
Subject: Re: [EXTERNAL] Re: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

On 17/10/23 4:34 pm, Paolo Abeni wrote:
> On Fri, 2023-10-13 at 15:35 +0530, MD Danish Anwar wrote:
>> With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
>> k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
>> the expected CFLAGS are different between builtins and modules.
>>
>> The build system is complaining about the following:
>>
>> k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
>> ti-am65-cpsw-nuss
>>
>> Introduce the new module, k3-cppi-desc-pool, to provide the common
>> functions to ti-am65-cpsw-nuss and icssg-prueth.
>>
>> Signed-off-by: MD Danish Anwar <[email protected]>
>
> Given that you target the -net tree, please include a suitable fixes
> tag, thanks!
>

Sure. I'll add the proper fixes tag in commit message and send next
revision.

> Paolo
>

--
Thanks and Regards,
Danish

2023-10-18 04:29:41

by MD Danish Anwar

[permalink] [raw]
Subject: Re: [EXTERNAL] Re: [PATCH net] net: ethernet: ti: Fix mixed module-builtin object

On 17/10/23 5:08 pm, Arnd Bergmann wrote:
> On Fri, Oct 13, 2023, at 13:10, MD Danish Anwar wrote:
>> On 13/10/23 16:08, Arnd Bergmann wrote:
>>> On Fri, Oct 13, 2023, at 12:05, MD Danish Anwar wrote:
>>>> With CONFIG_TI_K3_AM65_CPSW_NUSS=y and CONFIG_TI_ICSSG_PRUETH=m,
>>>> k3-cppi-desc-pool.o is linked to a module and also to vmlinux even though
>>>> the expected CFLAGS are different between builtins and modules.
>>>>
>>>> The build system is complaining about the following:
>>>>
>>>> k3-cppi-desc-pool.o is added to multiple modules: icssg-prueth
>>>> ti-am65-cpsw-nuss
>>>>
>>>> Introduce the new module, k3-cppi-desc-pool, to provide the common
>>>> functions to ti-am65-cpsw-nuss and icssg-prueth.
>>>>
>>>> Signed-off-by: MD Danish Anwar <[email protected]>
>>>
>>> I submitted a different patch for this a while ago:
>>> https://lore.kernel.org/lkml/[email protected]/
>>>
>>> I think I never sent a v2 of that, but I still have a
>>> working version in my local tree. I've replaced my version
>>> with yours for testing now, to see if you still need something
>>> beyond that.
>>>
>>
>> I see your patch addresses different modules. My patch introduces a new
>> module for k3-cppi-desc-pool which is used by both am65-cpsw-nuss and
>> icssg-prueth driver. Where as your patch addresses modules common across
>> different cpsw drivers (davinci-emac, cpsw, cpsw-switchdev, netcp,
>> netcp_ethss and am65-cpsw-nuss). So I think that both these patches are
>> addressing differet warnings.
>
> Right, I can resend my patch (or Alexander Lobakin can rebase his version)
> after yours makes it in. Note that your patch introduces a warning about
> a missing license and description for the new module, so you should
> probably include this hunk:
>

Sure Arnd, I'll add this and send v2.

> --- a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
> +++ b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
> @@ -131,3 +131,6 @@ size_t k3_cppi_desc_pool_avail(struct k3_cppi_desc_pool *pool)
> return gen_pool_avail(pool->gen_pool) / pool->desc_size;
> }
> EXPORT_SYMBOL_GPL(k3_cppi_desc_pool_avail);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("TI K3 CPPI5 descriptors pool API");

--
Thanks and Regards,
Danish