Skip to contentSkip to conversation

octeontx2-af: Fix QMEM struct memory allocation

PATCH In review Geetha sowjanya 4 participants 4 messages Jan 3, 2023 – Jan 4, 2023

Subsystems (3)
lore
Share & tools
lore

Geetha sowjanya

author maintainer
#0 lore raw

PATCH 1/1 octeontx2-af: Fix QMEM struct memory allocation

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")
---
 drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/common.h +1 -1
index 8931864ee110..4b4be9ca4d2f 100644
@@ -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;
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 22 lines · Geetha sowjanya

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")
---
 drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/common.h +0 -0
index 8931864ee110..4b4be9ca4d2f 100644

drivers/net/ethernet/marvell/octeontx2/af/common.h static inline int qmem_alloc(struct device *dev, struct qmem **q, · line 64

Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/common.h +1 -1
@@ -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?

Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/common.h +0 -1
        if (!qmem->base)
                return -ENOMEM;
 
--

2.25.1

#2 lore raw
In reply to Geetha sowjanya
Quoted 8 lines · Geetha sowjanya

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

maintainer
#3 lore raw
Quoted 2 lines · 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.