Message ID | 20220526120113.971512-3-ltykernel@gmail.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | swiotlb: Add child io tlb mem support | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
On 5/27/2022 2:43 AM, Dexuan Cui wrote: >> From: Tianyu Lan <ltykernel@gmail.com> >> Sent: Thursday, May 26, 2022 5:01 AM >> ... >> @@ -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); >> } > > Looks like swiotlb_device_allocate() is not called if the netvsc device > has only 1 primary channel and no sub-schannel, e.g. in the case of > single-vCPU VM? When there is only sinlge,there seems not to be much performance penalty. But you are right, we should keep the same behavior when single CPU and multi CPU. Will update in the next version. Thanks.
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