From patchwork Tue Dec 8 09:04:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 339721 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp3619129ejs; Tue, 8 Dec 2020 01:07:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYfnZXb/2dss47ZFrj2zNMhRLBsIFc1DtzEevPpLxbgG+8qB+w1/UdRoR/Jl6vfRUmbsut X-Received: by 2002:a05:6402:b9a:: with SMTP id cf26mr18006943edb.372.1607418463437; Tue, 08 Dec 2020 01:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607418463; cv=none; d=google.com; s=arc-20160816; b=MEQKb7l12rILdXsi7xesal6EEKc/mjWlmmhvwffNNbWww+wisd+tKmrfUW9yRt0n/Z l3xf18M8IHE2sjv9zix4swjPvMQ4dveS/i8QeRaHewMtnBdqErmDLmxPQZw37a+Hze8Z NepCVexf8M7ypZE1UPjqgTDfQmfQnWExOWks6dA3AdbFMjsDH2wbMMy5KLTqgZdWDSoh rHR5ad716iuiDfoC9tr+ouJJWjntj13r9P36bdnPNG5DL8DTTUgAi1qX2GzKJC4A8KCr 9XmazaUjXorH6jyD/nAe3ay1+um4/3JWNNZpbrozIvwmlvtJRG1g+DL9QSkWhLrIjIdP 2EKg== 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=IQO2yaz/9bInpDSpHQeF6HLe6FFsup5nZ3kyY3A1F0I=; b=Sz1ovZ0wEibAAh4PwHoob80G2c8yM+Sfa52b831dyBoiTPjnuvE8t7Bl28TKkXJTLY PmAg67tPJKZx7R+dSl5zY2NY3X/xytnQOzOb1O5QdfywyU3Ynz5OzIUW6IJ2FnZRTsol fDECWeYhuGm6ZlzmX1rE8RXASLt+r12drXJ/JIzeerUb7awAEw9tcSp7TjUdgwBvBGvi DpL34D+fmC5CMo7LZscvC7lhbDGqNtgWmiQjAiLPHR6MEKXpUm/ErVV+PwAKSKKvGvFl xlSSNBrZQ4pyEnXUVrhT3uYY2EWvXevKQACLRlhL9NhXoB8KJ401Erre+EHtSPzOl2yj M9jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Z1UMw+8L; 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 o18si9973884edz.265.2020.12.08.01.07.43; Tue, 08 Dec 2020 01:07: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=Z1UMw+8L; 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 S1728822AbgLHJGA (ORCPT + 6 others); Tue, 8 Dec 2020 04:06:00 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:34474 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbgLHJF4 (ORCPT ); Tue, 8 Dec 2020 04:05:56 -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 0B894F1n002838; Tue, 8 Dec 2020 03:04:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1607418255; bh=IQO2yaz/9bInpDSpHQeF6HLe6FFsup5nZ3kyY3A1F0I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Z1UMw+8LkhV2e19/tzFzQdQXd8csZpGX/rwqA/nA0sppRJnGaYHZ9VsedAoQRC4Gf LGwVtVRUoa22J9Fr0dgtEwTRRkQV26MRmcXqrr1YNQ+2P9zByhpvZrGq2567f3eu4O vsVhSIDYz77r0q1dG4zWX4gS/NghlwCAIMscCG5k= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0B894FR5044156 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Dec 2020 03:04:15 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE107.ent.ti.com (157.170.170.37) 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:14 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE112.ent.ti.com (157.170.170.23) 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:14 -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 0B893dcD120112; Tue, 8 Dec 2020 03:04:09 -0600 From: Peter Ujfalusi To: , , , CC: , , , , , , , Subject: [PATCH v3 08/20] dmaengine: Add support for per channel coherency handling Date: Tue, 8 Dec 2020 11:04:28 +0200 Message-ID: <20201208090440.31792-9-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 If the DMA device supports per channel coherency configuration (a channel can be configured to have coherent or not coherent view) then a single device (the DMA controller's device) can not be used for dma_api for all channels as channels can have different coherency. Introduce custom_dma_mapping flag for the dma_chan and a new helper to get the device pointer to be used for dma_api for the given channel. Client drivers should be updated to be able to support per channel coherency by: - dma_map_single(chan->device->dev, ptr, size, DMA_TO_DEVICE); + struct device *dma_dev = dmaengine_get_dma_device(chan); + + dma_map_single(dma_dev, ptr, size, DMA_TO_DEVICE); Signed-off-by: Peter Ujfalusi --- include/linux/dmaengine.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index aed44888cad3..68130f5f599e 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -357,11 +357,14 @@ struct dma_chan { * @chan: driver channel device * @device: sysfs device * @dev_id: parent dma_device dev_id + * @chan_dma_dev: The channel is using custom/different dma-mapping + * compared to the parent dma_device */ struct dma_chan_dev { struct dma_chan *chan; struct device device; int dev_id; + bool chan_dma_dev; }; /** @@ -1618,4 +1621,13 @@ dmaengine_get_direction_text(enum dma_transfer_direction dir) return "invalid"; } } + +static inline struct device *dmaengine_get_dma_device(struct dma_chan *chan) +{ + if (chan->dev->chan_dma_dev) + return &chan->dev->device; + + return chan->device->dev; +} + #endif /* DMAENGINE_H */