Received: by 10.192.165.148 with SMTP id m20csp1639127imm; Thu, 10 May 2018 14:03:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqFgd9ScHpdOn8tyxY4AX0XL4fmPeoqaq2rir+yaEuR/vmSSQrD9DOCSEdLBmrfzeFM6pKP X-Received: by 2002:a63:6fc8:: with SMTP id k191-v6mr2290337pgc.330.1525986234368; Thu, 10 May 2018 14:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525986234; cv=none; d=google.com; s=arc-20160816; b=tUf0ich2Yoy6OcMWfFiHvIY5jLre4ZEqWU2AIZ8FMacB82OieA7EtPA89gLGhO3NIr fqNq3S36vrDfHuMNUNsPkepkg0T6H4Y0yvQPYRFa3OamVqIkcrrcSIS4VQ9NVMUrmI/r tHIE5V+9UOPyuFNTlU2ZOOMfMeFEB/FZjHKX8oMx39Nz+lqAlRoYHo5ncfdH2GAmSoKp sWw+bfM3s30xBjW7LGC4vdJqdPFnNAvGyMuxYZUa7MsAselg1ujJC1MePP5oPdo4UYoF /iWS680H4IPZdrzMTnCKP5b2dPmxqgYgh9uP+So5sD4dmC/Y7SITOW9Neb3cJqwlBUDd xe/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=aCevnnRQXjsI2ioPsanhF76NXOBOGZjtAe5Cd3jqTj4=; b=ZpnGls2AeqpGuvTi3zWkVRUpl33QyEg2lYBsgLc79fNeZ8uN/uY4geD8/9bzKdWicQ YhKfnVc7IpMM61a3ggvRIVFGryBbMmel/uoGEW1K3uJoXKJe2QAvM1CCs+pmQYsOVr7h AeR5H/3fnbU609upxmziM/w+UnsuiEYzZUKP6yB7Vt1l2w3Kt9FpAjlQz1G7DkJBvney vFFJtl2Nd9VpVzGVAiGpRrV1agGCn/fkBOBJLT/emG3uwDYr1P1dTykvJNRiTX7ikOOa hDxWvWmUNhEFX6TVpQyYrhDAAsiGh6GSNvZoJ9zrmibUFP4gu8ab58Ju/FkQxsTv8wbU XrFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FFxqCX3I; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12-v6si1491885pls.278.2018.05.10.14.03.35; Thu, 10 May 2018 14:03:54 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=FFxqCX3I; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752424AbeEJVCE (ORCPT + 99 others); Thu, 10 May 2018 17:02:04 -0400 Received: from mail-vk0-f42.google.com ([209.85.213.42]:35631 "EHLO mail-vk0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171AbeEJVCC (ORCPT ); Thu, 10 May 2018 17:02:02 -0400 Received: by mail-vk0-f42.google.com with SMTP id g72-v6so2049568vke.2 for ; Thu, 10 May 2018 14:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aCevnnRQXjsI2ioPsanhF76NXOBOGZjtAe5Cd3jqTj4=; b=FFxqCX3Ij9VsPShubjudxBqiwSO2JFvKbW90nWuncA4SCsX3dkL+23imbsMLZ3E/gg iX2DWekmuQnGyLyRHWrHZcfVDYgq/ljh3rZMZVQhsJvaDoGOrWgd94UUy61xqoI4TpFY Vl6c6h+XL9J3/WxFedgp+AwLhL/6wNER50bYV6VwG4gGQaF4R4ioEh/8aiPGZbMglvFi UZ3pLuHS1/JZGT/NDO6F7LZn2jpLvKRF4SPJvMUzA0wW3ao6ekGZOre+88gjdossd2ee V+54siDm4oasvvXoH4pMguu8tsv/4FIzVCq1zAsZGstgkLvPPXAyO/g2tGfjJjRQInv8 1XPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=aCevnnRQXjsI2ioPsanhF76NXOBOGZjtAe5Cd3jqTj4=; b=FlPunw7KexBV2LggQxgczeJgxlv50FCe+bRrW5fngJKtxUVy+uuwixAlIY4I6sQlp6 Bf08+s6znsAICUnuDcypSmS7i09SFHuwUOtH0oBY/0rKtIstSDU4ZdS4wnj/pRgZzFku 0H/aZGKn/rmMHho3e62bDIZjTMK5IEsqBcgoItpxiUUAn4NtO52Hhi81C40Gf/0z6HKU s1cZvBnEoKNsa2dLk9aJHDzAP1b1g0O7HDAFPtOpPQNTYf3xwZKT+cCTk87L23spPkyC rSpLjX20D4QDuWwroTWNGFsVBBcdv5p5g1Q/w5brWrzQJo9p2yg41H/M/a+/WWj6fYvm 7b1g== X-Gm-Message-State: ALKqPwelSRX5eIGTa0tkNZQ553xhxR8VCrbwikUxu2Hyh+dFxxEOGHqi uO11nriNlS5W8ifPVHFW5eojClQwt5pfLJIP9sFmvg== X-Received: by 2002:a1f:bd56:: with SMTP id n83-v6mr2096421vkf.60.1525986120633; Thu, 10 May 2018 14:02:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.48.82 with HTTP; Thu, 10 May 2018 14:01:59 -0700 (PDT) In-Reply-To: <1525860661-18619-2-git-send-email-william.wu@rock-chips.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: Doug Anderson Date: Thu, 10 May 2018 14:01:59 -0700 Message-ID: Subject: Re: [PATCH v4 1/2] usb: dwc2: alloc dma aligned buffer for isoc split in To: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > - 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