Received: by 10.192.165.148 with SMTP id m20csp1633520imm; Thu, 10 May 2018 13:59:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhYPvVloulZ9f4LkPa1l3nlQEZ2sO9+IN3t7lUkp3pnao164PgERw30hb+EF6UeGzUefDL X-Received: by 2002:a17:902:b908:: with SMTP id bf8-v6mr2728783plb.358.1525985986151; Thu, 10 May 2018 13:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525985986; cv=none; d=google.com; s=arc-20160816; b=Ugm1YmoLRK3XbkFB8oxJQAgwywpb6sEuuKcaCNvemVtLv8Zu9f54lDiHW5/1n3sp1J wIHA9ZlQJG43p8WJiFPMALvFMog/73w9uGFTfuut4hgSVAfsxRtmMhO/epV5neSnh2RB IDvo0TF2F/YojRr1JmPXKc1DSSp+IQmZktBSMdNwQipo5fOU4B+G/KzEr9iAZfcIvsbD 2Zurk5eftklSOCHJstI6alvFZMrzPXQ2KHciX8pwQ9//FTeRLeSUEMm/UXUy1acE6e6g ZQdqteh3NEtprgwe3+3zCXEjj4d00kvHNL9tMSYeLhqO3dqHMRVa5KV+axGjy4MB1iH5 opEg== 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=M8HtdGZF/017Jtizf5na+uB2g+LArw+kGvtin2zh55U=; b=iBEWrqacoMqfkiKpVK2p04VG4YshCG/AAENH8v5aOWojnzy/crtHMQZs2byNKSysuW 846VoxXV7jIyGT61wcdocJ35daz5knq63g/7gk9zcTu3u2dwC+v6hyVELSBa8HTR40BJ 5NtnJbO/dbBNbEU1QSq3coFDAi25Dc+tyCVqH+v+QGt/wN09SmSbVUQGD8qoN8u49HRT HpeBoXshIxS+9ZhpjHrePtXg2gDpxGj6rBm8g5RqG9IQ/ZBrs0FAErctol73CBaxpmzO s850wAE1Q7dhneYXCv4915J0aRljKpuiBOa4roeVJ9DnE4Asi8rPZxSjwC2Gx2W0IDKY jQrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tgYlaYef; 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 f11-v6si1340552pgr.275.2018.05.10.13.59.30; Thu, 10 May 2018 13:59:46 -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=tgYlaYef; 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 S1752449AbeEJU7R (ORCPT + 99 others); Thu, 10 May 2018 16:59:17 -0400 Received: from mail-vk0-f41.google.com ([209.85.213.41]:35441 "EHLO mail-vk0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752104AbeEJU7P (ORCPT ); Thu, 10 May 2018 16:59:15 -0400 Received: by mail-vk0-f41.google.com with SMTP id g72-v6so2044941vke.2 for ; Thu, 10 May 2018 13:59:15 -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=M8HtdGZF/017Jtizf5na+uB2g+LArw+kGvtin2zh55U=; b=tgYlaYef/aNBDcf4f2Zxg5Sf6HgiVIAxIILP7ik4Q/9WKeOZ7xfSMvpULgZ5tFh8fY Bb++yBW94cUkIi5XNjaOAsd9ExAex9PzgpYkTtcnbWm4GNABXiZxL8da7PvzF4xiiwps uOgCucPb2BNdWh48Pikme5EosZ0x5g4pu+o3zoiWF8jwWxeSN10Z7dx5rT+7Cm7Srxtb bcA4JzIrXBuZjjOdKey91lGGkuBlV8InXU+33jRoHQ2yYgN2dwv16dkEyA1HNaSmlaIp hO2SWtKsCycZPtYNtUg9zAKkFxXDIdPX2tAv2dhY4GSxSuoXCM78UfezVEA8ggGryFlK d8YA== 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=M8HtdGZF/017Jtizf5na+uB2g+LArw+kGvtin2zh55U=; b=HNURf2gOdhi0nG6VF/L6whlVvY54tqmDQ4BM8QwQ4Wa4k805QMIIG3FgLjjjjz/eop qTM0DaghCrvxNAGhvUZ/xG8mbPdRR8pl8JYEohGccJ/7RFcAcKd6jQWHHHoqczZCa5aM uUUdJS93xB8WasH0i4KGZAFwztjSqDK+r43bpSkRyafPQOddiDayQqO9yAy06h8dhB0N CQrzdNkRHogfLn1uOI7UFYoU02EIVaBZI8NxIoFiPT4MO/lwhCKgmL3nm6XdL9HSQSG3 rA28XxOU21EW6WE7LmTJo5HkSNkay9V4DF5V+wT9BDDAJ9EcZayEcDn858ouWZoPXOIN TD6w== X-Gm-Message-State: ALKqPwejdnJYe6JpY2Xv6NVD1jmnKwD0sIOJuY/1/n6Lu0KQI2vVP5N5 cmhWtcdazcspeqm5DchYfNydHg2QgiRcC7ZsYvRSZg== X-Received: by 2002:a1f:d304:: with SMTP id k4-v6mr2087797vkg.101.1525985954079; Thu, 10 May 2018 13:59:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.48.82 with HTTP; Thu, 10 May 2018 13:59:13 -0700 (PDT) In-Reply-To: <196bd304-3c6b-91b6-1743-50d6d13fc5a5@rock-chips.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: Doug Anderson Date: Thu, 10 May 2018 13:59:13 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] usb: dwc2: alloc dma aligned buffer for isoc split in To: wlf 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 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 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: /* * 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... -Doug