From: Chenguang Zhao <chenguang.zhao@linux.dev>
To: Andrew Lunn <andrew@lunn.ch>
Cc: marcin.s.wojtas@gmail.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
Chenguang Zhao <zhaochenguang@kylinos.cn>
Subject: Re: [PATCH net] net: mvneta_bm: fix gen_pool_free address for BPPI
Date: Thu, 6 Aug 2026 16:13:32 +0800 [thread overview]
Message-ID: <8358b477-5dad-40cf-949b-bac905253be6@linux.dev> (raw)
In-Reply-To: <8a46fda8-79a7-44c6-b4ef-2ca66c4dc3c0@lunn.ch>
在 2026/8/5 21:12, Andrew Lunn 写道:
> On Wed, Aug 05, 2026 at 02:14:38PM +0800, Chenguang Zhao wrote:
>> From: Chenguang Zhao <zhaochenguang@kylinos.cn>
>>
>> gen_pool_free() expects the virtual address returned by
>> gen_pool_dma_alloc(), not the physical address. Passing phys can miss
>> the chunk and trigger BUG() on remove or probe rollback.
>>
>> Fixes: dc35a10f68d3 ("net: mvneta: bm: add support for hardware buffer management")
>> Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
>> ---
>> drivers/net/ethernet/marvell/mvneta_bm.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/marvell/mvneta_bm.c b/drivers/net/ethernet/marvell/mvneta_bm.c
>> index 6bb380494919..2a114a69a0ab 100644
>> --- a/drivers/net/ethernet/marvell/mvneta_bm.c
>> +++ b/drivers/net/ethernet/marvell/mvneta_bm.c
>> @@ -389,7 +389,7 @@ static int mvneta_bm_get_sram(struct device_node *dn,
>>
>> static void mvneta_bm_put_sram(struct mvneta_bm *priv)
>> {
>> - gen_pool_free(priv->bppi_pool, priv->bppi_phys_addr,
>> + gen_pool_free(priv->bppi_pool, (unsigned long)priv->bppi_virt_addr,
> The cast is ugly, but it also seems correct. However, can the API be
> improved. If the intention is
>
> gen_pool_free(priv->bppi_pool,
> gen_pool_dma_alloc(priv->bppi_pool,
> MVNETA_BM_BPPI_SIZE,
> &priv->bppi_phys_addr),
> MVNETA_BM_BPPI_SIZE);
>
> maybe gen_pool_free() should be changed to take a void *?
>
> Andrew
Thanks for the suggestion.
The cast is indeed a bit ugly, but several other drivers free memory from
gen_pool_dma_alloc() in the same way today. Changing gen_pool_free()
itself to take a void * would touch quite a few call sites, including
ones that use genalloc for non-pointer cookies, so that may be a larger
change than we want for this fix.
If we do want to improve the API, perhaps a small helper would be enough,
for example:
static inline void gen_pool_dma_free(struct gen_pool *pool, void *vaddr,
size_t size)
{
gen_pool_free(pool, (unsigned long)vaddr, size);
}
Does that sound reasonable to you? I'm happy to keep this bugfix as-is
for now, or follow up with such a helper if preferred.
Chenguang
next prev parent reply other threads:[~2026-08-06 8:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 6:14 [PATCH net] net: mvneta_bm: fix gen_pool_free address for BPPI Chenguang Zhao
2026-08-05 13:12 ` Andrew Lunn
2026-08-06 8:13 ` Chenguang Zhao [this message]
2026-08-06 16:16 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8358b477-5dad-40cf-949b-bac905253be6@linux.dev \
--to=chenguang.zhao@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=marcin.s.wojtas@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=zhaochenguang@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.