From patchwork Tue Dec 8 09:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 339706 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp3617665ejs; Tue, 8 Dec 2020 01:05:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4XHPbvpSTaVVZ/r8AO3LwSGPSUGfsQu663EQBBW9ZSVVa9D+DiEjY22+nQQ+++yFyKc6w X-Received: by 2002:a17:907:3e23:: with SMTP id hp35mr22685007ejc.254.1607418343211; Tue, 08 Dec 2020 01:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607418343; cv=none; d=google.com; s=arc-20160816; b=dhDFQEbtssKqvhAMs8T/OnCf7kTQK+idRJ5/5RoOjY7q96a8l+3E9TeU7rRLoq0kck clBYzpmYle4VC9QLTc0ZPgDt1PX7QADNX+dqH3mc7G9XPmQAGHED7cr8YRHNMh2rJRsi DlrHlAnT2ah+iSbazWTgZEdCXE3ArSsPtB/wwHKbhepswD7A2nHhUKye0VjQofMmHojS q0R9P+uT8aN7RSoGVfO/7NJB34o9fFRFuwV0X+T7RTWHhM5vrHp9jHPJLKOg+FICTrXu wRAJkItOEheRUXmmuFfHiUwLpkogJr4/Qq2/DR3rYdMXUE/fyaL+gVh+0/P+XxLIMx8H Zx3A== 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=HSm4+oz7ndB15ND59RBAyXDIbwXFdQb/ZAZiFLJMjns=; b=xhHnRreymuLSGsAW3YFWe9pzUB91b5tmFgcEF0KE+bS92Bc4IGCBwNrYSrCkqdF2rg FADzT5de+5XOppTFqhmJvLCQtXexIm2BNikzklF/AvBsuf5TChSltu+L1q2OPED68pov ASlCM2t1uxbTIkzPA732bI5pHSpWoqrhDQv27sOuD4wqlcEsEc37jPOlBN2vId7GB2ol XVYJOoECGtjcMLOD4TLPdFZayFVIvqqSjeghT4AB28DtX7uNLwKmvK/TraZ7hQaTDPPV Z0YK7IqQhQkkmBx4ZxSI8Nc9YpNFzmXVQSHTDVKRwKAacQxvISl5tQJ/4Od+CBPHa4yr 3TTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cJFVI0DC; 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 h18si5193516eds.65.2020.12.08.01.05.43; Tue, 08 Dec 2020 01:05:43 -0800 (PST) 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=cJFVI0DC; 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 S1728679AbgLHJFG (ORCPT + 6 others); Tue, 8 Dec 2020 04:05:06 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:34420 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728189AbgLHJFF (ORCPT ); Tue, 8 Dec 2020 04:05:05 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0B8949ko002798; Tue, 8 Dec 2020 03:04:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1607418249; bh=HSm4+oz7ndB15ND59RBAyXDIbwXFdQb/ZAZiFLJMjns=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=cJFVI0DCd7pz0AE6g3eWxmqI0OF4OUSm21jmTFuT15eADWvhxglpgzJ819ym/gHjG 2YaxynXnqtSwevC5vMHYqTOskeLf2Jbym1UVdJRaZjyG+0VkOa/cJPZBB+J3UODqDa 58SBbYoSwBYjjSBG4lSBigDDAsMWOv+wrHB7NISQ= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0B8949jB044070 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Dec 2020 03:04:09 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 8 Dec 2020 03:04:09 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE101.ent.ti.com (157.170.170.31) 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; Tue, 8 Dec 2020 03:04:09 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0B893dcC120112; Tue, 8 Dec 2020 03:04:05 -0600 From: Peter Ujfalusi To: , , , CC: , , , , , , , Subject: [PATCH v3 07/20] dmaengine: of-dma: Add support for optional router configuration callback Date: Tue, 8 Dec 2020 11:04:27 +0200 Message-ID: <20201208090440.31792-8-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208090440.31792-1-peter.ujfalusi@ti.com> References: <20201208090440.31792-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 493a047ed0a2..aed44888cad3 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -805,6 +805,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 @@ -879,6 +880,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)(