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: 10168351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B8B596055D for ; Wed, 17 Jan 2018 00:36:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9477027F7F for ; Wed, 17 Jan 2018 00:36:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8867B27F85; Wed, 17 Jan 2018 00:36:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33F4F27F7F for ; Wed, 17 Jan 2018 00:36:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA8DB6E330; Wed, 17 Jan 2018 00:36:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6900B6E330 for ; Wed, 17 Jan 2018 00:36:16 +0000 (UTC) Received: by mail-pg0-x241.google.com with SMTP id n17so2793426pgf.10 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=gHwkOsLT2CLqZs9PjxDdciWkhsMmxlI6CJyyN7z8t4P1ZT47iuOtQWMcKyw6Ks2xr6 Ed+5Tsnb/9hg/TzoV9uRa+I8NnOlg7wbbq+pxuYm0hhljYsu81btxLakbe016xSsFM7d KeE+RJNeYzYof2FFS26z1g2iBRP6N2L6vI9ZvtOSsZ4E+DYfsP6pbM2dgf/vdccCg1Vt jE4O4jUsvlFgPrD/NRxNIchjCtzDs8W3p48sygf/pZj+c9cPvQUYdLdnihztKJLIm85e gLhmpFxsGIxbOu/JdPMSPcV6fkmfCmPx2gHJccLTlMYneDgsa8nP/5QyFot9Y6a8o+Qy 4DXA== X-Gm-Message-State: AKwxytdp2I4TMPmfVzooDHXd5+iZ2aT/NWblAFbWnwOsDyR0fwLjhkPw +0VZxDaFRpsh2rMvWOSJ82Mjx43a89A= 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 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> Cc: Gurchetan Singh , thierry.reding@gmail.com, linux-tegra@vger.kernel.org, daniel.vetter@intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;