linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Zengtao (B)" <prime.zeng@hisilicon.com>
To: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>,
	"johnyoun@synopsys.com" <John.Youn@synopsys.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Zengtao (B)" <prime.zeng@hisilicon.com>
Subject: 答复: Possible usb_request leak in the function dwc2_gadget_complete_isoc_request_ddma
Date: Fri, 2 Mar 2018 01:48:12 +0000	[thread overview]
Message-ID: <678F3D1BB717D949B966B68EAEB446ED0C865E22@DGGEMM506-MBX.china.huawei.com> (raw)
In-Reply-To: <410670D7E743164D87FA6160E7907A560113A9C13B@am04wembxb.internal.synopsys.com>

Hi Minas:

Thanks for your reply.

>-----邮件原件-----
>发件人: Minas Harutyunyan [mailto:Minas.Harutyunyan@synopsys.com]
>发送时间: 2018年2月28日 18:27
>收件人: Zengtao (B) <prime.zeng@hisilicon.com>; johnyoun@synopsys.com
><John.Youn@synopsys.com>
>抄送: gregkh@linuxfoundation.org; linux-usb@vger.kernel.org;
>linux-kernel@vger.kernel.org
>主题: Re: Possible usb_request leak in the function
>dwc2_gadget_complete_isoc_request_ddma
>
>Hi,
>
>On 2/28/2018 1:00 PM, Zengtao (B) wrote:
>> Hi johnyoun:
>>
>> I found a suspected bug, and I am writing to confirm with you.
>>
>> In the function
>dwc2_gadget_complete_isoc_request_ddma(drivers/usb/dwc2/gadget.c).
>> Only the first request from the eq queue is processed while maybe there are
>more than one descriptors done by the HW.
>>
>> 1. Each usb request is associated with a DMA descriptor, but this is
>> not reflect in the driver, so when one DMA descriptor is done, we
>> don't know which usb request is done, but I think if only one DMA descriptor is
>done, we can know that the first USB request in eq queue is done, because the
>HW DMA descriptor and SW usb request are both in sequence.
>>
>> 2. In the function dwc2_gadget_complete_isoc_request_ddma, we may
>> complete more than one DMA descriptor but only the first Usb request is
>processed, but in fact, we should all the usb requests associated with all the
>done DMA descriptors.
>>
>> 3. I noticed that each DMA descriptor is configured to report an
>> interrupt, and if each DMA descriptor generate an interrupt, the above Flow
>should be ok, but the interrupts can merge and we have used the depdma to
>figure out the largest finished DMA descriptor index.
>>
>
>Why you suspect that subsequent interrupts can be merged? Did you see this
>case? Can you provide a log?
>Even in case of minimal interval=1, time between 2 subsequent interrupts
>should be about 125us. It's fully enough to process target descriptor, complete
>request, enqueue new request and prepare new descriptor.
>
Yes, I have seen thas case on my platform.

I think the following should be considered.

1. The currently driver code checks the depdma register to figure out the latest finished
descriptor, and even in the interrupt handler triggered by one descriptor, the depdma
may continue to increase, so I think you should not at least depend on the depdma if you
think on descriptor should be processed in the interrupt handler.

2. The Linux system can't assure that the system is available in every 125us, for example
Some other kernel modules need to disable the interrupts or other interrupts handler cost
more than 125us, and this unfortunately happened on our platform, but that is not an illegal
case.

3. The hardware allows each dma descriptor to set it's own ioc bit, so we can't just assume
That every dma descriptor must set the ioc bit to 1. And if we enforce each descriptor to generate 
an interrupt, then too frequent interrupts(125us) will be really a burden for the system.

Thank you.

>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-usb"
>> in the body of a message to majordomo@vger.kernel.org More majordomo
>> info at
>>
>https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordo
>mo-2Dinfo.html&d=DwIDAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=6z9Al9FrHR_Zqb
>btSAsD16pvOL2S3XHxQnSzq8kusyI&m=vbKt9jwY5FRUysFlZg1CB6HKRyFACygkw
>ZBO0mvSQDc&s=7rLKr3g3UyOZT22GAer-w5wDtv-Bb5awlncAJQ1OICM&e=
>>


  reply	other threads:[~2018-03-02  1:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28  9:00 Possible usb_request leak in the function dwc2_gadget_complete_isoc_request_ddma Zengtao (B)
2018-02-28 10:27 ` Minas Harutyunyan
2018-03-02  1:48   ` Zengtao (B) [this message]
2018-03-02 10:10     ` 答复: " Minas Harutyunyan
2018-03-02 10:26       ` Minas Harutyunyan
2018-03-07  3:38         ` 答复: " Zengtao (B)
2018-03-16  8:18           ` Minas Harutyunyan

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=678F3D1BB717D949B966B68EAEB446ED0C865E22@DGGEMM506-MBX.china.huawei.com \
    --to=prime.zeng@hisilicon.com \
    --cc=John.Youn@synopsys.com \
    --cc=Minas.Harutyunyan@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).