All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Mathias Nyman <mathias.nyman@intel.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Felipe Balbi <balbi@ti.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Roger Quadros <rogerq@ti.com>,
	linux-usb@vger.kernel.org, linux-mediatek@lists.infradead.org,
	John Crispin <blogic@openwrt.org>,
	Daniel Kurtz <djkurtz@chromium.org>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Kishon Vijay Abraham I <kishon@ti.com>
Subject: Re: [PATCH v5 4/5] xhci: mediatek: support MTK xHCI host controller
Date: Mon, 17 Aug 2015 18:07:35 +0300	[thread overview]
Message-ID: <55D1F8B7.9060306@linux.intel.com> (raw)
In-Reply-To: <1438950644-27290-5-git-send-email-chunfeng.yun@mediatek.com>

Hi

On 07.08.2015 15:30, Chunfeng Yun wrote:
> MTK xhci host controller defines some extra SW scheduling
> parameters for HW to minimize the scheduling effort for
> synchronous and interrupt endpoints. The parameters are
> put into reseved DWs of slot context and endpoint context
>
>

...

> + * The TD size is the number of max packet sized packets remaining in the TD
> + * (including this TRB), right shifted by 10.
> + * It must fit in bits 21:17, so it can't be bigger than 31.
> + */
> +u32 xhci_mtk_td_remainder_quirk(unsigned int td_running_total,
> +	unsigned trb_buffer_length, struct urb *urb)
> +{
> +	u32 max = 31;
> +	int remainder, td_packet_count, packet_transferred;
> +	unsigned int td_transfer_size = urb->transfer_buffer_length;
> +	unsigned int maxp;
> +
> +	maxp = GET_MAX_PACKET(usb_endpoint_maxp(&urb->ep->desc));
> +
> +	/* 0 for the last TRB */
> +	if (td_running_total + trb_buffer_length == td_transfer_size)
> +		return 0;
> +
> +	packet_transferred = td_running_total / maxp;
> +	td_packet_count = DIV_ROUND_UP(td_transfer_size, maxp);
> +	remainder = td_packet_count - packet_transferred;
> +
> +	if (remainder > max)
> +		return max << 17;
> +	else
> +		return remainder << 17;
> +}

I started looking at this xhci_mtk_td_remainder() function, one
of the places this patch touches the existing xhci code.

The remainder functions in xhci are already bit too messy, and
adding one more function which does almost the same thing makes
it even messier.

For example queuing a bulk transfer will end up like this:

>   		/* Set the TRB length, TD size, and interrupter fields. */
>   		if (xhci->hci_version < 0x100) {
> -			remainder = xhci_td_remainder(
> +			if (xhci->quirks & XHCI_MTK_HOST) {
> +				remainder = xhci_mtk_td_remainder_quirk(
> +					running_total, trb_buff_len, urb);
> +			} else {
> +				remainder = xhci_td_remainder(
>   					urb->transfer_buffer_length -
>   					running_total);
> +			}
>   		} else {
>   			remainder = xhci_v1_0_td_remainder(running_total,
>   					trb_buff_len, total_packet_count, urb,

and similar for isoc and control transfers.

I'll see if I can simplify the existing remainder calculations into one function, then it should
be enough to just add something like this into it:

if (xhci->quirks & XHCI_MTK_HOST)
	trb_buff_len = 0;
  	
This way we can skip all the extra hassle that comes with a new exported quirk function

Is the Mediatek xhci really a xHCI 0.96 or older controller? (hci_version < 0x100)
Not a xHCI 1.0 or 1.1 ?

-Mathias

WARNING: multiple messages have this Message-ID (diff)
From: Mathias Nyman <mathias.nyman-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Chunfeng Yun
	<chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
	Mathias Nyman
	<mathias.nyman-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Sergei Shtylyov
	<sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>,
	Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>,
	Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Matthias Brugger
	<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	John Crispin <blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Subject: Re: [PATCH v5 4/5] xhci: mediatek: support MTK xHCI host controller
Date: Mon, 17 Aug 2015 18:07:35 +0300	[thread overview]
Message-ID: <55D1F8B7.9060306@linux.intel.com> (raw)
In-Reply-To: <1438950644-27290-5-git-send-email-chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>

Hi

On 07.08.2015 15:30, Chunfeng Yun wrote:
> MTK xhci host controller defines some extra SW scheduling
> parameters for HW to minimize the scheduling effort for
> synchronous and interrupt endpoints. The parameters are
> put into reseved DWs of slot context and endpoint context
>
>

...

> + * The TD size is the number of max packet sized packets remaining in the TD
> + * (including this TRB), right shifted by 10.
> + * It must fit in bits 21:17, so it can't be bigger than 31.
> + */
> +u32 xhci_mtk_td_remainder_quirk(unsigned int td_running_total,
> +	unsigned trb_buffer_length, struct urb *urb)
> +{
> +	u32 max = 31;
> +	int remainder, td_packet_count, packet_transferred;
> +	unsigned int td_transfer_size = urb->transfer_buffer_length;
> +	unsigned int maxp;
> +
> +	maxp = GET_MAX_PACKET(usb_endpoint_maxp(&urb->ep->desc));
> +
> +	/* 0 for the last TRB */
> +	if (td_running_total + trb_buffer_length == td_transfer_size)
> +		return 0;
> +
> +	packet_transferred = td_running_total / maxp;
> +	td_packet_count = DIV_ROUND_UP(td_transfer_size, maxp);
> +	remainder = td_packet_count - packet_transferred;
> +
> +	if (remainder > max)
> +		return max << 17;
> +	else
> +		return remainder << 17;
> +}

I started looking at this xhci_mtk_td_remainder() function, one
of the places this patch touches the existing xhci code.

The remainder functions in xhci are already bit too messy, and
adding one more function which does almost the same thing makes
it even messier.

For example queuing a bulk transfer will end up like this:

>   		/* Set the TRB length, TD size, and interrupter fields. */
>   		if (xhci->hci_version < 0x100) {
> -			remainder = xhci_td_remainder(
> +			if (xhci->quirks & XHCI_MTK_HOST) {
> +				remainder = xhci_mtk_td_remainder_quirk(
> +					running_total, trb_buff_len, urb);
> +			} else {
> +				remainder = xhci_td_remainder(
>   					urb->transfer_buffer_length -
>   					running_total);
> +			}
>   		} else {
>   			remainder = xhci_v1_0_td_remainder(running_total,
>   					trb_buff_len, total_packet_count, urb,

and similar for isoc and control transfers.

I'll see if I can simplify the existing remainder calculations into one function, then it should
be enough to just add something like this into it:

if (xhci->quirks & XHCI_MTK_HOST)
	trb_buff_len = 0;
  	
This way we can skip all the extra hassle that comes with a new exported quirk function

Is the Mediatek xhci really a xHCI 0.96 or older controller? (hci_version < 0x100)
Not a xHCI 1.0 or 1.1 ?

-Mathias

WARNING: multiple messages have this Message-ID (diff)
From: mathias.nyman@linux.intel.com (Mathias Nyman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 4/5] xhci: mediatek: support MTK xHCI host controller
Date: Mon, 17 Aug 2015 18:07:35 +0300	[thread overview]
Message-ID: <55D1F8B7.9060306@linux.intel.com> (raw)
In-Reply-To: <1438950644-27290-5-git-send-email-chunfeng.yun@mediatek.com>

Hi

On 07.08.2015 15:30, Chunfeng Yun wrote:
> MTK xhci host controller defines some extra SW scheduling
> parameters for HW to minimize the scheduling effort for
> synchronous and interrupt endpoints. The parameters are
> put into reseved DWs of slot context and endpoint context
>
>

...

> + * The TD size is the number of max packet sized packets remaining in the TD
> + * (including this TRB), right shifted by 10.
> + * It must fit in bits 21:17, so it can't be bigger than 31.
> + */
> +u32 xhci_mtk_td_remainder_quirk(unsigned int td_running_total,
> +	unsigned trb_buffer_length, struct urb *urb)
> +{
> +	u32 max = 31;
> +	int remainder, td_packet_count, packet_transferred;
> +	unsigned int td_transfer_size = urb->transfer_buffer_length;
> +	unsigned int maxp;
> +
> +	maxp = GET_MAX_PACKET(usb_endpoint_maxp(&urb->ep->desc));
> +
> +	/* 0 for the last TRB */
> +	if (td_running_total + trb_buffer_length == td_transfer_size)
> +		return 0;
> +
> +	packet_transferred = td_running_total / maxp;
> +	td_packet_count = DIV_ROUND_UP(td_transfer_size, maxp);
> +	remainder = td_packet_count - packet_transferred;
> +
> +	if (remainder > max)
> +		return max << 17;
> +	else
> +		return remainder << 17;
> +}

I started looking at this xhci_mtk_td_remainder() function, one
of the places this patch touches the existing xhci code.

The remainder functions in xhci are already bit too messy, and
adding one more function which does almost the same thing makes
it even messier.

For example queuing a bulk transfer will end up like this:

>   		/* Set the TRB length, TD size, and interrupter fields. */
>   		if (xhci->hci_version < 0x100) {
> -			remainder = xhci_td_remainder(
> +			if (xhci->quirks & XHCI_MTK_HOST) {
> +				remainder = xhci_mtk_td_remainder_quirk(
> +					running_total, trb_buff_len, urb);
> +			} else {
> +				remainder = xhci_td_remainder(
>   					urb->transfer_buffer_length -
>   					running_total);
> +			}
>   		} else {
>   			remainder = xhci_v1_0_td_remainder(running_total,
>   					trb_buff_len, total_packet_count, urb,

and similar for isoc and control transfers.

I'll see if I can simplify the existing remainder calculations into one function, then it should
be enough to just add something like this into it:

if (xhci->quirks & XHCI_MTK_HOST)
	trb_buff_len = 0;
  	
This way we can skip all the extra hassle that comes with a new exported quirk function

Is the Mediatek xhci really a xHCI 0.96 or older controller? (hci_version < 0x100)
Not a xHCI 1.0 or 1.1 ?

-Mathias

  reply	other threads:[~2015-08-17 15:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07 12:30 Mediatek xHCI support Chunfeng Yun
2015-08-07 12:30 ` Chunfeng Yun
2015-08-07 12:30 ` Chunfeng Yun
2015-08-07 12:30 ` [PATCH v5 1/5] dt-bindings: Add usb3.0 phy binding for MT65xx SoCs Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-07 12:30 ` [PATCH v5 2/5] dt-bindings: Add a binding for Mediatek xHCI host controller Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-07 12:30 ` [PATCH v5 3/5] usb: phy: add usb3.0 phy driver for mt65xx SoCs Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-17  5:29   ` Kishon Vijay Abraham I
2015-08-17  5:29     ` Kishon Vijay Abraham I
2015-08-17  5:29     ` Kishon Vijay Abraham I
2015-08-19 11:29     ` chunfeng yun
2015-08-19 11:29       ` chunfeng yun
2015-08-19 11:29       ` chunfeng yun
2015-08-07 12:30 ` [PATCH v5 4/5] xhci: mediatek: support MTK xHCI host controller Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-17 15:07   ` Mathias Nyman [this message]
2015-08-17 15:07     ` Mathias Nyman
2015-08-17 15:07     ` Mathias Nyman
2015-08-19 11:21     ` chunfeng yun
2015-08-19 11:21       ` chunfeng yun
2015-08-19 11:21       ` chunfeng yun
2015-08-07 12:30 ` [PATCH v5 5/5] arm64: dts: mediatek: add xHCI & usb phy for mt8173 Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun
2015-08-07 12:30   ` Chunfeng Yun

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=55D1F8B7.9060306@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=balbi@ti.com \
    --cc=blogic@openwrt.org \
    --cc=chunfeng.yun@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djkurtz@chromium.org \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathias.nyman@intel.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=rogerq@ti.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sergei.shtylyov@cogentembedded.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.