Re: [RFC/PATCH 1/2] usb: gadget: introduce support for sg lists

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

 



On Tue, Nov 22, 2011 at 03:38:34PM +0100, Sebastian Andrzej Siewior wrote:
> * Felipe Balbi | 2011-11-22 11:42:05 [+0200]:
> 
> >diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> >index 22c37d2..fd61375 100644
> >--- a/include/linux/usb/gadget.h
> >+++ b/include/linux/usb/gadget.h
> >@@ -88,6 +91,9 @@ struct usb_request {
> > 	unsigned		length;
> > 	dma_addr_t		dma;
> > 
> >+	struct scatterlist	*sg;
> >+	unsigned		num_sgs;
> 
> This is close to what we have on the host side. Okay.

yeah, based on that side all over :-)

> 
> > 	unsigned		stream_id:16;
> > 	unsigned		no_interrupt:1;
> > 	unsigned		zero:1;
> >@@ -102,6 +108,22 @@ struct usb_request {
> > 	unsigned		actual;
> > };
> > 
> >+struct usb_request_sg {
> >+	int		status;
> >+	unsigned	actual;
> >+
> >+	void		(*complete)(struct usb_ep *ep,
> >+			struct usb_request_sg *rsg);
> >+	void		*context;
> >+
> >+	/*
> >+	 * Members below are private to the controller. Gadget
> >+	 * drivers should not touch them.
> >+	 */
> >+	struct usb_request	**requests;
> >+	int			num_entries;
> >+};
> 
> Ehm, why do you need this? This seem to be part of something else.

what do you mean ? I need one big request which will group all struct
usb_requests, it's just the easiest way to know how usb requests you
have on this SG list and, with that, how many requests will have CHN bit
set (on dwc3).

> >@@ -120,6 +142,13 @@ struct usb_ep_ops {
> > 		gfp_t gfp_flags);
> > 	void (*free_request) (struct usb_ep *ep, struct usb_request *req);
> > 
> >+	int (*sg_prepare)(struct usb_ep *ep, struct usb_request_sg *rsg,
> >+			struct scatterlist *sg, unsigned int num_entries,
> >+			unsigned int length, gfp_t gfp_flags);
> >+	int (*sg_queue)(struct usb_ep *ep, struct usb_request_sg *rsg,
> >+			gfp_t gfp_flags);
> >+	int (*sg_dequeue)(struct usb_ep *ep, struct usb_request_sg *rsg);
> >+
> > 	int (*queue) (struct usb_ep *ep, struct usb_request *req,
> > 		gfp_t gfp_flags);
> > 	int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
> >@@ -250,6 +279,45 @@ static inline void usb_ep_free_request(struct usb_ep *ep,
> > }
> > 
> > /**
> >+ * usb_ep_sg_prepare - prepares a sg list to be queued to the endpoint
> >+ * @ep: the endpoint associated with the request
> >+ * @rsg: the SG request
> >+ * @sg: the scatterlist
> >+ * @num_entries: number of entries
> >+ * @length: total length of the SG transfer
> >+ * @gfp_flags: flags for memory allocations on this call
> >+ */
> >+static inline int usb_ep_sg_prepare(struct usb_ep *ep,
> >+		struct usb_request_sg *rsg, struct scatterlist *sg,
> >+		unsigned int num_entries, unsigned int length, gfp_t gfp_flags)
> >+{
> >+	return ep->ops->sg_prepare(ep, rsg, sg, num_entries, length, gfp_flags);
> >+}
> >+
> >+/**
> >+ * usb_ep_sg_queue - queue a sg list to the endpoint
> >+ * @ep: the endpoint associated with the request
> >+ * @rsg: the SG request
> >+ * @gfp_flags: flags for memory allocations on this call
> >+ */
> >+static inline int usb_ep_sg_queue(struct usb_ep *ep,
> >+		struct usb_request_sg *rsg, gfp_t gfp_flags)
> >+{
> >+	return ep->ops->sg_queue(ep, rsg, gfp_flags);
> >+}
> >+
> >+/**
> >+ * usb_ep_sg_dequeue - dequeues a sg ist from the endpoint
> >+ * @ep: the endpoint associated with the request
> >+ * @rsg: the SG request to the dequeued
> >+ */
> >+static inline int usb_ep_sg_dequeue(struct usb_ep *ep,
> >+		struct usb_request_sg *rsg)
> >+{
> >+	return ep->ops->sg_dequeue(ep, rsg);
> >+}
> >+
> >+/**
> 
> Why do you need also this extra callbacks?

so that scatter/gather API is separate from the other API ?!? don't get
your concern.

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux