All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	oneukum@suse.com, Mathias Nyman <mathias.nyman@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC v2] usb: xhci: add Immediate Data Transfer support
Date: Wed, 06 Feb 2019 12:54:50 +0200	[thread overview]
Message-ID: <871s4lmbk5.fsf@linux.intel.com> (raw)
In-Reply-To: <294f2492f8d3b7022bf659dcb473c45a34e85db8.camel@suse.de>

[-- Attachment #1: Type: text/plain, Size: 2148 bytes --]


Hi,

Nicolas Saenz Julienne <nsaenzjulienne@suse.de> writes:
>> > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>> > index 005e65922608..dec62f7f5dc8 100644
>> > --- a/drivers/usb/host/xhci.c
>> > +++ b/drivers/usb/host/xhci.c
>> > @@ -1238,6 +1238,21 @@ EXPORT_SYMBOL_GPL(xhci_resume);
>> >  
>> >  /*-------------------------------------------------------------------------
>> > */
>> >  
>> > +/*
>> > + * Bypass the DMA mapping if URB is suitable for Immediate Transfer (IDT),
>> > + * we'll copy the actual data into the TRB address register. This is
>> > limited to
>> > + * transfers up to 8 bytes on output endpoints of any kind with
>> > wMaxPacketSize
>> > + * >= 8 bytes.
>> > + */
>> > +static int xhci_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
>> > +				gfp_t mem_flags)
>> > +{
>> > +	if (xhci_urb_suitable_for_idt(urb))
>> > +		return 0;
>> > +
>> > +	return usb_hcd_map_urb_for_dma(hcd, urb, mem_flags);
>> > +}
>> 
>> don't you need a matching unmap_urb_for_dma()??
>
> Not really as every DMA mapping sets a matching URB flag to track it. For
> example when usb_hcd_map_urb_for_dma() uses dma_map_single() it will set
> URB_DMA_MAP_SINGLE in urb->transfer_flags, later on unmap_urb_for_dma() will
> catch it and unmap it. As I bypass the mapping altogether there are no
> flags set, so unmap_urb_for_dma() won't have any effect.
>
> I could still add it for clarity, and well, I guess it'll save some
> instructions on the IDT suitable side.

thanks for the clarification.

>> > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
>> > index 652dc36e3012..9d77b0901ab7 100644
>> > --- a/drivers/usb/host/xhci.h
>> > +++ b/drivers/usb/host/xhci.h
>> > @@ -1295,6 +1295,8 @@ enum xhci_setup_dev {
>> >  #define TRB_IOC			(1<<5)
>> >  /* The buffer pointer contains immediate data */
>> >  #define TRB_IDT			(1<<6)
>> > +/* TDs smaller than this might use IDT */
>> 
>> Technically, "TDs at most this" since you're 8 itself is an allowed

heh, I made a mess on this sentence, but I guess you got the gist of it.

cheers

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	oneukum@suse.com, Mathias Nyman <mathias.nyman@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC,v2] usb: xhci: add Immediate Data Transfer support
Date: Wed, 06 Feb 2019 12:54:50 +0200	[thread overview]
Message-ID: <871s4lmbk5.fsf@linux.intel.com> (raw)

Hi,

Nicolas Saenz Julienne <nsaenzjulienne@suse.de> writes:
>> > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>> > index 005e65922608..dec62f7f5dc8 100644
>> > --- a/drivers/usb/host/xhci.c
>> > +++ b/drivers/usb/host/xhci.c
>> > @@ -1238,6 +1238,21 @@ EXPORT_SYMBOL_GPL(xhci_resume);
>> >  
>> >  /*-------------------------------------------------------------------------
>> > */
>> >  
>> > +/*
>> > + * Bypass the DMA mapping if URB is suitable for Immediate Transfer (IDT),
>> > + * we'll copy the actual data into the TRB address register. This is
>> > limited to
>> > + * transfers up to 8 bytes on output endpoints of any kind with
>> > wMaxPacketSize
>> > + * >= 8 bytes.
>> > + */
>> > +static int xhci_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
>> > +				gfp_t mem_flags)
>> > +{
>> > +	if (xhci_urb_suitable_for_idt(urb))
>> > +		return 0;
>> > +
>> > +	return usb_hcd_map_urb_for_dma(hcd, urb, mem_flags);
>> > +}
>> 
>> don't you need a matching unmap_urb_for_dma()??
>
> Not really as every DMA mapping sets a matching URB flag to track it. For
> example when usb_hcd_map_urb_for_dma() uses dma_map_single() it will set
> URB_DMA_MAP_SINGLE in urb->transfer_flags, later on unmap_urb_for_dma() will
> catch it and unmap it. As I bypass the mapping altogether there are no
> flags set, so unmap_urb_for_dma() won't have any effect.
>
> I could still add it for clarity, and well, I guess it'll save some
> instructions on the IDT suitable side.

thanks for the clarification.

>> > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
>> > index 652dc36e3012..9d77b0901ab7 100644
>> > --- a/drivers/usb/host/xhci.h
>> > +++ b/drivers/usb/host/xhci.h
>> > @@ -1295,6 +1295,8 @@ enum xhci_setup_dev {
>> >  #define TRB_IOC			(1<<5)
>> >  /* The buffer pointer contains immediate data */
>> >  #define TRB_IDT			(1<<6)
>> > +/* TDs smaller than this might use IDT */
>> 
>> Technically, "TDs at most this" since you're 8 itself is an allowed

heh, I made a mess on this sentence, but I guess you got the gist of it.

cheers

  reply	other threads:[~2019-02-06 10:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 19:56 [RFC v2] usb: xhci: add Immediate Data Transfer support Nicolas Saenz Julienne
2019-02-05 19:56 ` [RFC,v2] " Nicolas Saenz Julienne
2019-02-06  6:35 ` [RFC v2] " Felipe Balbi
2019-02-06  6:35   ` [RFC,v2] " Felipe Balbi
2019-02-06 10:08   ` [RFC v2] " Nicolas Saenz Julienne
2019-02-06 10:08     ` [RFC,v2] " Nicolas Saenz Julienne
2019-02-06 10:54     ` Felipe Balbi [this message]
2019-02-06 10:54       ` Felipe Balbi

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=871s4lmbk5.fsf@linux.intel.com \
    --to=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=oneukum@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.