[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220526120113.971512-3-ltykernel@gmail.com>
Date: Thu, 26 May 2022 08:01:12 -0400
From: Tianyu Lan <ltykernel@...il.com>
To: kys@...rosoft.com, haiyangz@...rosoft.com, sthemmin@...rosoft.com,
wei.liu@...nel.org, decui@...rosoft.com, davem@...emloft.net,
kuba@...nel.org, pabeni@...hat.com, hch@...radead.org,
m.szyprowski@...sung.com, robin.murphy@....com,
michael.h.kelley@...rosoft.com
Cc: Tianyu Lan <Tianyu.Lan@...rosoft.com>,
iommu@...ts.linux-foundation.org, linux-hyperv@...r.kernel.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
vkuznets@...hat.com, konrad.wilk@...cle.com, hch@....de,
parri.andrea@...il.com, thomas.lendacky@....com,
andi.kleen@...el.com, kirill.shutemov@...el.com
Subject: [RFC PATCH V3 2/2] net: netvsc: Allocate per-device swiotlb bounce buffer for netvsc
From: Tianyu Lan <Tianyu.Lan@...rosoft.com>
Netvsc driver allocates device io tlb mem via calling swiotlb_device_
allocate() and set child io tlb mem number according to device queue
number. Child io tlb mem may reduce overhead of single spin lock in
device io tlb mem among multi device queues.
Signed-off-by: Tianyu Lan <Tianyu.Lan@...rosoft.com>
---
drivers/net/hyperv/netvsc.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 9442f751ad3a..26a8f8f84fc4 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -23,6 +23,7 @@
#include <asm/sync_bitops.h>
#include <asm/mshyperv.h>
+#include <linux/swiotlb.h>
#include "hyperv_net.h"
#include "netvsc_trace.h"
@@ -98,6 +99,7 @@ static void netvsc_subchan_work(struct work_struct *w)
struct netvsc_device *nvdev =
container_of(w, struct netvsc_device, subchan_work);
struct rndis_device *rdev;
+ struct hv_device *hdev;
int i, ret;
/* Avoid deadlock with device removal already under RTNL */
@@ -108,6 +110,9 @@ static void netvsc_subchan_work(struct work_struct *w)
rdev = nvdev->extension;
if (rdev) {
+ hdev = ((struct net_device_context *)
+ netdev_priv(rdev->ndev))->device_ctx;
+
ret = rndis_set_subchannel(rdev->ndev, nvdev, NULL);
if (ret == 0) {
netif_device_attach(rdev->ndev);
@@ -119,6 +124,10 @@ static void netvsc_subchan_work(struct work_struct *w)
nvdev->max_chn = 1;
nvdev->num_chn = 1;
}
+
+ /* Allocate boucne buffer.*/
+ swiotlb_device_allocate(&hdev->device, nvdev->num_chn,
+ 10 * IO_TLB_BLOCK_UNIT);
}
rtnl_unlock();
@@ -769,6 +778,7 @@ void netvsc_device_remove(struct hv_device *device)
/* Release all resources */
free_netvsc_device_rcu(net_device);
+ swiotlb_device_free(&device->device);
}
#define RING_AVAIL_PERCENT_HIWATER 20
--
2.25.1
Powered by blists - more mailing lists