Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp71735ybt; Thu, 9 Jul 2020 15:48:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5jsEPEtMxTzVWBaKCl/cZD0oNKRcWbuRtQXKpg6srtLstUbWriD37lg5O4d9zc0hRBNbk X-Received: by 2002:a17:906:50a:: with SMTP id j10mr45367782eja.113.1594334902768; Thu, 09 Jul 2020 15:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594334902; cv=none; d=google.com; s=arc-20160816; b=kAut38tc+7fsh/YoGB+X3X6vPDNFuTlzwm8eOrVxZnhTevHhGclf1IhHgm49sof4pN TFxssv45PQLvAqtyj/yB+94QWokcJL2bxXwWhz6lr7ju9k3UwBQ1VpfU+JERAFbHhNZn wtTpituKUY4r1B5ZNi0IspEyX5yACnC74CxiNGeCEFdazmK67958p1rP3dzJFZedVgrF g+RWJAQUhTfKoRpWB3DeM9Ji0rIJ9q1s/x1WPnbATywfmgq3QUOpont5hO6ynWJOyX7T nxWQCl8TBj/CvFCQrabkjHozAjIQl0WAKOfyGKKa0+u01zW079SFyUCvNZnMN+xK5j79 bVPg== 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=v3aqY2J4+iMafvd5mQFee/SGs6Z2pHkC9LxocaAoMoE=; b=VF7/rE6zMK2lrU40ccRFhy7CEZZ7ffdSVI7aUPCn4WgM6lh0AtO9FUXVboHySLKCXm Qa2NmMQSqmBVibRedKX1UkWyPGmA3TYOEpagckgZTuhs9RwxtXmW6JH+mDImusuxydnU lFM/YnqHyEUOY1eoT/dIep4plhvuUfqgUxKhsoWOArm7nHSPJoXlPHnU7v2PYF9ILobZ Y3xQ+Rk8u3a/2vuNWHKtFXi6FevH616lSDUK9wlWnmJL8xBI2jb92iYfrhkVhvA7rwQQ GB8isuod/u7kmxGFln7qx/7RK+iNIIOR7zpGnuYV7FOc2adyZBNBLGqriAWVF0IZxj/e In2A== 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 p25si2811049edy.109.2020.07.09.15.48.00; Thu, 09 Jul 2020 15:48:22 -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 S1727941AbgGIWq6 (ORCPT + 99 others); Thu, 9 Jul 2020 18:46:58 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:48196 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgGIWqR (ORCPT ); Thu, 9 Jul 2020 18:46:17 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 045D5803202F; Thu, 9 Jul 2020 22:46:13 +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 NzAlM3y_o2Qn; Fri, 10 Jul 2020 01:46:12 +0300 (MSK) From: Serge Semin To: Vinod Koul , Viresh Kumar , Dan Williams CC: Serge Semin , Serge Semin , Andy Shevchenko , Alexey Malahov , Thomas Bogendoerfer , Arnd Bergmann , Rob Herring , , , , Subject: [PATCH v7 05/11] dmaengine: Introduce DMA-device device_caps callback Date: Fri, 10 Jul 2020 01:45:44 +0300 Message-ID: <20200709224550.15539-6-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200709224550.15539-1-Sergey.Semin@baikalelectronics.ru> References: <20200709224550.15539-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 There are DMA devices (like ours version of Synopsys DW DMAC) which have DMA capabilities non-uniformly redistributed between the device channels. In order to provide a way of exposing the channel-specific parameters to the DMA engine consumers, we introduce a new DMA-device callback. In case if provided it gets called from the dma_get_slave_caps() method and is able to override the generic DMA-device capabilities. Signed-off-by: Serge Semin Reviewed-by: Andy Shevchenko Cc: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Arnd Bergmann Cc: Andy Shevchenko Cc: Rob Herring Cc: linux-mips@vger.kernel.org Cc: devicetree@vger.kernel.org --- Changelog v3: - This is a new patch created as a result of the discussion with Vinod and Andy in the framework of DW DMA burst and LLP capabilities. Changelog v5: - Add in-line comment at the point of the device_caps callback invocation. - Add doc-comment for the device_caps member of struct dma_device. --- drivers/dma/dmaengine.c | 10 ++++++++++ include/linux/dmaengine.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index ad56ad58932c..ed1fd376f1a5 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -599,6 +599,16 @@ int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps) caps->cmd_resume = !!device->device_resume; caps->cmd_terminate = !!device->device_terminate_all; + /* + * DMA engine device might be configured with non-uniformly + * distributed slave capabilities per device channels. In this + * case the corresponding driver may provide the device_caps + * callback to override the generic capabilities with + * channel-specific ones. + */ + if (device->device_caps) + device->device_caps(chan, caps); + return 0; } EXPORT_SYMBOL_GPL(dma_get_slave_caps); diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index a7e4d8dfdd19..298b721c8b9f 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -799,6 +799,8 @@ struct dma_filter { * be called after period_len bytes have been transferred. * @device_prep_interleaved_dma: Transfer expression in a generic way. * @device_prep_dma_imm_data: DMA's 8 byte immediate data to the dst address + * @device_caps: May be used to override the generic DMA slave capabilities + * with per-channel specific ones * @device_config: Pushes a new configuration to a channel, return 0 or an error * code * @device_pause: Pauses any transfer happening on a channel. Returns @@ -899,6 +901,8 @@ struct dma_device { struct dma_chan *chan, dma_addr_t dst, u64 data, unsigned long flags); + void (*device_caps)(struct dma_chan *chan, + struct dma_slave_caps *caps); int (*device_config)(struct dma_chan *chan, struct dma_slave_config *config); int (*device_pause)(struct dma_chan *chan); -- 2.26.2