Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp547449imm; Fri, 11 May 2018 02:34:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpsOTgjdPgdzFGvQfC0n0dAvvImyD0spCKs8wBMAoZ/mmvcHlZOhg3zx6KwQmOe1jz2Khv+ X-Received: by 2002:a62:9f15:: with SMTP id g21-v6mr4650533pfe.207.1526031289085; Fri, 11 May 2018 02:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526031289; cv=none; d=google.com; s=arc-20160816; b=jlu8soILSI9vEis8PkulMLfOsrqBM6YCJ8mqipbzPkdu7iZ8Rjn4yJfVnBepgw97fY 7F6/jqCjdgpamQZGv0Stsjqu1EEsUeMX1JBdEt3VtljMSac9Zfuac+YscvZoBgWPmQQc yBgV3NFNICyiENv+0dYtJ6WXodEDUAvmjL2EhHl60D4wqrwc0PLuOPxrBmpQ1fCHn3tv TejtHth1v/e4Lat8OJO7emod1rJyFd9aW5QGF2K4X4XEekve5l/h7G5sX0UtfZDPNVXl tj7X7v+P9070TighAjb8aKppuJ3tjvWyvh9ppww1hupz6KUwhmBbSU750NwaIb99qarE 30/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=JwskvU6ndEmzRXc5o6WhHLqmTnzwaHiBAYi7mizFZqE=; b=V3aGL/oTmOoZeirrsGAj6nS0AubURVTiXY1TxqPrusQnREsOkIzz1KnplLWjbxlUjl 78dpk0hC2BYaA5StLpsDGO5+kU7YEuOOC390DuoAKpRJy4SSNvpWkZhTY5Ap0MHes+NO qECa6ZKcs/5ILqNo5H5+3TulfpcKFWh5aBFr0UWzo5GWc5vz2J3R+SwKG+gLMK6ry8fp zSCashMVMKHHpmZ13MUb4S5FgXzMdUa+zPvcU3v1eE300x1lCvox7K+T9FnfvWnw0rqy Ya/66zsWp7S8x8lVPY0GffzU39/cyRy9ov2x+hYPk4tC5lfKr3aI+PK1IlGmwQAPlqgf R3aQ== 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 64-v6si2298640pgd.511.2018.05.11.02.34.34; Fri, 11 May 2018 02:34:49 -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 S1752733AbeEKJeN (ORCPT + 99 others); Fri, 11 May 2018 05:34:13 -0400 Received: from regular1.263xmail.com ([211.150.99.134]:40784 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752476AbeEKJeM (ORCPT ); Fri, 11 May 2018 05:34:12 -0400 Received: from wulf?rock-chips.com (unknown [192.168.167.110]) by regular1.263xmail.com (Postfix) with ESMTP id E7C7C9154; Fri, 11 May 2018 17:34:05 +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 418283BC; Fri, 11 May 2018 17:33:57 +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: <67274dbab7315ca3e374fadefd25b041> 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 1731Z5YNAE; Fri, 11 May 2018 17:34:04 +0800 (CST) Subject: Re: [PATCH v4 1/2] usb: dwc2: alloc dma aligned buffer for isoc split in To: Doug Anderson , William Wu Cc: 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: <1525860661-18619-1-git-send-email-william.wu@rock-chips.com> <1525860661-18619-2-git-send-email-william.wu@rock-chips.com> From: wlf Message-ID: <60703355-c0e5-f6f4-0933-1efb7b46dded@rock-chips.com> Date: Fri, 11 May 2018 17:33:55 +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日 05:01, Doug Anderson 写道: > Hi, > > On Wed, May 9, 2018 at 3:11 AM, William Wu wrote: >> The commit 3bc04e28a030 ("usb: dwc2: host: Get aligned DMA in >> a more supported way") rips out a lot of code to simply the >> allocation of aligned DMA. However, it also introduces a new >> issue when use isoc split in transfer. >> >> In my test case, I connect the dwc2 controller with an usb hs >> Hub (GL852G-12), and plug an usb fs audio device (Plantronics >> headset) into the downstream port of Hub. Then use the usb mic >> to record, we can find noise when playback. >> >> It's because that the usb Hub uses an MDATA for the first >> transaction and a DATA0 for the second transaction for the isoc >> split in transaction. An typical isoc split in transaction sequence >> like this: >> >> - SSPLIT IN transaction >> - CSPLIT IN transaction >> - MDATA packet >> - CSPLIT IN transaction >> - DATA0 packet >> >> The DMA address of MDATA (urb->dma) is always DWORD-aligned, but >> the DMA address of DATA0 (urb->dma + qtd->isoc_split_offset) may >> not be DWORD-aligned, it depends on the qtd->isoc_split_offset (the >> length of MDATA). In my test case, the length of MDATA is usually >> unaligned, this cause DATA0 packet transmission error. >> >> This patch use kmem_cache to allocate aligned DMA buf for isoc >> split in transaction. Note that according to usb 2.0 spec, the >> maximum data payload size is 1023 bytes for each fs isoc ep, >> and the maximum allowable interrupt data payload size is 64 bytes >> or less for fs interrupt ep. So we set the size of object to be >> 1024 bytes in the kmem cache. >> >> Signed-off-by: William Wu >> --- >> Changes in v4: >> - get rid of "qh->dw_align_buf_size" >> - allocate unaligned_cache for Address DMA mode and Desc DMA mode >> - freeing order opposite of allocation > You only did half of this. You changed the order under "error4" but > forgot to make dwc2_hcd_remove() match. Ah, sorry, I'm careless. > > >> - do dma_map_single() with the size of DWC2_KMEM_UNALIGNED_BUF_SIZE >> >> Changes in v3: >> - Modify the commit message >> - Use Kmem_cache to allocate aligned DMA buf >> - Fix coding style >> >> Changes in v2: >> - None >> >> drivers/usb/dwc2/core.h | 3 ++ >> drivers/usb/dwc2/hcd.c | 87 ++++++++++++++++++++++++++++++++++++++++++-- >> drivers/usb/dwc2/hcd.h | 8 ++++ >> drivers/usb/dwc2/hcd_intr.c | 8 ++++ >> drivers/usb/dwc2/hcd_queue.c | 3 ++ >> 5 files changed, 105 insertions(+), 4 deletions(-) > My only remaining comment is a really nitty detail. Unless someone > else feels strongly about it, I'm not sure it's worth spinning the > patch just for that nit unless someone else has review comments. > > I believe I've looked at this enough to say: > > Reviewed-by: Douglas Anderson Thank you very much for your review. I will submit V5 patches to fix the order of memory free in dwc2_hcd_remove(), and also add Review-by. > > >