* [PATCH 1/5] net: hns3: remove unnecessary devm_kfree
2020-06-18 1:02 [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes Barry Song
@ 2020-06-18 1:02 ` Barry Song
2020-06-18 1:02 ` [PATCH 2/5] net: hns3: pointer type of buffer should be void Barry Song
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Barry Song @ 2020-06-18 1:02 UTC (permalink / raw)
To: davem, kuba
Cc: yisen.zhuang, salil.mehta, netdev, linyunsheng, linux-kernel,
linuxarm, Barry Song
since we are using device-managed function, it is unnecessary
to free in probe.
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index b14f2abc2425..1817d7f2e5f6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2097,10 +2097,8 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_drvdata(pdev, ae_dev);
ret = hnae3_register_ae_dev(ae_dev);
- if (ret) {
- devm_kfree(&pdev->dev, ae_dev);
+ if (ret)
pci_set_drvdata(pdev, NULL);
- }
return ret;
}
@@ -2157,7 +2155,6 @@ static void hns3_shutdown(struct pci_dev *pdev)
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
hnae3_unregister_ae_dev(ae_dev);
- devm_kfree(&pdev->dev, ae_dev);
pci_set_drvdata(pdev, NULL);
if (system_state == SYSTEM_POWER_OFF)
--
2.23.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 2/5] net: hns3: pointer type of buffer should be void
2020-06-18 1:02 [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes Barry Song
2020-06-18 1:02 ` [PATCH 1/5] net: hns3: remove unnecessary devm_kfree Barry Song
@ 2020-06-18 1:02 ` Barry Song
2020-06-18 23:35 ` Jakub Kicinski
2020-06-18 1:02 ` [PATCH 3/5] net: hns3: rename buffer-related functions Barry Song
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Barry Song @ 2020-06-18 1:02 UTC (permalink / raw)
To: davem, kuba
Cc: yisen.zhuang, salil.mehta, netdev, linyunsheng, linux-kernel,
linuxarm, Barry Song
Move the type of buffer address from unsigned char to void
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 1817d7f2e5f6..61b5a849b162 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -3070,7 +3070,7 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring)
return -ENXIO;
if (!skb)
- ring->va = (unsigned char *)desc_cb->buf + desc_cb->page_offset;
+ ring->va = desc_cb->buf + desc_cb->page_offset;
/* Prefetch first cache line of first page
* Idea is to cache few bytes of the header of the packet. Our L1 Cache
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index 66cd4395f781..9f64077ee834 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -407,7 +407,7 @@ struct hns3_enet_ring {
u32 pull_len; /* head length for current packet */
u32 frag_num;
- unsigned char *va; /* first buffer address for current packet */
+ void *va; /* first buffer address for current packet */
u32 flag; /* ring attribute */
--
2.23.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 2/5] net: hns3: pointer type of buffer should be void
2020-06-18 1:02 ` [PATCH 2/5] net: hns3: pointer type of buffer should be void Barry Song
@ 2020-06-18 23:35 ` Jakub Kicinski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2020-06-18 23:35 UTC (permalink / raw)
To: Barry Song
Cc: davem, yisen.zhuang, salil.mehta, netdev, linyunsheng,
linux-kernel, linuxarm
On Thu, 18 Jun 2020 13:02:08 +1200 Barry Song wrote:
> Move the type of buffer address from unsigned char to void
>
> Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
> ---
> drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
> drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index 1817d7f2e5f6..61b5a849b162 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -3070,7 +3070,7 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring)
> return -ENXIO;
>
> if (!skb)
> - ring->va = (unsigned char *)desc_cb->buf + desc_cb->page_offset;
> + ring->va = desc_cb->buf + desc_cb->page_offset;
>
> /* Prefetch first cache line of first page
> * Idea is to cache few bytes of the header of the packet. Our L1 Cache
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
> index 66cd4395f781..9f64077ee834 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
> @@ -407,7 +407,7 @@ struct hns3_enet_ring {
>
> u32 pull_len; /* head length for current packet */
> u32 frag_num;
> - unsigned char *va; /* first buffer address for current packet */
> + void *va; /* first buffer address for current packet */
>
> u32 flag; /* ring attribute */
>
I think void pointer arithmetic is questionable in the eyes of the C
standard. But I'm not sure about kernel C.
Otherwise series looks good to me.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/5] net: hns3: rename buffer-related functions
2020-06-18 1:02 [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes Barry Song
2020-06-18 1:02 ` [PATCH 1/5] net: hns3: remove unnecessary devm_kfree Barry Song
2020-06-18 1:02 ` [PATCH 2/5] net: hns3: pointer type of buffer should be void Barry Song
@ 2020-06-18 1:02 ` Barry Song
2020-06-18 1:02 ` [PATCH 4/5] net: hns3: replace disable_irq by IRQ_NOAUTOEN flag Barry Song
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Barry Song @ 2020-06-18 1:02 UTC (permalink / raw)
To: davem, kuba
Cc: yisen.zhuang, salil.mehta, netdev, linyunsheng, linux-kernel,
linuxarm, Barry Song
This is for improving the readability.
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 61b5a849b162..3cd2216e49b9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2405,7 +2405,7 @@ static int hns3_alloc_desc(struct hns3_enet_ring *ring)
return 0;
}
-static int hns3_reserve_buffer_map(struct hns3_enet_ring *ring,
+static int hns3_alloc_and_map_buffer(struct hns3_enet_ring *ring,
struct hns3_desc_cb *cb)
{
int ret;
@@ -2426,9 +2426,9 @@ static int hns3_reserve_buffer_map(struct hns3_enet_ring *ring,
return ret;
}
-static int hns3_alloc_buffer_attach(struct hns3_enet_ring *ring, int i)
+static int hns3_alloc_and_attach_buffer(struct hns3_enet_ring *ring, int i)
{
- int ret = hns3_reserve_buffer_map(ring, &ring->desc_cb[i]);
+ int ret = hns3_alloc_and_map_buffer(ring, &ring->desc_cb[i]);
if (ret)
return ret;
@@ -2444,7 +2444,7 @@ static int hns3_alloc_ring_buffers(struct hns3_enet_ring *ring)
int i, j, ret;
for (i = 0; i < ring->desc_num; i++) {
- ret = hns3_alloc_buffer_attach(ring, i);
+ ret = hns3_alloc_and_attach_buffer(ring, i);
if (ret)
goto out_buffer_fail;
}
@@ -2590,7 +2590,7 @@ static void hns3_nic_alloc_rx_buffers(struct hns3_enet_ring *ring,
hns3_reuse_buffer(ring, ring->next_to_use);
} else {
- ret = hns3_reserve_buffer_map(ring, &res_cbs);
+ ret = hns3_alloc_and_map_buffer(ring, &res_cbs);
if (ret) {
u64_stats_update_begin(&ring->syncp);
ring->stats.sw_err_cnt++;
@@ -4184,7 +4184,7 @@ static int hns3_clear_rx_ring(struct hns3_enet_ring *ring)
* stack, so we need to replace the buffer here.
*/
if (!ring->desc_cb[ring->next_to_use].reuse_flag) {
- ret = hns3_reserve_buffer_map(ring, &res_cbs);
+ ret = hns3_alloc_and_map_buffer(ring, &res_cbs);
if (ret) {
u64_stats_update_begin(&ring->syncp);
ring->stats.sw_err_cnt++;
--
2.23.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 4/5] net: hns3: replace disable_irq by IRQ_NOAUTOEN flag
2020-06-18 1:02 [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes Barry Song
` (2 preceding siblings ...)
2020-06-18 1:02 ` [PATCH 3/5] net: hns3: rename buffer-related functions Barry Song
@ 2020-06-18 1:02 ` Barry Song
2020-06-18 1:02 ` [PATCH 5/5] net: hns3: streaming dma buffer sync between cpu and device Barry Song
2020-06-19 3:43 ` [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes David Miller
5 siblings, 0 replies; 8+ messages in thread
From: Barry Song @ 2020-06-18 1:02 UTC (permalink / raw)
To: davem, kuba
Cc: yisen.zhuang, salil.mehta, netdev, linyunsheng, linux-kernel,
linuxarm, Barry Song
disable_irq() after request_irq() is still risk as there is a chance irq
can come after request_irq() and before disable_irq().
this should be done by IRQ_NOAUTOEN flag.
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 3cd2216e49b9..1330820152fa 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -8,6 +8,7 @@
#include <linux/cpu_rmap.h>
#endif
#include <linux/if_vlan.h>
+#include <linux/irq.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/module.h>
@@ -154,6 +155,7 @@ static int hns3_nic_init_irq(struct hns3_nic_priv *priv)
tqp_vectors->name[HNAE3_INT_NAME_LEN - 1] = '\0';
+ irq_set_status_flags(tqp_vectors->vector_irq, IRQ_NOAUTOEN);
ret = request_irq(tqp_vectors->vector_irq, hns3_irq_handle, 0,
tqp_vectors->name, tqp_vectors);
if (ret) {
@@ -163,8 +165,6 @@ static int hns3_nic_init_irq(struct hns3_nic_priv *priv)
return ret;
}
- disable_irq(tqp_vectors->vector_irq);
-
irq_set_affinity_hint(tqp_vectors->vector_irq,
&tqp_vectors->affinity_mask);
--
2.23.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 5/5] net: hns3: streaming dma buffer sync between cpu and device
2020-06-18 1:02 [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes Barry Song
` (3 preceding siblings ...)
2020-06-18 1:02 ` [PATCH 4/5] net: hns3: replace disable_irq by IRQ_NOAUTOEN flag Barry Song
@ 2020-06-18 1:02 ` Barry Song
2020-06-19 3:43 ` [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes David Miller
5 siblings, 0 replies; 8+ messages in thread
From: Barry Song @ 2020-06-18 1:02 UTC (permalink / raw)
To: davem, kuba
Cc: yisen.zhuang, salil.mehta, netdev, linyunsheng, linux-kernel,
linuxarm, Barry Song
Right now they are empty functions for our SoC since hardware can keep
cache coherent, but it is still good to align with streaming DMA APIs
as device drivers should not make an assumption of SoC.
Reviewed-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
---
.../net/ethernet/hisilicon/hns3/hns3_enet.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 1330820152fa..b319a766889f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2473,6 +2473,11 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma +
ring->desc_cb[i].page_offset);
ring->desc[i].rx.bd_base_info = 0;
+
+ dma_sync_single_for_device(ring_to_dev(ring),
+ ring->desc_cb[i].dma + ring->desc_cb[i].page_offset,
+ hns3_buf_size(ring),
+ DMA_FROM_DEVICE);
}
static void hns3_nic_reclaim_desc(struct hns3_enet_ring *ring, int head,
@@ -2918,6 +2923,11 @@ static int hns3_add_frag(struct hns3_enet_ring *ring)
skb = ring->tail_skb;
}
+ dma_sync_single_for_cpu(ring_to_dev(ring),
+ desc_cb->dma + desc_cb->page_offset,
+ hns3_buf_size(ring),
+ DMA_FROM_DEVICE);
+
hns3_nic_reuse_page(skb, ring->frag_num++, ring, 0, desc_cb);
trace_hns3_rx_desc(ring);
ring_ptr_move_fw(ring, next_to_clean);
@@ -3069,9 +3079,15 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring)
if (unlikely(!(bd_base_info & BIT(HNS3_RXD_VLD_B))))
return -ENXIO;
- if (!skb)
+ if (!skb) {
ring->va = desc_cb->buf + desc_cb->page_offset;
+ dma_sync_single_for_cpu(ring_to_dev(ring),
+ desc_cb->dma + desc_cb->page_offset,
+ hns3_buf_size(ring),
+ DMA_FROM_DEVICE);
+ }
+
/* Prefetch first cache line of first page
* Idea is to cache few bytes of the header of the packet. Our L1 Cache
* line size is 64B so need to prefetch twice to make it 128B. But in
--
2.23.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes
2020-06-18 1:02 [PATCH 0/5] net: hns3: a bundle of minor cleanup and fixes Barry Song
` (4 preceding siblings ...)
2020-06-18 1:02 ` [PATCH 5/5] net: hns3: streaming dma buffer sync between cpu and device Barry Song
@ 2020-06-19 3:43 ` David Miller
5 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2020-06-19 3:43 UTC (permalink / raw)
To: song.bao.hua
Cc: kuba, yisen.zhuang, salil.mehta, netdev, linyunsheng,
linux-kernel, linuxarm
From: Barry Song <song.bao.hua@hisilicon.com>
Date: Thu, 18 Jun 2020 13:02:06 +1200
> some minor changes to either improve the readability or make the code align
> with linux APIs better.
Series applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread