Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2522588rwb; Mon, 7 Nov 2022 14:28:23 -0800 (PST) X-Google-Smtp-Source: AMsMyM5jBvkogif4+k7lqiEy1kD5theADiwTFIHkm2Uz2DUsf17nn0rYySkCtfmfxU6HId9PuQBO X-Received: by 2002:a17:906:6a27:b0:7a6:c537:ba4 with SMTP id qw39-20020a1709066a2700b007a6c5370ba4mr48017864ejc.517.1667860103409; Mon, 07 Nov 2022 14:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667860103; cv=none; d=google.com; s=arc-20160816; b=g9osM1Dy8iaLkPNeiCoRkQVLUyNRw1cqPn30eizNQJYkCw/yAzsjjXucrKuT1kNvtL 2VUgcqPRoPZjCQmCepGTi4iptiNScdyBZS8fwRlmhVVwBZae1UXoj6WPWAQu53o4anVQ Ve8FT8RpyAZdYw7Q7mWpGKjABtOsdsQ3axJtTd9IEZn9nwAIMI0kAv0cXfoXkMermndN ze/IqVkNtJZECGCJgftYyF+VXlZ4tbkMpk21oefDfmiJZa+PSsGrXz34I7UlzlQzP/W9 4wf8YrqBTaLl4oIDi0EHdIG52tCCZI1Jxhlut5mQU4O/D1OwxNjTNldyvg31T1v1Pw6b uxtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zaHch3W2dHBQ7wKVvRQE27rjvYWFoOJ5zCs8+an7Ey0=; b=R9xU9MGduXfrs1YvPZDkLbdf4sw+5JWLJfdB9M+xqSrH3GCqI9ORfUyVFYuLZ9JZK2 SsPPjtlr9v2KD1E2N6BqdKhvGceUdNRghqT7cnqPLWA2iNCddpvkxlhXtpvVW15aqCun 8Zm8udsstDpJZwAY9kOoOwaCq6W5c6NhdFG1n7f1mwp0dZfTR+E8dWYCTGMO0NKLALii XYMyPcZNPX6/J/aOoUkQ9uz8iI1/NsfmGv+s87aKFxxEzAsgGPK3pkQSdItcgHt0h5X9 daE5xG6Jx86y4fonakPonejCz5n7K+9iea5bM01dasli9qSpKvS6gKY9QY2nosjrbAuG s55Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pZIpX1DA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a056402440300b0046627848e1fsi10443298eda.630.2022.11.07.14.28.02; Mon, 07 Nov 2022 14:28:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pZIpX1DA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232363AbiKGVPr (ORCPT + 91 others); Mon, 7 Nov 2022 16:15:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233462AbiKGVPW (ORCPT ); Mon, 7 Nov 2022 16:15:22 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50A1660D1; Mon, 7 Nov 2022 13:11:39 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id f37so18471882lfv.8; Mon, 07 Nov 2022 13:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zaHch3W2dHBQ7wKVvRQE27rjvYWFoOJ5zCs8+an7Ey0=; b=pZIpX1DA0QwBB6bnAU9YT3pfgjJX/moijyhD143qSf9Mc2rMZ4B5DbxEsXHzQ33yWY cn/PZPBARO8xmivefTpKTYSLCRp5YbH17NJtiMyk1QNS0hOdm5xHhXK9tJ0DfaLzmXVR 4DNIx906025NDHf8ZWYQ53Pd1ClUhRk1vGTLwnawyw+8PE0lSmjzDl6S1DYPWTM3zl9J zSyK6VQl+5V2TgGnr1d8mk64R3zKIC7E0xGoPgXBrD22nxR8Vac3V1qURzt7g9bZbtoQ pel+Cx8odbbpHEWK0YNU+EVy4UyUUMUOdEkzsnC/iZx+tLxwWnDsQywgFcxqa5AmE/3M Mdqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zaHch3W2dHBQ7wKVvRQE27rjvYWFoOJ5zCs8+an7Ey0=; b=nHmsnBTdPxSMEVfYpdbjFC1LjaRHNktI0Fa7CHO60gROkQk7fE/mh9u7KiaTxdwwyr GrFwrCbIgSzHpb+SWTaYcngM+v8QHGANs8gMJjP7ep2IpLL5nG+Vd6pm++ZLr91a+DN8 7tGYqWyHB6Ow/1C/89JWb8Qr5NsAmf2F9R/wrUtfhUq9aPAmlwM/ML+JC1StfnYJjspz 7Lj4rJi8XYOnRp02GGXtBuVukf6gZXGx2estfBY8MtNX8nPkA8tOBTogzq8mmKL2gblT KsTjjuBuzSn+63BZIk4Kk2EdAOOTD9T0WNAquUIuoP/s65lxx6rnCpCyYYyOeWKxEWRo lEwQ== X-Gm-Message-State: ACrzQf0EbP4UoL+Eci4Ijr1T1oOBhI0Uo6pu+gQBgL3GhVeq60915y6v HkJZv+Uy1wfSJtnOMmXxqu8= X-Received: by 2002:a05:6512:2203:b0:4ad:5fbb:a58d with SMTP id h3-20020a056512220300b004ad5fbba58dmr17586460lfu.287.1667855497394; Mon, 07 Nov 2022 13:11:37 -0800 (PST) Received: from mobilestation ([95.79.133.202]) by smtp.gmail.com with ESMTPSA id v12-20020a2ea60c000000b0026fb5525ee4sm1407813ljp.116.2022.11.07.13.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:11:37 -0800 (PST) Date: Tue, 8 Nov 2022 00:11:34 +0300 From: Serge Semin To: Robin Murphy , Vinod Koul , Manivannan Sadhasivam Cc: Serge Semin , Gustavo Pimentel , Vinod Koul , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Cai Huoqing , Robin Murphy , Jingoo Han , Frank Li , Manivannan Sadhasivam , Alexey Malahov , Pavel Parkhomenko , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , caihuoqing , linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 22/24] dmaengine: dw-edma: Bypass dma-ranges mapping for the local setup Message-ID: <20221107211134.wxaqi2sew6aejxne@mobilestation> References: <20221107210438.1515-1-Sergey.Semin@baikalelectronics.ru> <20221107210438.1515-23-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221107210438.1515-23-Sergey.Semin@baikalelectronics.ru> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 08, 2022 at 12:04:36AM +0300, Serge Semin wrote: > DW eDMA doesn't perform any translation of the traffic generated on the > CPU/Application side. It just generates read/write AXI-bus requests with > the specified addresses. But in case if the dma-ranges DT-property is > specified for a platform device node, Linux will use it to create a > mapping the PCIe-bus regions into the CPU memory ranges. This isn't what > we want for the eDMA embedded into the locally accessed DW PCIe Root Port > and End-point. In order to work that around let's set the chan_dma_dev > flag for each DW eDMA channel thus forcing the client drivers to getting a > custom dma-ranges-less parental device for the mappings. > > Note it will only work for the client drivers using the > dmaengine_get_dma_device() method to get the parental DMA device. @Robin, we particularly need you opinion on this patch. I did as you said: call *_dma_configure() method to initialize the child device and set the DMA-mask here instead of the platform driver. @Vinoud, @Manivannan I had to drop your tags from this patch since its content had been significantly changed. -Sergey > > Signed-off-by: Serge Semin > > --- > > Changelog v2: > - Fix the comment a bit to being clearer. (@Manivannan) > > Changelog v3: > - Conditionally set dchan->dev->device.dma_coherent field since it can > be missing on some platforms. (@Manivannan) > - Remove Manivannan' rb and tb tags since the patch content has been > changed. > > Changelog v6: > - Directly call *_dma_configure() method on the child device used for > the DMA buffers mapping. (@Robin) > - Explicitly set the DMA-mask of the child device in the channel > allocation proecedure. (@Robin) > - Drop @Manivannan and @Vinod rb- and ab-tags due to significant patch > content change. > --- > drivers/dma/dw-edma/dw-edma-core.c | 44 ++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c > index e3671bfbe186..846518509753 100644 > --- a/drivers/dma/dw-edma/dw-edma-core.c > +++ b/drivers/dma/dw-edma/dw-edma-core.c > @@ -6,9 +6,11 @@ > * Author: Gustavo Pimentel > */ > > +#include > #include > #include > #include > +#include > #include > #include > #include > @@ -711,10 +713,52 @@ static irqreturn_t dw_edma_interrupt_common(int irq, void *data) > static int dw_edma_alloc_chan_resources(struct dma_chan *dchan) > { > struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan); > + struct device *dev = chan->dw->chip->dev; > + int ret; > > if (chan->status != EDMA_ST_IDLE) > return -EBUSY; > > + /* Bypass the dma-ranges based memory regions mapping for the eDMA > + * controlled from the CPU/Application side since in that case > + * the local memory address is left untranslated. > + */ > + if (chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL) { > + ret = dma_coerce_mask_and_coherent(&dchan->dev->device, > + DMA_BIT_MASK(64)); > + if (ret) { > + ret = dma_coerce_mask_and_coherent(&dchan->dev->device, > + DMA_BIT_MASK(32)); > + if (ret) > + return ret; > + } > + > + if (dev_of_node(dev)) { > + struct device_node *node = dev_of_node(dev); > + > + ret = of_dma_configure(&dchan->dev->device, node, true); > + } else if (has_acpi_companion(dev)) { > + struct acpi_device *adev = to_acpi_device_node(dev->fwnode); > + > + ret = acpi_dma_configure(&dchan->dev->device, > + acpi_get_dma_attr(adev)); > + } else { > + ret = -EINVAL; > + } > + > + if (ret) > + return ret; > + > + if (dchan->dev->device.dma_range_map) { > + kfree(dchan->dev->device.dma_range_map); > + dchan->dev->device.dma_range_map = NULL; > + } > + > + dchan->dev->chan_dma_dev = true; > + } else { > + dchan->dev->chan_dma_dev = false; > + } > + > return 0; > } > > -- > 2.38.0 > >