Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp541451imm; Fri, 11 May 2018 02:27:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr4YwvWDBogKqBCSYcadldJ+rAH4Wne5Zm9T4+YVIsDORcAOS4MyMNgMfJvFrv8vb6pkpR0 X-Received: by 2002:aa7:82d0:: with SMTP id f16-v6mr4744359pfn.199.1526030863477; Fri, 11 May 2018 02:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526030863; cv=none; d=google.com; s=arc-20160816; b=UG4B6YiBLabL68ZHjr7nXXCiYYbF04NWeZHURniUVqNjQJLzQKfreHNeTBiWvUYygN OKJ1ytrea5KCLwQKzPUvVhC8eyThOTlNeIDeadqKgHQWfd+URNb0drJHhJ94abOZchhx l84aUptTphZnCLCSaBR3TZbplCivvnz5ft0ZlBaPTMec4gNzcl0XNwezG/puS5srEGMl ZedFSVoZYfnp97Y/bLp4Zv3timSXk7oqgSk2SQZhL6K87hMOLBDc0DxAq4ew17OQkj0J 37VXbXcCCFIQii0+gOxqO7GyIIBC3Tp+L23yREqKa6zb+1u89y0hyyaVisUqfRdZ7HKk ag+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=y3lxbBelTSNH/Q5u2B+ZE29IXXrU4i3C3ECr/m0XZNw=; b=uY8gUt/9ieRYVwhGOjzxW/1Pq55XAmC1uNwPpnVoWYjn8f+/gFNAXbM4SmAUE6EPNZ 0qZyPknoVPcKr1UHjAthr2/ibgqRc1dchawx24XbK3e3G0jrLdof1O1PeBJQrOUYNQqu Fi5LaneEma9jJwpGnG41e5BZs/HzQ+w5Js0NsXB6Qa4vIh8nCgrr+xyUoaj4oUfn3m5b ICiBsgHT2z9RhndTN1kDQMsqQbhWQLspd/ZQdLWJuFuf+UeFgYv28nvzaUhiKRNT8N6X W04RpQc0yRNkG/EpLfDWyGXgT163zwkmENBNnDsesxBpxRfrFIgM0lkUfNSXxYHq/Kjs AFrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si2810022pli.269.2018.05.11.02.27.29; Fri, 11 May 2018 02:27:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752744AbeEKJ1O (ORCPT + 99 others); Fri, 11 May 2018 05:27:14 -0400 Received: from regular1.263xmail.com ([211.150.99.138]:40523 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750806AbeEKJ1L (ORCPT ); Fri, 11 May 2018 05:27:11 -0400 Received: from wulf?rock-chips.com (unknown [192.168.167.179]) by regular1.263xmail.com (Postfix) with ESMTP id A3E9D7B38; Fri, 11 May 2018 17:27:03 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from [172.16.12.12] (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 5CD6E387; Fri, 11 May 2018 17:27:00 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: wulf@rock-chips.com X-FST-TO: milesschofield@aopen.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: wulf@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: wulf@rock-chips.com X-DNS-TYPE: 0 Received: from [172.16.12.12] (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 4496HJ4QLA; Fri, 11 May 2018 17:27:04 +0800 (CST) Subject: Re: [PATCH v3 1/2] usb: dwc2: alloc dma aligned buffer for isoc split in To: Doug Anderson Cc: William Wu , hminas@synopsys.com, felipe.balbi@linux.intel.com, Greg Kroah-Hartman , Sergei Shtylyov , =?UTF-8?Q?Heiko_St=c3=bcbner?= , LKML , linux-usb@vger.kernel.org, "open list:ARM/Rockchip SoC..." , Frank Wang , =?UTF-8?B?6buE5rab?= , "daniel.meng" , John Youn , =?UTF-8?B?546L5b6B5aKe?= , zsq@rock-chips.com, =?UTF-8?B?6Kix5ZiJ6YqY?= , Stan Tsui , =?UTF-8?B?U3BydWNlIFd1ICjlkLPlu7rli7Mp?= , Martin Tsai , Kevin Hsueh , =?UTF-8?B?TW9uLUplciBXdSAo5ZCz5a2f5ZOyKQ==?= , =?UTF-8?B?Q2xhdWQgQ2hhbmcgKOW8teaBreeviSk=?= , =?UTF-8?B?U2FuIExpbiAo5p6X5bu66I+xKQ==?= , Ren Kuo , "David H.T. Wang" , Fong Lin , Steven Cheng , Tom Chen , Don Chang , milesschofield@aopen.com References: <1525748846-7767-1-git-send-email-william.wu@rock-chips.com> <1525748846-7767-2-git-send-email-william.wu@rock-chips.com> <196bd304-3c6b-91b6-1743-50d6d13fc5a5@rock-chips.com> From: wlf Message-ID: <3768eb42-98c4-5bd0-a796-5ba36d03cd35@rock-chips.com> Date: Fri, 11 May 2018 17:26:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Doug, 在 2018年05月11日 04:59, Doug Anderson 写道: > Hi, > > On Wed, May 9, 2018 at 1:55 AM, wlf wrote: >>>>>> + } else if (hsotg->params.host_dma) { >>>>> Are you sure this is "else if"? Can't you have descriptor DMA enabled >>>>> in the controller and still need to do a normal DMA transfer if you >>>>> plug in a hub? Seems like this should be just "if". >>>> Sorry, I don't understand the case "have descriptor DMA enabled in the >>>> controller and still need to do a normal DMA transfer". But maybe it >>>> still >>>> has another problem if just use "if" here, because it will create kmem >>>> caches for Slave mode which actually doesn't need aligned DMA buf. >>> So right now your code looks like: >>> >>> if (hsotg->params.dma_desc_enable || >>> hsotg->params.dma_desc_fs_enable) { >>> ... >>> ... >>> } else if (hsotg->params.host_dma) { >>> ... >>> } >>> >>> >>> I've never played much with "descriptor DMA" on dwc2 because every >>> time I enabled it (last I tried was years ago) a whole bunch of >>> peripherals stopped working and I didn't dig (I just left it off). >>> Thus, I'm no expert on descriptor DMA. ...that being said, my >>> understanding is that if you enable descriptor DMA in the controller >>> then it will enable a smarter DMA mode for some of the transfers. >>> IIRC Descriptor DMA mode specifically can't handle splits. Is my >>> memory correct there? Presumably that means that when you enable >>> descriptor DMA in the controller the driver will automatically fall >>> back to normal Address DMA mode if things get too complicated. When >>> it falls back to Address DMA mode, presumably dwc2_hcd_init() won't >>> get called again. That means that any data structures that are needed >>> for Address DMA need to be allocated in dwc2_hcd_init() even if >>> descriptor DMA is enabled because we might need to fall back to >>> Address DMA. >>> >>> Thus, I'm suggesting changing the code to: >>> >>> if (hsotg->params.dma_desc_enable || >>> hsotg->params.dma_desc_fs_enable) { >>> ... >>> ... >>> } >>> >>> if (hsotg->params.host_dma) { >>> ... >>> } >>> >>> >>> ...as I said, I'm no expert and I could just be confused. If >>> something I say seems wrong please correct me. >> Ah, I got it. Thanks for your detailed explanation. Although I don't know if >> it's possible that dwc2 driver automatically fall back to normal Address DMA >> mode when desc DMA work abnormally with split, I agree with your suggestion. >> I'll fix it in V4 patch. > Hmm, I guess you're right. I did a quick search and I can't find any > evidence of a fallback like this. Maybe I dreamed that. I found some > old comment in the commit history that said: I think you're right. I find that it's possible to fall back to Address DMA mode if desc DMA initialization failure. The error case is:in dwc2_hcd_init(),  if it fails to create dwc2 generic desc cache or dwc2 hs isoc desc cache, then it will disable desc DMA and fall back to Address DMA mode. > > /* > * Disable descriptor dma mode by default as the HW can support > * it, but does not support it for SPLIT transactions. > * Disable it for FS devices as well. > */ > > ...and it looks there's currently nobody using descriptor DMA anyway > (assuming I read the code correctly). It does seem like people were > ever going to turn it on then it would have to be dynamic as I was > dreaming it was... Yes, the dwc2 desc DMA mode can't support split transaction. So few people use desc DMA mode for OTG Host mode. BTW, I find that the latest code enable desc DMA mode by default for the OTG peripheral mode if the dwc2 hardware support desc DMA. >