LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API
@ 2021-08-27 19:56 Christophe JAILLET
2021-08-28 1:34 ` Geoff Levand
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Christophe JAILLET @ 2021-08-27 19:56 UTC (permalink / raw)
To: kou.ishizaki, geoff, davem, kuba
Cc: netdev, linuxppc-dev, linux-kernel, kernel-janitors, Christophe JAILLET
In [1], Christoph Hellwig has proposed to remove the wrappers in
include/linux/pci-dma-compat.h.
Some reasons why this API should be removed have been given by Julia
Lawall in [2].
A coccinelle script has been used to perform the needed transformation
Only relevant parts are given below.
@@ @@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@ @@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@ @@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
[1]: https://lore.kernel.org/kernel-janitors/20200421081257.GA131897@infradead.org/
[2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.2007120902170.2424@hadrien/
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
It has *not* been compile tested because I don't have the needed
configuration or cross-compiler. However, the modification is completely
mechanical and done by coccinelle.
---
drivers/net/ethernet/toshiba/spider_net.c | 27 +++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c
index 087f0af56c50..66d4e024d11e 100644
--- a/drivers/net/ethernet/toshiba/spider_net.c
+++ b/drivers/net/ethernet/toshiba/spider_net.c
@@ -354,9 +354,10 @@ spider_net_free_rx_chain_contents(struct spider_net_card *card)
descr = card->rx_chain.head;
do {
if (descr->skb) {
- pci_unmap_single(card->pdev, descr->hwdescr->buf_addr,
+ dma_unmap_single(&card->pdev->dev,
+ descr->hwdescr->buf_addr,
SPIDER_NET_MAX_FRAME,
- PCI_DMA_BIDIRECTIONAL);
+ DMA_BIDIRECTIONAL);
dev_kfree_skb(descr->skb);
descr->skb = NULL;
}
@@ -411,9 +412,9 @@ spider_net_prepare_rx_descr(struct spider_net_card *card,
if (offset)
skb_reserve(descr->skb, SPIDER_NET_RXBUF_ALIGN - offset);
/* iommu-map the skb */
- buf = pci_map_single(card->pdev, descr->skb->data,
- SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
- if (pci_dma_mapping_error(card->pdev, buf)) {
+ buf = dma_map_single(&card->pdev->dev, descr->skb->data,
+ SPIDER_NET_MAX_FRAME, DMA_FROM_DEVICE);
+ if (dma_mapping_error(&card->pdev->dev, buf)) {
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
if (netif_msg_rx_err(card) && net_ratelimit())
@@ -653,8 +654,9 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
dma_addr_t buf;
unsigned long flags;
- buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
- if (pci_dma_mapping_error(card->pdev, buf)) {
+ buf = dma_map_single(&card->pdev->dev, skb->data, skb->len,
+ DMA_TO_DEVICE);
+ if (dma_mapping_error(&card->pdev->dev, buf)) {
if (netif_msg_tx_err(card) && net_ratelimit())
dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). "
"Dropping packet\n", skb->data, skb->len);
@@ -666,7 +668,8 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
descr = card->tx_chain.head;
if (descr->next == chain->tail->prev) {
spin_unlock_irqrestore(&chain->lock, flags);
- pci_unmap_single(card->pdev, buf, skb->len, PCI_DMA_TODEVICE);
+ dma_unmap_single(&card->pdev->dev, buf, skb->len,
+ DMA_TO_DEVICE);
return -ENOMEM;
}
hwdescr = descr->hwdescr;
@@ -822,8 +825,8 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
/* unmap the skb */
if (skb) {
- pci_unmap_single(card->pdev, buf_addr, skb->len,
- PCI_DMA_TODEVICE);
+ dma_unmap_single(&card->pdev->dev, buf_addr, skb->len,
+ DMA_TO_DEVICE);
dev_consume_skb_any(skb);
}
}
@@ -1165,8 +1168,8 @@ spider_net_decode_one_descr(struct spider_net_card *card)
/* unmap descriptor */
hw_buf_addr = hwdescr->buf_addr;
hwdescr->buf_addr = 0xffffffff;
- pci_unmap_single(card->pdev, hw_buf_addr,
- SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
+ dma_unmap_single(&card->pdev->dev, hw_buf_addr, SPIDER_NET_MAX_FRAME,
+ DMA_FROM_DEVICE);
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
(status == SPIDER_NET_DESCR_PROTECTION_ERROR) ||
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API
2021-08-27 19:56 [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API Christophe JAILLET
@ 2021-08-28 1:34 ` Geoff Levand
2021-08-29 0:09 ` Geoff Levand
2021-08-29 8:01 ` Christophe Leroy
2021-08-29 10:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Geoff Levand @ 2021-08-28 1:34 UTC (permalink / raw)
To: Christophe JAILLET, kou.ishizaki, davem, kuba
Cc: netdev, linuxppc-dev, linux-kernel, kernel-janitors
Hi Christophe,
On 8/27/21 12:56 PM, Christophe JAILLET wrote:
> It has *not* been compile tested because I don't have the needed
> configuration or cross-compiler.
The powerpc ppc64_defconfig has CONFIG_SPIDER_NET set. My
tdd-builder Docker image has the needed gcc-powerpc-linux-gnu
cross compiler to build ppc64_defconfig:
https://hub.docker.com/r/glevand/tdd-builder
-Geoff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API
2021-08-28 1:34 ` Geoff Levand
@ 2021-08-29 0:09 ` Geoff Levand
0 siblings, 0 replies; 6+ messages in thread
From: Geoff Levand @ 2021-08-29 0:09 UTC (permalink / raw)
To: Christophe JAILLET, kou.ishizaki, davem, kuba
Cc: netdev, linuxppc-dev, linux-kernel, kernel-janitors
Hi Christophe,
On 8/27/21 6:34 PM, Geoff Levand wrote:
> On 8/27/21 12:56 PM, Christophe JAILLET wrote:
>> It has *not* been compile tested because I don't have the needed
>> configuration or cross-compiler.
>
> The powerpc ppc64_defconfig has CONFIG_SPIDER_NET set. My
> tdd-builder Docker image has the needed gcc-powerpc-linux-gnu
> cross compiler to build ppc64_defconfig:
>
> https://hub.docker.com/r/glevand/tdd-builder
Just to follow up, I applied your patch to v5.14-rc7 and built
ppc64_defconfig. No warnings or errors were seen.
Thanks for your contribution.
Acked-by: Geoff Levand <geoff@infradead.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API
2021-08-27 19:56 [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API Christophe JAILLET
2021-08-28 1:34 ` Geoff Levand
@ 2021-08-29 8:01 ` Christophe Leroy
2021-08-29 12:25 ` Michael Ellerman
2021-08-29 10:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Christophe Leroy @ 2021-08-29 8:01 UTC (permalink / raw)
To: Christophe JAILLET, kou.ishizaki, geoff, davem, kuba
Cc: netdev, kernel-janitors, linuxppc-dev, linux-kernel
Le 27/08/2021 à 21:56, Christophe JAILLET a écrit :
> ---
> It has *not* been compile tested because I don't have the needed
> configuration or cross-compiler. However, the modification is completely
> mechanical and done by coccinelle.
All you need is at https://mirrors.edge.kernel.org/pub/tools/crosstool/
Christophe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API
2021-08-27 19:56 [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API Christophe JAILLET
2021-08-28 1:34 ` Geoff Levand
2021-08-29 8:01 ` Christophe Leroy
@ 2021-08-29 10:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-29 10:00 UTC (permalink / raw)
To: Christophe JAILLET
Cc: kou.ishizaki, geoff, davem, kuba, netdev, linuxppc-dev,
linux-kernel, kernel-janitors
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Fri, 27 Aug 2021 21:56:28 +0200 you wrote:
> In [1], Christoph Hellwig has proposed to remove the wrappers in
> include/linux/pci-dma-compat.h.
>
> Some reasons why this API should be removed have been given by Julia
> Lawall in [2].
>
> A coccinelle script has been used to perform the needed transformation
> Only relevant parts are given below.
>
> [...]
Here is the summary with links:
- net: spider_net: switch from 'pci_' to 'dma_' API
https://git.kernel.org/netdev/net-next/c/27d57f85102b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API
2021-08-29 8:01 ` Christophe Leroy
@ 2021-08-29 12:25 ` Michael Ellerman
0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2021-08-29 12:25 UTC (permalink / raw)
To: Christophe Leroy, Christophe JAILLET, kou.ishizaki, geoff, davem, kuba
Cc: netdev, kernel-janitors, linuxppc-dev, linux-kernel
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 27/08/2021 à 21:56, Christophe JAILLET a écrit :
>> ---
>> It has *not* been compile tested because I don't have the needed
>> configuration or cross-compiler. However, the modification is completely
>> mechanical and done by coccinelle.
>
> All you need is at https://mirrors.edge.kernel.org/pub/tools/crosstool/
There's also some instructions here for using distro toolchains:
https://github.com/linuxppc/wiki/wiki/Building-powerpc-kernels
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-29 12:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 19:56 [PATCH] net: spider_net: switch from 'pci_' to 'dma_' API Christophe JAILLET
2021-08-28 1:34 ` Geoff Levand
2021-08-29 0:09 ` Geoff Levand
2021-08-29 8:01 ` Christophe Leroy
2021-08-29 12:25 ` Michael Ellerman
2021-08-29 10:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).