From: Tianyu Lan <ltykernel@gmail.com>
To: kys@microsoft.com, haiyangz@microsoft.com,
sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
hch@infradead.org, m.szyprowski@samsung.com,
robin.murphy@arm.com, michael.h.kelley@microsoft.com
Cc: parri.andrea@gmail.com, thomas.lendacky@amd.com,
linux-hyperv@vger.kernel.org,
Tianyu Lan <Tianyu.Lan@microsoft.com>,
konrad.wilk@oracle.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kirill.shutemov@intel.com,
iommu@lists.linux-foundation.org, andi.kleen@intel.com,
vkuznets@redhat.com, hch@lst.de
Subject: [RFC PATCH V3 2/2] net: netvsc: Allocate per-device swiotlb bounce buffer for netvsc
Date: Thu, 26 May 2022 08:01:12 -0400 [thread overview]
Message-ID: <20220526120113.971512-3-ltykernel@gmail.com> (raw)
In-Reply-To: <20220526120113.971512-1-ltykernel@gmail.com>
From: Tianyu Lan <Tianyu.Lan@microsoft.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@microsoft.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
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-05-26 12:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-26 12:01 [RFC PATCH V3 0/2] swiotlb: Add child io tlb mem support Tianyu Lan
2022-05-26 12:01 ` [RFC PATCH V3 1/2] swiotlb: Add Child IO TLB " Tianyu Lan
2022-05-26 12:01 ` Tianyu Lan [this message]
2022-05-26 18:43 ` [RFC PATCH V3 2/2] net: netvsc: Allocate per-device swiotlb bounce buffer for netvsc Dexuan Cui via iommu
2022-05-27 12:20 ` Tianyu Lan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220526120113.971512-3-ltykernel@gmail.com \
--to=ltykernel@gmail.com \
--cc=Tianyu.Lan@microsoft.com \
--cc=andi.kleen@intel.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=kirill.shutemov@intel.com \
--cc=konrad.wilk@oracle.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=michael.h.kelley@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parri.andrea@gmail.com \
--cc=robin.murphy@arm.com \
--cc=sthemmin@microsoft.com \
--cc=thomas.lendacky@amd.com \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).