diff mbox series

[1/2] wifi: mwifiex: simplify PCIE DMA mapping management

Message ID 20230802161049.89326-1-dmantipov@yandex.ru
State New
Headers show
Series [1/2] wifi: mwifiex: simplify PCIE DMA mapping management | expand

Commit Message

Dmitry Antipov Aug. 2, 2023, 4:09 p.m. UTC
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 <dmantipov@yandex.ru>
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 14 +++++------
 drivers/net/wireless/marvell/mwifiex/util.h | 27 +++------------------
 2 files changed, 10 insertions(+), 31 deletions(-)

Comments

Kalle Valo Aug. 23, 2023, 10:25 a.m. UTC | #1
Dmitry Antipov <dmantipov@yandex.ru> 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 <dmantipov@yandex.ru>

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
Brian Norris Aug. 23, 2023, 7:49 p.m. UTC | #2
On Wed, Aug 23, 2023 at 3:25 AM Kalle Valo <kvalo@kernel.org> wrote:
>
> Dmitry Antipov <dmantipov@yandex.ru> 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 <dmantipov@yandex.ru>
>
> 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.

If Dmitry can prove out some proper testing, maybe the status can
change [1]. Or maybe I'll feel charitable and look/test them more
closely.

Brian

[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.
Kalle Valo Aug. 25, 2023, 7:13 a.m. UTC | #3
Brian Norris <briannorris@chromium.org> writes:

> On Wed, Aug 23, 2023 at 3:25 AM Kalle Valo <kvalo@kernel.org> wrote:
>>
>> Dmitry Antipov <dmantipov@yandex.ru> 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 <dmantipov@yandex.ru>
>>
>> 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.
diff mbox series

Patch

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);