From patchwork Wed Sep 30 09:13:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 313855 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:1081:0:0:0:0 with SMTP id r1csp21091ilj; Wed, 30 Sep 2020 02:14:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxws6ysu+b0BqUTXn1BoVtF6/P+AcFSTAb+rk7cysczaItjNp0uP2hxlPZs+2Zb6kE3CEco X-Received: by 2002:a17:906:8143:: with SMTP id z3mr1759810ejw.323.1601457251916; Wed, 30 Sep 2020 02:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601457251; cv=none; d=google.com; s=arc-20160816; b=tUjYJl5kSsdFQRT8aIl8J5yKn+D8tUY6j4Ej+feJGg02TcncgoXTSv+T7TZ8kT73pu 0djnBY+/nikg6ZIdt0p11dF5k6/sHdJECrHvbw1u8cknaIwnBntbN58jFwvij7KQedDK kmfg8FIYbMNXS+QQV3I7XvrXm/XURmdqNtx7WBBZ89J4lU0gKuBo/3E59Vwyhsv9uHbZ V9GXEjsKlTJxd2p1KCHonZAyNRi+b80HPcSQZz6rtiAJRfexrWIUAjp5jRUF8SKxweYg HByoKNgzV7UQEwKoC4asyoFt9XB0xgwXmCXv2e8utKj3cZ6QQBtWWuZma4fnEMVOHXo8 xSCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5ridk5920UfMB0nCEIpCyF/07n7stscwVpGaO1rQQhA=; b=N5rB46hescmmKca+SGeq/OBEqbRD0bR5d77xzmpBDQ6DzLJzZLknT5JOJcl0PbBaI9 A6YkChJnW3S95hnOevYRNt3VoGkwRexUWkLyNkzojjikRS4MsNGdoUDtSnT242WCiy5q Ddf06waksMNLb+hxz85kogoq3PY2b5v/2tSAD3VWjHQ3kM8gV3MFHbg+FB+Rx4RcG8mg 5huu2UkG6FfvtrFKR760a/NKeEvT17cQuycIK3P7VFsKR0HAbPECbCNuNJmj3ZKjfSUi tmIhZEhlkXFB5Iajkhzbi3g9HDvQKEYlT1YftbFYGcJT2DFsqCJBVuMID02wGBnh/r3y 7ooA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="hAI/eQIp"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m17si572171edj.540.2020.09.30.02.14.11; Wed, 30 Sep 2020 02:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="hAI/eQIp"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728673AbgI3JOK (ORCPT + 6 others); Wed, 30 Sep 2020 05:14:10 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:35008 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725779AbgI3JOJ (ORCPT ); Wed, 30 Sep 2020 05:14:09 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 08U9E35X034882; Wed, 30 Sep 2020 04:14:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1601457243; bh=5ridk5920UfMB0nCEIpCyF/07n7stscwVpGaO1rQQhA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hAI/eQIpcwJQUk0v9xFVj0B/6YmQCfL80Xrg/yduhWEsIRKVXZOIKXFFDi5MX11gu uP1TDOA+UeSEcvhtZ0zLj21Vy8JquVYtCfA16JaiksmhnfxFXsgIUZAGcHggrtQffr cr9QI/UlAe+cvcSFFMlZvY1qtlL9mbyyk6jh9tUg= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 08U9E2CL111169 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 Sep 2020 04:14:02 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 30 Sep 2020 04:14:02 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 30 Sep 2020 04:14:02 -0500 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 08U9DuJY116385; Wed, 30 Sep 2020 04:13:59 -0500 From: Peter Ujfalusi To: , , , , CC: , , , , , , Subject: [PATCH 01/18] dmaengine: of-dma: Add support for optional router configuration callback Date: Wed, 30 Sep 2020 12:13:55 +0300 Message-ID: <20200930091412.8020-2-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200930091412.8020-1-peter.ujfalusi@ti.com> References: <20200930091412.8020-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Additional configuration for the DMA event router might be needed for a channel which can not be done during device_alloc_chan_resources callback since the router information is not yet present for the drivers. If there is a need for additional configuration for the channel if DMA router is in use, then the driver can implement the device_router_config callback. Signed-off-by: Peter Ujfalusi --- drivers/dma/of-dma.c | 10 ++++++++++ include/linux/dmaengine.h | 2 ++ 2 files changed, 12 insertions(+) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index 8a4f608904b9..ec00b20ae8e4 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -75,8 +75,18 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec, ofdma->dma_router->route_free(ofdma->dma_router->dev, route_data); } else { + int ret = 0; + chan->router = ofdma->dma_router; chan->route_data = route_data; + + if (chan->device->device_router_config) + ret = chan->device->device_router_config(chan); + + if (ret) { + dma_release_channel(chan); + chan = ERR_PTR(ret); + } } /* diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index dd357a747780..d6197fe875af 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -800,6 +800,7 @@ struct dma_filter { * by tx_status * @device_alloc_chan_resources: allocate resources and return the * number of allocated descriptors + * @device_router_config: optional callback for DMA router configuration * @device_free_chan_resources: release DMA channel's resources * @device_prep_dma_memcpy: prepares a memcpy operation * @device_prep_dma_xor: prepares a xor operation @@ -874,6 +875,7 @@ struct dma_device { enum dma_residue_granularity residue_granularity; int (*device_alloc_chan_resources)(struct dma_chan *chan); + int (*device_router_config)(struct dma_chan *chan); void (*device_free_chan_resources)(struct dma_chan *chan); struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)(