From patchwork Wed Jan 17 00:35:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 861970 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="W4z+eB/3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLp6n29mbz9s75 for ; Wed, 17 Jan 2018 11:36:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751182AbeAQAgQ (ORCPT ); Tue, 16 Jan 2018 19:36:16 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:46175 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750908AbeAQAgQ (ORCPT ); Tue, 16 Jan 2018 19:36:16 -0500 Received: by mail-pg0-f65.google.com with SMTP id s9so8549590pgq.13 for ; Tue, 16 Jan 2018 16:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hxBfj4VkIK48Do30B/HBw4SfRMXCI0WRpT3nyl69Ifo=; b=W4z+eB/3irt3MqGp+fpOc+bpPeFkn7GHIEkzZKchvOY0FkAFgfDazpEYdYu7T3gNVr uRBMm66tjvCi2iRLwp+KqhlhaOxIN0k6L210Ro6wasCboJ5ocuAAsh9PxesYTwXZDU/v bPtr13ABeGaaUGtl6i41nqC97wjTcHqBnTx6E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hxBfj4VkIK48Do30B/HBw4SfRMXCI0WRpT3nyl69Ifo=; b=j/GWvFzYjRyeW9Gy/B1gxG0fu23TfFWKxjgoj9sXny/fURxXmOpJFqVvGRFVv1bDFJ wp49sfOFXHtXrQCPX1/G7uDNiejV2WkqqF73rE+HXEtMe75tLaTueM4PV0uLYG+LaSbz RbZwyBkZx8AyZkqpzH/xUsiaK5G9yh2W0FmcSJwT+ziUXWDRyYXbyE86tCD1IX1NjOeC qBArweDvpgWibkpip5azNhoi50wDIg4o1cXppX9FJQYSZbT/Ksq5TiAA4hiaMnXFwBnU 4IfHjYEuVcTQn0PbLrD1+s6HeFDnhB+4PzefncUEetrX4NwFmR7gdcXqkfF3wlNVEr5F wfwQ== X-Gm-Message-State: AKwxytftdt9ecc/q381L3ub7B5Hyqa10wEvm7MyrMJ+nKj1s7il0xq0K JS9XXCltKqtQvrkmi+h9NpUHQQ== X-Google-Smtp-Source: ACJfBosQHjnqwWho/31YRPQh0JtQ321XIOAf6bJ0vTd0N1OmtyI/0qiSE02E+vpz7Gh1cjfQCpFShA== X-Received: by 10.99.113.75 with SMTP id b11mr22623205pgn.271.1516149375754; Tue, 16 Jan 2018 16:36:15 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:0:1000:1600:1dfc:23a3:37e7:107c]) by smtp.gmail.com with ESMTPSA id 15sm5792104pfi.97.2018.01.16.16.36.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 16:36:14 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Cc: thierry.reding@gmail.com, heiko@sntech.de, daniel.vetter@intel.com, chris@chris-wilson.co.uk, linux-tegra@vger.kernel.org, Gurchetan Singh Subject: [PATCH 3/4] drm: add ARM flush implementations Date: Tue, 16 Jan 2018 16:35:58 -0800 Message-Id: <20180117003559.67837-3-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180117003559.67837-1-gurchetansingh@chromium.org> References: <20180117003559.67837-1-gurchetansingh@chromium.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org The DMA API can be used to flush scatter gather tables and physical pages on ARM devices. Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/drm_cache.c | 17 +++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 7 ++----- drivers/gpu/drm/tegra/gem.c | 6 +----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c index 3d2bb9d71a60..98d6ebb40e96 100644 --- a/drivers/gpu/drm/drm_cache.c +++ b/drivers/gpu/drm/drm_cache.c @@ -105,6 +105,18 @@ drm_flush_pages(struct device *dev, struct page *pages[], (unsigned long)page_virtual + PAGE_SIZE); kunmap_atomic(page_virtual); } +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64) + unsigned long i; + dma_addr_t dma_handle; + + if (!dev) + return; + + for (i = 0; i < num_pages; i++) { + dma_handle = phys_to_dma(drm->dev, page_to_phys(pages[i])); + dma_sync_single_for_device(dev, dma_handle, PAGE_SIZE, + DMA_TO_DEVICE); + } #else pr_err("Architecture has no drm_cache.c support\n"); WARN_ON_ONCE(1); @@ -136,6 +148,11 @@ drm_flush_sg(struct device *dev, struct sg_table *st) if (wbinvd_on_all_cpus()) pr_err("Timed out waiting for cache flush\n"); +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64) + if (!dev) + return; + + dma_sync_sg_for_device(dev, st->sgl, st->nents, DMA_TO_DEVICE); #else pr_err("Architecture has no drm_cache.c support\n"); WARN_ON_ONCE(1); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 8ac7eb25e46d..0157f90b5d10 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -99,15 +100,11 @@ static int rockchip_gem_get_pages(struct rockchip_gem_object *rk_obj) /* * Fake up the SG table so that dma_sync_sg_for_device() can be used * to flush the pages associated with it. - * - * TODO: Replace this by drm_flush_sg() once it can be implemented - * without relying on symbols that are not exported. */ for_each_sg(rk_obj->sgt->sgl, s, rk_obj->sgt->nents, i) sg_dma_address(s) = sg_phys(s); - dma_sync_sg_for_device(drm->dev, rk_obj->sgt->sgl, rk_obj->sgt->nents, - DMA_TO_DEVICE); + drm_flush_sg(drm->dev, rk_obj->sgt); return 0; diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index ab1e53d434e8..9945fd2f6bd6 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -230,15 +230,11 @@ static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo) /* * Fake up the SG table so that dma_sync_sg_for_device() can be used * to flush the pages associated with it. - * - * TODO: Replace this by drm_clflash_sg() once it can be implemented - * without relying on symbols that are not exported. */ for_each_sg(bo->sgt->sgl, s, bo->sgt->nents, i) sg_dma_address(s) = sg_phys(s); - dma_sync_sg_for_device(drm->dev, bo->sgt->sgl, bo->sgt->nents, - DMA_TO_DEVICE); + drm_flush_sg(drm->dev, bo->sgt); return 0;