From patchwork Tue Nov 17 10:56:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 324572 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp4066727ils; Tue, 17 Nov 2020 02:57:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYQLpe9pnGgr/elPsM15WV/Fw8u367GfRAKN5m+H0hTiQd0bHIXKjIJY082xpNljLcD4qM X-Received: by 2002:a05:6402:17ac:: with SMTP id j12mr19852462edy.31.1605610651723; Tue, 17 Nov 2020 02:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605610651; cv=none; d=google.com; s=arc-20160816; b=iCB0tslvf+FMCY3rmzL+V8xNWO8uVaJkGdxwwj+Rc6WYcNYWRYhL9bRlyt13wp9/TA BcZHmZA5HxPUG7iAVkZ9y9H5mrqEry9UCwT9/vDZd397LZJgM2DbQUZoNXeSywimOERp HDUJiJYEzBnWzbSDMGs4D10tJeVRDmSGKskOea24oViU5DAttIFVHUz20hxPbjoqndg3 tCmMwN6CvSpJHUKAhR0V4oU6UZOec7ITjFknghQ8LoNNMAM/Aa9WtO/EEVcIU17buJf5 w9JI5vSdE9emvewoHsoM2baRUAGcEJ7iuKi4nNZUwsVb5dXylSciSsNgMXZOW4KIWSH0 DBrw== 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=tGzKA1yRg7i5GyT9lym3Yd/2qYgqdr076UVUiXIk8Jzwf0KarxDQ0Ei6kqmMf8zXDc 1x3EqUI975M+yC7J+qaIRPkKFDSrV+cdiVi/DuuWjhlsQkLCwn/hX6SUh4uC2e9c6l7N iPAuzpe7RcJD7P9tzAA7eE2aUV8aozvNhdp4emTPtj8EJd9ZMIYXoUyg7+wueS/toL5l /vG3mqdXI/VqnmHIjgekJRhjt0JhcV3XK6/kAXOzva/BzWAoBQU6cJbix40RczYXF0Df 1TZVlWyU2Gbd6y5lRyShRzaf1WsQ3/gGnEBLX0MXawQJh1hLCJd+FpvkHX907QUoXQHA vtEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=W1u7Mx1P; 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 dm25si12962825edb.238.2020.11.17.02.57.31; Tue, 17 Nov 2020 02:57:31 -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=W1u7Mx1P; 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 S1728085AbgKQK4e (ORCPT + 6 others); Tue, 17 Nov 2020 05:56:34 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:59658 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727347AbgKQK4d (ORCPT ); Tue, 17 Nov 2020 05:56:33 -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 0AHAuSLj019551; Tue, 17 Nov 2020 04:56:28 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1605610588; bh=5ridk5920UfMB0nCEIpCyF/07n7stscwVpGaO1rQQhA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=W1u7Mx1PwsOuT8GyG/xpAz0KvDnKeigyw/WI0qJ88iN2FyC/B9XEDPNHAhJ1+3RIA lNMyvDdGdDLwMqQdM4wZJy0aIIugdjbvWIjnA7AWEq+UnYE1CT8RpANkX7sdzz0PeG 8g0XDO4RWicCvykSk2aSrhrPy4fOsvbLUqrlFoj8= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0AHAuSfI010123 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 17 Nov 2020 04:56:28 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 17 Nov 2020 04:56:27 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE114.ent.ti.com (10.64.6.35) 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, 17 Nov 2020 04:56:27 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0AHAu6tq087311; Tue, 17 Nov 2020 04:56:25 -0600 From: Peter Ujfalusi To: , , , CC: , , , , , , , Subject: [PATCH v2 06/19] dmaengine: of-dma: Add support for optional router configuration callback Date: Tue, 17 Nov 2020 12:56:43 +0200 Message-ID: <20201117105656.5236-7-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117105656.5236-1-peter.ujfalusi@ti.com> References: <20201117105656.5236-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)(