diff mbox series

[net] octeontx2-af: Fix QMEM struct memory allocation

Message ID 20230103040917.16151-1-gakula@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] octeontx2-af: Fix QMEM struct memory allocation | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: lcherian@marvell.com jerinj@marvell.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 21 this patch: 21
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Geetha sowjanya Jan. 3, 2023, 4:09 a.m. UTC
Currently NIX, NPA queue context memory is being allocated using
GFP_KERNEL flag which inturns allocates from memory reserved for
CMA_DMA. Sizing CMA_DMA memory is getting difficult due to this
dependency, the more number of interfaces enabled the more the
CMA_DMA memory requirement.

To address this issue, GFP_KERNEL flag is replaced with GFP_ATOMIC,
with this memory will be allocated from unreserved memory.

Fixes: 7a37245ef23f ("octeontx2-af: NPA block admin queue init")
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: Geetha sowjanya <gakula@marvell.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pavan Chebbi Jan. 3, 2023, 9 a.m. UTC | #1
On Tue, Jan 3, 2023 at 9:39 AM Geetha sowjanya <gakula@marvell.com> wrote:
>
> Currently NIX, NPA queue context memory is being allocated using
> GFP_KERNEL flag which inturns allocates from memory reserved for
> CMA_DMA. Sizing CMA_DMA memory is getting difficult due to this
> dependency, the more number of interfaces enabled the more the
> CMA_DMA memory requirement.
>
> To address this issue, GFP_KERNEL flag is replaced with GFP_ATOMIC,
> with this memory will be allocated from unreserved memory.
>
> Fixes: 7a37245ef23f ("octeontx2-af: NPA block admin queue init")
> Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
> Signed-off-by: Geetha sowjanya <gakula@marvell.com>
> ---
>  drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/common.h b/drivers/net/ethernet/marvell/octeontx2/af/common.h
> index 8931864ee110..4b4be9ca4d2f 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/common.h
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/common.h
> @@ -61,7 +61,7 @@ static inline int qmem_alloc(struct device *dev, struct qmem **q,
>         qmem->entry_sz = entry_sz;
>         qmem->alloc_sz = (qsize * entry_sz) + OTX2_ALIGN;
>         qmem->base = dma_alloc_attrs(dev, qmem->alloc_sz, &qmem->iova,
> -                                    GFP_KERNEL, DMA_ATTR_FORCE_CONTIGUOUS);
> +                                    GFP_ATOMIC, DMA_ATTR_FORCE_CONTIGUOUS);

I am not understanding the problem this change is solving. Can you
describe the issue in some detail?
What do you mean when you say GFP_ATOMIC allocates the memory from
unreserved memory?

>         if (!qmem->base)
>                 return -ENOMEM;
>
> --
> 2.25.1
>
Leon Romanovsky Jan. 3, 2023, 10:05 a.m. UTC | #2
On Tue, Jan 03, 2023 at 09:39:17AM +0530, Geetha sowjanya wrote:
> Currently NIX, NPA queue context memory is being allocated using
> GFP_KERNEL flag which inturns allocates from memory reserved for
> CMA_DMA. Sizing CMA_DMA memory is getting difficult due to this
> dependency, the more number of interfaces enabled the more the
> CMA_DMA memory requirement.
> 
> To address this issue, GFP_KERNEL flag is replaced with GFP_ATOMIC,
> with this memory will be allocated from unreserved memory.

No, GFP_ATOMIC is for memory allocations in atomic context and not for
separation between reserved and unreserved memory.

There is no any explanation to use GFP_ATOMIC except being in atomic
context.

Thanks
Jakub Kicinski Jan. 4, 2023, 3:13 a.m. UTC | #3
On Tue, 3 Jan 2023 12:05:51 +0200 Leon Romanovsky wrote:
> No, GFP_ATOMIC is for memory allocations in atomic context and not for
> separation between reserved and unreserved memory.

Indeed, using ATOMIC to avoid CMA seems like an odd hack.
I haven't encountered this before.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/common.h b/drivers/net/ethernet/marvell/octeontx2/af/common.h
index 8931864ee110..4b4be9ca4d2f 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/common.h
@@ -61,7 +61,7 @@  static inline int qmem_alloc(struct device *dev, struct qmem **q,
 	qmem->entry_sz = entry_sz;
 	qmem->alloc_sz = (qsize * entry_sz) + OTX2_ALIGN;
 	qmem->base = dma_alloc_attrs(dev, qmem->alloc_sz, &qmem->iova,
-				     GFP_KERNEL, DMA_ATTR_FORCE_CONTIGUOUS);
+				     GFP_ATOMIC, DMA_ATTR_FORCE_CONTIGUOUS);
 	if (!qmem->base)
 		return -ENOMEM;