Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1543936ybj; Fri, 8 May 2020 03:56:46 -0700 (PDT) X-Google-Smtp-Source: APiQypLiJzGDdJ+6zxMdaEX8J3woMQ2KY6/vDwm3v45/sDbHZxLueuJTY0dMeXG3H/Mzl1gtzixL X-Received: by 2002:a17:907:7210:: with SMTP id dr16mr1307127ejc.197.1588935406190; Fri, 08 May 2020 03:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588935406; cv=none; d=google.com; s=arc-20160816; b=qHE1e/7/VIfAl4VSIyGOUrv3nkqx8FbG2JT+Mnfbow1P1HEDBHEGWdcuEZyjAmfZR4 P1WUlvGO6np9zXet3zbn723Q7lwZ7/AU4i1mzYcMYkfgt3oMscDmns/GaGLMWT4vrJ6Z XyUb/SZQNW4MavnZ0Wgea5oMXYeBpaLWllqCyPevTnV9Ufs9NxV6xMP5dFGg2r/FPkeD uOIcuqSZX3L0oTrF3iKLyQ0bhsxzfX+Hnr102VGt5CFUzLUMJ/3QFiuXfhwlsF8KeFK5 VhR9TfbOGF//C8IvHapL+Sqk+kVHfiq7jJh7DDUGadJohqHs5jdy77jmknuZ77dBoAJL y1qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sjpBvHFdSqmAwigSxytWHkpjNbrAhyp9u2MkiK71iKI=; b=vjv3J9J58Gi5Cx/j8Tm6u6bP4nMDB2uiA3mQvWtKDQ63ArtlguQUIrLVONMDKlaxmT nw9FwWIyBihx8EjcGT0PMpX4QyQQG/EYC8qHcMYXaCKuLU1Nb241MFO+MkZJ1p8skIUc u90LGN8Yk8peZloLRg5Ve+1khpHg2tq1yOFL+lSeV2tuV6+wmcWABtsD/8g3fYCyFS4R kAGYz27zM5w5s0xfFr0xkYYgT+7blZR0+uBIeLvCwXZrhakXvpyMbjO2vjonolo1ApkP gYZCZ6o0qUC/fKR9/9zaCe7mNJ96fGXU2nejOgknRQPWRteg01CSAm9dg/RnFgDVoam4 uKEA== 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 u16si713399edd.86.2020.05.08.03.56.13; Fri, 08 May 2020 03:56:46 -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 S1727884AbgEHKxa (ORCPT + 99 others); Fri, 8 May 2020 06:53:30 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:41774 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727839AbgEHKx2 (ORCPT ); Fri, 8 May 2020 06:53:28 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 0868080307C2; Fri, 8 May 2020 10:53:22 +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 2IanKEQvf44Q; Fri, 8 May 2020 13:53:21 +0300 (MSK) From: Serge Semin To: Vinod Koul , Viresh Kumar , Andy Shevchenko , Dan Williams CC: Serge Semin , Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , Arnd Bergmann , Rob Herring , , , , Subject: [PATCH v2 3/6] dmaengine: dw: Set DMA device max segment size parameter Date: Fri, 8 May 2020 13:53:01 +0300 Message-ID: <20200508105304.14065-4-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200508105304.14065-1-Sergey.Semin@baikalelectronics.ru> References: <20200306131048.ADBE18030797@mail.baikalelectronics.ru> <20200508105304.14065-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 Maximum block size DW DMAC configuration corresponds to the max segment size DMA parameter in the DMA core subsystem notation. Lets set it with a value specific to the probed DW DMA controller. It shall help the DMA clients to create size-optimized SG-list items for the controller. This in turn will cause less dw_desc allocations, less LLP reinitializations, better DMA device performance. Signed-off-by: Serge Semin Cc: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle Cc: Arnd Bergmann Cc: Andy Shevchenko Cc: Dan Williams Cc: Rob Herring Cc: linux-mips@vger.kernel.org Cc: devicetree@vger.kernel.org --- Changelog v2: - This is a new patch created in place of the dropped one: "dmaengine: dw: Add LLP and block size config accessors". --- drivers/dma/dw/core.c | 17 +++++++++++++++++ drivers/dma/dw/regs.h | 18 ++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c index 21cb2a58dbd2..8bcd82c64478 100644 --- a/drivers/dma/dw/core.c +++ b/drivers/dma/dw/core.c @@ -1054,6 +1054,7 @@ int do_dma_probe(struct dw_dma_chip *chip) struct dw_dma *dw = chip->dw; struct dw_dma_platform_data *pdata; bool autocfg = false; + unsigned int block_size = 0; unsigned int dw_params; unsigned int i; int err; @@ -1184,6 +1185,18 @@ int do_dma_probe(struct dw_dma_chip *chip) dwc->block_size = pdata->block_size; dwc->nollp = !pdata->multi_block[i]; } + + /* + * Find maximum block size to be set as the DMA device maximum + * segment size. By doing so we'll have size optimized SG-list + * items for the channels with biggest block size. This won't + * be a problem for the rest of the channels, since they will + * still be able to split the requests up by allocating + * multiple DW DMA LLP descriptors, which they would have done + * anyway. + */ + if (dwc->block_size > block_size) + block_size = dwc->block_size; } /* Clear all interrupts on all channels. */ @@ -1220,6 +1233,10 @@ int do_dma_probe(struct dw_dma_chip *chip) BIT(DMA_MEM_TO_MEM); dw->dma.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; + /* Block size corresponds to the maximum sg size */ + dw->dma.dev->dma_parms = &dw->dma_parms; + dma_set_max_seg_size(dw->dma.dev, block_size); + err = dma_async_device_register(&dw->dma); if (err) goto err_dma_register; diff --git a/drivers/dma/dw/regs.h b/drivers/dma/dw/regs.h index 3fce66ecee7a..20037d64f961 100644 --- a/drivers/dma/dw/regs.h +++ b/drivers/dma/dw/regs.h @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -308,16 +309,17 @@ static inline struct dw_dma_chan *to_dw_dma_chan(struct dma_chan *chan) } struct dw_dma { - struct dma_device dma; - char name[20]; - void __iomem *regs; - struct dma_pool *desc_pool; - struct tasklet_struct tasklet; + struct dma_device dma; + struct device_dma_parameters dma_parms; + char name[20]; + void __iomem *regs; + struct dma_pool *desc_pool; + struct tasklet_struct tasklet; /* channels */ - struct dw_dma_chan *chan; - u8 all_chan_mask; - u8 in_use; + struct dw_dma_chan *chan; + u8 all_chan_mask; + u8 in_use; /* Channel operations */ void (*initialize_chan)(struct dw_dma_chan *dwc); -- 2.25.1