Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2683977ybk; Tue, 12 May 2020 05:44:04 -0700 (PDT) X-Google-Smtp-Source: APiQypIEYAgwD9TFCSIg2Msg8MHFk5VzewPRx0joq00GTM2AE39W9mzrAtjN1TJZ6k95AFicWlCn X-Received: by 2002:a05:6402:b4c:: with SMTP id bx12mr18502852edb.247.1589287444147; Tue, 12 May 2020 05:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589287444; cv=none; d=google.com; s=arc-20160816; b=qfAqE9WQ0lwnmvWAn2IlQijnYsrfHd/GuMbSQ7ekrEulrKXT+NRKMsWRVSbznHPO8t +j3JxPPNu5b4IAVDfhu2V7cyVk+49N0W2WU5ziY/juty4I3ADGCFjTvA7mJA9ZckW1aL uM5XXuzbESDDPQla96Wu0p3Sbd6PjOl/E0P3jaXLcvXu6yvMyreVw4lrQFpdAulBO+cO nqEin0Tu5pirB8EFp7WJGgAl4eA2jhBeYZ5YwPpo8wnx1MbgbvezZNSmmJwPW4S7CEH+ cV5bJLKExfg43NvyI6NefClzyWxCjymn7C+u7MInHnPiaUo1sz/U1dHt+uN4mmLhE9D5 Gq5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=oQHTRIUD/kJxSdkPHj+KdwAu4hPwfSc1airJcdyq24A=; b=XOBu4W26QgaFsPamJMHZx1rvFX2Hz9M123yv55fa6Gn9DweLzIBvcT3eVt08jf8wty 6ME24CYqYbfdxYlNpvpQokDuQSDGiLJ8TuNEJcQ7LBP2MjPhkz2GRd0g7MGP/+/rhT2z 2FmL0r8YK8u5VJVWx6EJC+P1k40KtyHxvJAV0eTnMQ8GBaJIf28WR9cs465+6YNO6T44 OeC4kN9uXM/W/8JTEUUmskjkHrUZJntbIxnZUbBH787pHrBDofL8YiZh82+/3G45PZh5 iNzu8wm4v+lid+DubR3JKepGUyoCRs+KMNdbbatvE8yQaVCqw3IFGL4brLQrjiFT3u8T 6Ifg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb14si10002508edb.170.2020.05.12.05.43.40; Tue, 12 May 2020 05:44:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729682AbgELMmP (ORCPT + 99 others); Tue, 12 May 2020 08:42:15 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:53368 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbgELMmP (ORCPT ); Tue, 12 May 2020 08:42:15 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id B0FAC803080B; Tue, 12 May 2020 12:42:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PTikmzJM42z6; Tue, 12 May 2020 15:42:07 +0300 (MSK) Date: Tue, 12 May 2020 15:42:06 +0300 From: Serge Semin To: Andy Shevchenko CC: Serge Semin , Mark Brown , Vinod Koul , Viresh Kumar , Dan Williams , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , Arnd Bergmann , Rob Herring , , devicetree , dmaengine , Linux Kernel Mailing List Subject: Re: [PATCH v2 4/6] dmaengine: dw: Print warning if multi-block is unsupported Message-ID: <20200512124206.l3uv5hg2zimi24dq@mobilestation> References: <20200508105304.14065-5-Sergey.Semin@baikalelectronics.ru> <20200508112604.GJ185537@smile.fi.intel.com> <20200508115334.GE4820@sirena.org.uk> <20200511021016.wptcgnc3iq3kadgz@mobilestation> <20200511115813.GG8216@sirena.org.uk> <20200511134502.hjbu5evkiuh75chr@mobilestation> <20200511193255.t6orpcdz5ukmwmqo@mobilestation> <20200511210714.GO185537@smile.fi.intel.com> <20200511210800.GP185537@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200511210800.GP185537@smile.fi.intel.com> X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vinod, Could you join the discussion for a little bit? In order to properly fix the problem discussed in this topic, we need to introduce an additional capability exported by DMA channel handlers on per-channel basis. It must be a number, which would indicate an upper limitation of the SG list entries amount. Something like this would do it: struct dma_slave_caps { ... unsigned int max_sg_nents; ... }; As Andy suggested it's value should be interpreted as: 0 - unlimited number of entries, 1:MAX_UINT - actual limit to the number of entries. In addition to that seeing the dma_get_slave_caps() method provide the caps only by getting them from the DMA device descriptor, while we need to have an info on per-channel basis, it would be good to introduce a new DMA-device callback like: struct dma_device { ... int (*device_caps)(struct dma_chan *chan, struct dma_slave_caps *caps); ... }; So the DMA driver could override the generic DMA device capabilities with the values specific to the DMA channels. Such functionality will be also helpful for the max-burst-len parameter introduced by this patchset, since depending on the IP-core synthesis parameters it may be channel-specific. Alternatively we could just introduce a new fields to the dma_chan structure and retrieve the new caps values from them in the dma_get_slave_caps() method. Though the solution with callback I like better. What is your opinion about this? What solution you'd prefer? On Tue, May 12, 2020 at 12:08:00AM +0300, Andy Shevchenko wrote: > On Tue, May 12, 2020 at 12:07:14AM +0300, Andy Shevchenko wrote: > > On Mon, May 11, 2020 at 10:32:55PM +0300, Serge Semin wrote: > > > On Mon, May 11, 2020 at 04:58:53PM +0300, Andy Shevchenko wrote: > > > > On Mon, May 11, 2020 at 4:48 PM Serge Semin > > > > wrote: > > > > > > > > > > On Mon, May 11, 2020 at 12:58:13PM +0100, Mark Brown wrote: > > > > > > On Mon, May 11, 2020 at 05:10:16AM +0300, Serge Semin wrote: > > > > > > > > > > > > > Alas linearizing the SPI messages won't help in this case because the DW DMA > > > > > > > driver will split it into the max transaction chunks anyway. > > > > > > > > > > > > That sounds like you need to also impose a limit on the maximum message > > > > > > size as well then, with that you should be able to handle messages up > > > > > > to whatever that limit is. There's code for that bit already, so long > > > > > > as the limit is not too low it should be fine for most devices and > > > > > > client drivers can see the limit so they can be updated to work with it > > > > > > if needed. > > > > > > > > > > Hmm, this might work. The problem will be with imposing such limitation through > > > > > the DW APB SSI driver. In order to do this I need to know: > > > > > 1) Whether multi-block LLP is supported by the DW DMA controller. > > > > > 2) Maximum DW DMA transfer block size. > > > > > Then I'll be able to use this information in the can_dma() callback to enable > > > > > the DMA xfers only for the safe transfers. Did you mean something like this when > > > > > you said "There's code for that bit already" ? If you meant the max_dma_len > > > > > parameter, then setting it won't work, because it just limits the SG items size > > > > > not the total length of a single transfer. > > > > > > > > > > So the question is of how to export the multi-block LLP flag from DW DMAc > > > > > driver. Andy? > > > > > > > > I'm not sure I understand why do you need this being exported. Just > > > > always supply SG list out of single entry and define the length > > > > according to the maximum segment size (it's done IIRC in SPI core). > > > > > > Finally I see your point. So you suggest to feed the DMA engine with SG list > > > entries one-by-one instead of sending all of them at once in a single > > > dmaengine_prep_slave_sg() -> dmaengine_submit() -> dma_async_issue_pending() > > > session. Hm, this solution will work, but there is an issue. There is no > > > guarantee, that Tx and Rx SG lists are symmetric, consisting of the same > > > number of items with the same sizes. It depends on the Tx/Rx buffers physical > > > address alignment and their offsets within the memory pages. Though this > > > problem can be solved by making the Tx and Rx SG lists symmetric. I'll have > > > to implement a clever DMA IO loop, which would extract the DMA > > > addresses/lengths from the SG entries and perform the single-buffer DMA > > > transactions with the DMA buffers of the same length. > > > > > > Regarding noLLP being exported. Obviously I intended to solve the problem in a > > > generic way since the problem is common for noLLP DW APB SSI/DW DMAC combination. > > > In order to do this we need to know whether the multi-block LLP feature is > > > unsupported by the DW DMA controller. We either make such info somehow exported > > > from the DW DMA driver, so the DMA clients (like Dw APB SSI controller driver) > > > could be ready to work around the problem; or just implement a flag-based quirk > > > in the DMA client driver, which would be enabled in the platform-specific basis > > > depending on the platform device actually detected (for instance, a specific > > > version of the DW APB SSI IP). AFAICS You'd prefer the later option. > > > > So, we may extend the struct of DMA parameters to tell the consumer amount of entries (each of which is no longer than maximum segment size) it can afford: > > - 0: Auto (DMA driver handles any cases itself) > > - 1: Only single entry > > - 2: Up to two... > > It will left implementation details (or i.o.w. obstacles or limitation) why DMA > can't do otherwise. Sounds good. Thanks for assistance. -Sergey > > -- > With Best Regards, > Andy Shevchenko > >