2023-08-02 16:50:28

by Dmitry Antipov

[permalink] [raw]
Subject: [PATCH 1/2] wifi: mwifiex: simplify PCIE DMA mapping management

Simplify PCIE DMA mapping management by eliminating extra copies
of {address, size} pairs to/from temporary data structures. Map
and unmap operations may use skb fields directly via introduced
'MWIFIEX_SKB_DMA_ADDR()' and 'MWIFIEX_SKB_DMA_SIZE()' macros.

Signed-off-by: Dmitry Antipov <[email protected]>
---
drivers/net/wireless/marvell/mwifiex/pcie.c | 14 +++++------
drivers/net/wireless/marvell/mwifiex/util.h | 27 +++------------------
2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 6697132ecc97..4c7c17fd2387 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -197,15 +197,14 @@ mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb,
size_t size, int flags)
{
struct pcie_service_card *card = adapter->card;
- struct mwifiex_dma_mapping mapping;

- mapping.addr = dma_map_single(&card->dev->dev, skb->data, size, flags);
- if (dma_mapping_error(&card->dev->dev, mapping.addr)) {
+ MWIFIEX_SKB_DMA_ADDR(skb) = dma_map_single(&card->dev->dev, skb->data,
+ size, flags);
+ if (dma_mapping_error(&card->dev->dev, MWIFIEX_SKB_DMA_ADDR(skb))) {
mwifiex_dbg(adapter, ERROR, "failed to map pci memory!\n");
return -1;
}
- mapping.len = size;
- mwifiex_store_mapping(skb, &mapping);
+ MWIFIEX_SKB_DMA_SIZE(skb) = size;
return 0;
}

@@ -213,10 +212,9 @@ static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter,
struct sk_buff *skb, int flags)
{
struct pcie_service_card *card = adapter->card;
- struct mwifiex_dma_mapping mapping;

- mwifiex_get_mapping(skb, &mapping);
- dma_unmap_single(&card->dev->dev, mapping.addr, mapping.len, flags);
+ dma_unmap_single(&card->dev->dev, MWIFIEX_SKB_DMA_ADDR(skb),
+ MWIFIEX_SKB_DMA_SIZE(skb), flags);
}

/*
diff --git a/drivers/net/wireless/marvell/mwifiex/util.h b/drivers/net/wireless/marvell/mwifiex/util.h
index 4699c505c0a0..495f1a74b62d 100644
--- a/drivers/net/wireless/marvell/mwifiex/util.h
+++ b/drivers/net/wireless/marvell/mwifiex/util.h
@@ -53,30 +53,11 @@ static inline struct mwifiex_txinfo *MWIFIEX_SKB_TXCB(struct sk_buff *skb)
return &cb->tx_info;
}

-static inline void mwifiex_store_mapping(struct sk_buff *skb,
- struct mwifiex_dma_mapping *mapping)
-{
- struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
-
- memcpy(&cb->dma_mapping, mapping, sizeof(*mapping));
-}
-
-static inline void mwifiex_get_mapping(struct sk_buff *skb,
- struct mwifiex_dma_mapping *mapping)
-{
- struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
+#define MWIFIEX_SKB_DMA_ADDR(skb) \
+ (((struct mwifiex_cb *)((skb)->cb))->dma_mapping.addr)

- memcpy(mapping, &cb->dma_mapping, sizeof(*mapping));
-}
-
-static inline dma_addr_t MWIFIEX_SKB_DMA_ADDR(struct sk_buff *skb)
-{
- struct mwifiex_dma_mapping mapping;
-
- mwifiex_get_mapping(skb, &mapping);
-
- return mapping.addr;
-}
+#define MWIFIEX_SKB_DMA_SIZE(skb) \
+ (((struct mwifiex_cb *)((skb)->cb))->dma_mapping.len)

int mwifiex_debug_info_to_buffer(struct mwifiex_private *priv, char *buf,
struct mwifiex_debug_info *info);
--
2.41.0



2023-08-23 11:13:53

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: mwifiex: simplify PCIE DMA mapping management

Dmitry Antipov <[email protected]> wrote:

> Simplify PCIE DMA mapping management by eliminating extra copies
> of {address, size} pairs to/from temporary data structures. Map
> and unmap operations may use skb fields directly via introduced
> 'MWIFIEX_SKB_DMA_ADDR()' and 'MWIFIEX_SKB_DMA_SIZE()' macros.
>
> Signed-off-by: Dmitry Antipov <[email protected]>

I assume these patches are compile tested only so I'm very reluctant
take these.

2 patches set to Changes Requested.

13338499 [1/2] wifi: mwifiex: simplify PCIE DMA mapping management
13338500 [2/2] wifi: mwifiex: avoid indirection in PCIE buffer descriptor management

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


2023-08-25 08:41:47

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: mwifiex: simplify PCIE DMA mapping management

Brian Norris <[email protected]> writes:

> On Wed, Aug 23, 2023 at 3:25 AM Kalle Valo <[email protected]> wrote:
>>
>> Dmitry Antipov <[email protected]> wrote:
>>
>> > Simplify PCIE DMA mapping management by eliminating extra copies
>> > of {address, size} pairs to/from temporary data structures. Map
>> > and unmap operations may use skb fields directly via introduced
>> > 'MWIFIEX_SKB_DMA_ADDR()' and 'MWIFIEX_SKB_DMA_SIZE()' macros.
>> >
>> > Signed-off-by: Dmitry Antipov <[email protected]>
>>
>> I assume these patches are compile tested only so I'm very reluctant
>> take these.
>>
>> 2 patches set to Changes Requested.
>
> That's fair IMO. These kinds of patches put a much larger burden on
> the reviewer to make sure they make sense. Thus, I had this in a
> backlog to review, and haven't gotten around to it.

I'm looking at this from risk vs reward point of view. The risk is that
these cause regressions which is of course more work for us maintainers
but I'm not really seeing any concrete benefit from these patches.

> [1] Although, I don't think I have permission to change the Patchwork
> status, so it still might be lost to /dev/null without a RESEND.

I can change the status by request, not a problem. We could also setup
you admin access to patchwork.

BTW with ath9k patches we do so that patchwork first assigns the patches
automatically to Toke. Once Toke has reviewed the patches he either
drops of them or assigns them for me so I can commit them. At least from
my point of view that works really well, do let me know if you would
like to try something like that.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches