> -----Original Message-----
> From: Michael Kelley (LINUX) <mikel...@microsoft.com>
> Sent: Thursday, December 9, 2021 2:54 PM
> To: Haiyang Zhang <haiya...@microsoft.com>; Tianyu Lan <ltyker...@gmail.com>; 
> KY
> Srinivasan <k...@microsoft.com>; Stephen Hemminger <sthem...@microsoft.com>;
> wei....@kernel.org; Dexuan Cui <de...@microsoft.com>; t...@linutronix.de; 
> mi...@redhat.com;
> b...@alien8.de; dave.han...@linux.intel.com; x...@kernel.org; h...@zytor.com;
> da...@davemloft.net; k...@kernel.org; j...@linux.ibm.com; 
> martin.peter...@oracle.com;
> a...@arndb.de; h...@infradead.org; m.szyprow...@samsung.com; 
> robin.mur...@arm.com; Tianyu
> Lan <tianyu....@microsoft.com>; thomas.lenda...@amd.com
> Cc: iommu@lists.linux-foundation.org; linux-a...@vger.kernel.org; linux-
> hyp...@vger.kernel.org; linux-ker...@vger.kernel.org; 
> linux-s...@vger.kernel.org;
> net...@vger.kernel.org; vkuznets <vkuzn...@redhat.com>; brijesh.si...@amd.com;
> konrad.w...@oracle.com; h...@lst.de; j...@8bytes.org; parri.and...@gmail.com;
> dave.han...@intel.com
> Subject: RE: [PATCH V6 5/5] net: netvsc: Add Isolation VM support for netvsc 
> driver
> 
> From: Haiyang Zhang <haiya...@microsoft.com> Sent: Wednesday, December 8, 
> 2021 12:14 PM
> > > From: Tianyu Lan <ltyker...@gmail.com>
> > > Sent: Tuesday, December 7, 2021 2:56 AM
> 
> [snip]
> 
> > >  static inline int netvsc_send_pkt(
> > >   struct hv_device *device,
> > >   struct hv_netvsc_packet *packet,
> > > @@ -986,14 +1105,24 @@ static inline int netvsc_send_pkt(
> > >
> > >   trace_nvsp_send_pkt(ndev, out_channel, rpkt);
> > >
> > > + packet->dma_range = NULL;
> > >   if (packet->page_buf_cnt) {
> > >           if (packet->cp_partial)
> > >                   pb += packet->rmsg_pgcnt;
> > >
> > > +         ret = netvsc_dma_map(ndev_ctx->device_ctx, packet, pb);
> > > +         if (ret) {
> > > +                 ret = -EAGAIN;
> > > +                 goto exit;
> > > +         }
> >
> > Returning EAGAIN will let the upper network layer busy retry,
> > which may make things worse.
> > I suggest to return ENOSPC here like another place in this
> > function, which will just drop the packet, and let the network
> > protocol/app layer decide how to recover.
> >
> > Thanks,
> > - Haiyang
> 
> I made the original suggestion to return -EAGAIN here.   A
> DMA mapping failure should occur only if swiotlb bounce
> buffer space is unavailable, which is a transient condition.
> The existing code already stops the queue and returns
> -EAGAIN when the ring buffer is full, which is also a transient
> condition.  My sense is that the two conditions should be
> handled the same way.  Or is there a reason why a ring
> buffer full condition should stop the queue and retry, while
> a mapping failure should drop the packet?

The netvsc_dma_map() fails in these two places. The dma_map_single() 
is doing the maping with swiotlb bounce buffer, correct? And it will 
become successful after the previous packets are unmapped?

+       packet->dma_range = kcalloc(page_count,
+                                   sizeof(*packet->dma_range),
+                                   GFP_KERNEL);

+               dma = dma_map_single(&hv_dev->device, src, len,
+                                    DMA_TO_DEVICE);

I recalled your previous suggestion now, and agree with you that 
we can treat it the same way (return -EAGAIN) in this case. And 
the existing code will stop the queue temporarily.

Thanks,
- Haiyang
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to