RE: [PATCH] usb: gadget: core: unmap request from DMA only if previously mapped

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jack-san,

> -----Original Message-----
> From: Jack Pham
> Sent: Tuesday, August 1, 2017 6:01 PM
> Subject: [PATCH] usb: gadget: core: unmap request from DMA only if previously mapped
> 
> In the SG case this is already handled since a non-zero
> request->num_mapped_sgs is a clear indicator that dma_map_sg()
> had been called. While it would be nice to do the same for the
> singly mapped case by simply checking for non-zero request->dma,
> it's conceivable that 0 is a valid dma_addr_t handle. Hence add
> a flag 'dma_mapped' to struct usb_request and use this to
> determine the need to call dma_unmap_single(). Otherwise, if a
> request is not DMA mapped then the result of calling
> usb_request_unmap_request() would safely be a no-op.
> 
> Signed-off-by: Jack Pham <jackp@xxxxxxxxxxxxxx>
> ---
> Hi Felipe,
> 
> Here's what I came up with after our discussion back in [1]. It
> turned out to be pretty dead-simple and hopefully doesn't need to
> approach the number of URB flags that the host core uses.
> 
> I did a quick survey of all callers of usb_gadget_{map,unmap}_request
> and besides the instance I reported & patched in dwc3, from what I
> can tell it looks like all the other gadget drivers seem to be calling
> these APIs sanely--i.e. a request is only queued after being
> successfully mapped, and unmap only ever gets called on requests that
> had been queued.
> 
> Although in one instance (renesas_usb3.c), there is a 'used' flag as
> part of struct renesas_usb3_dma that looks like it's tracking the
> status of whether a request is mapped or not, but it's not obvious from
> cursory glance whether it has a use besides that or if it would be
> sufficient to just rely on this new flag in struct usb_gadget.
> Maybe Yoshihiro-san can comment.

About the 'used' flag on renesas_usb3.c, I don't think the driver is able to
rely on this new flag 'dma_mapped' in struct usb_request because the 'used' flag
will be used for marking the dma channels.
This controller only handles 4 channels(endpoints) at the same time.
So, this driver has 'used' in struct renesas_usb3_dma.

But, I think this patch is good to unmap safety.
So,

Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>

Best regards,
Yoshihiro Shimoda

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux