From patchwork Wed Jan 19 22:16:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 533282 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1275140imr; Wed, 19 Jan 2022 14:16:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzn4b2OjCzmSCPa9QpYNGMRjwxLuQ45sAgiXK9bgo/UjV8h25KoAAYSAQiKW8WnfiEbwi9C X-Received: by 2002:a17:907:3e82:: with SMTP id hs2mr27459519ejc.30.1642630590925; Wed, 19 Jan 2022 14:16:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642630590; cv=none; d=google.com; s=arc-20160816; b=oM/hq7r8EEAm2kYXsqTWdKrN/G8iXjBSIMPwTJsnE2RGEOkkmLddLVBAbHGAR+n9iE krz+ei4TzwvH0ayHNt1mkR7m4cGRzevt6xxqncO5f+FoBqvedfEyr8XvGTmCBEXlfm6P gXWMwIc/uaPwgug1wuATmPqvo76YU/zLLQoZlnAhZKDKNgXebBsSdvIbIG99Hd/z+ET9 TAAzcU11oXxwDR+hHW6ngNG7f3nceUrXYUSSbXGd0+xSVOFN7EFWNcQYfejnIUXEth2Y Sm0NlXx1DCFOywYvl4PlYJTVzemhwm0ryaQa8NrOAUlCIsVEWuZf4xkfMMXWt7i6RuNU FdmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=12uuow7778XV9In4fyeSWkSK2fcajo2YhG6nP2XCnuo=; b=mev9qRBm/MQspVtFU4mwcqa3PakrBVgAPWFqn9YJ+qTI+N506QCVQFmTCnxMMWg+Ku gZjLRO0N2pblbj/MUwxxPnUjDDHixYr5N9BivwC/gU6X1LfrONJhzSLZBf7NgK6iFWe7 Xljlfqn73N1vW0Q/w0rgL18807xUOwmRAiz9mCC5QT4JqXIwnTwoaK/xm4tq/zt8Ax9m jYLeMP5QNQ0AzrxoVX+FE3RgDAhDk3f5KrF+DEVfBG1kE79gA/yjRYLYW1AfSE2oJYdn BC4M5FTMvtwLPEE16v7C5qVAlqEVEdfRal7XlT/VowMXyDEExWekG8m8CgvXN6UYwJx7 LtBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oRANZyti; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id f25si630077edv.569.2022.01.19.14.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 14:16:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oRANZyti; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BD0410EE8C; Wed, 19 Jan 2022 22:16:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EA6C10E1F5 for ; Wed, 19 Jan 2022 22:16:20 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id o15so13871404lfo.11 for ; Wed, 19 Jan 2022 14:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=12uuow7778XV9In4fyeSWkSK2fcajo2YhG6nP2XCnuo=; b=oRANZytiUkULtkc/kZsihHeTif+N2gvEmOq8UngRG88HInYNQwEq1anyETDsabVgn3 XdhQ/vUgecyTaSgV/fV13AuIJhsDg7dyw5hyyh7Te2bUIcnnXj9XTqexpQzVTyNFRl6y qo0LcmEnufMdhqlCA7ftikQQE9kjX2Zt7fs+Giu6kAexZw/JoNs7LpmnlGZMJtKRVWxf vMzwEW1gWTA1Wvxumf5I047QIPMzNegBPi39NfQMwLZUY3iHkha9WXfQ6+agYDpu8Lkx jCXwsAlPD5+FGOFLfcp7bky/pY2KcrmpfZuzm6Yqei0YRBEou+dyoZ81L45kubXYCRxX wTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=12uuow7778XV9In4fyeSWkSK2fcajo2YhG6nP2XCnuo=; b=2lQK//8j3k2CdycUJIEwy+xm2OwlJWZdgNeADom6x9gmkHjwa/rx6kyWnbnH64oMm2 9kimNJs3E7RKdLxGFlLQii7xsvBEW/aOdPPZH9pxgFzCjpBXGaXcYOXMKQ/yix/pUzTF ujynvZi3Y3xlltRwpLscZM9nGVGMOVX4nfUrI9oe+yMLdFOInq5OZ9WO/dLLYKlRXGvS y7jgEfQG4FmaCnjilXN35/YXfoERgEpYqM8JW9PSXHAj5rNNmwakdBmfWSrKgE8z6YRe ZO+HoBME56BsWXyZzYE5Fu0Gs/ZxeQLYiRpjcqi57fUqS9EL33wAkLBr7jUVeC0geeLk Phuw== X-Gm-Message-State: AOAM531TiSThTrROfrRjq4XF3TAPr3qVQoGS9qIctqr6dLHgYjwQ/9nq m+pYS0zGNFUDo7QwQmU7Aiarnw== X-Received: by 2002:a05:651c:1a29:: with SMTP id by41mr16859847ljb.151.1642630578692; Wed, 19 Jan 2022 14:16:18 -0800 (PST) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b11sm89053lfb.277.2022.01.19.14.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 14:16:18 -0800 (PST) From: Dmitry Baryshkov To: Bjorn Andersson , Rob Clark , Sean Paul , Abhinav Kumar Subject: [PATCH v3 1/3] drm/msm: move utility functions from msm_drv.c Date: Thu, 20 Jan 2022 01:16:14 +0300 Message-Id: <20220119221616.3089119-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220119221616.3089119-1-dmitry.baryshkov@linaro.org> References: <20220119221616.3089119-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, Stephen Boyd , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move clock/IO/hrtimer utility functions from msm_drv.c to new msm_io_utils.c file. Signed-off-by: Dmitry Baryshkov Reviewed-by: Jessica Zhang --- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/msm_drv.c | 118 --------------------------- drivers/gpu/drm/msm/msm_io_utils.c | 126 +++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 118 deletions(-) create mode 100644 drivers/gpu/drm/msm/msm_io_utils.c diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index 03ab55c37beb..5b6e37477079 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -87,6 +87,7 @@ msm-y := \ msm_gem_vma.o \ msm_gpu.o \ msm_gpu_devfreq.o \ + msm_io_utils.o \ msm_iommu.o \ msm_perf.o \ msm_rd.o \ diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index fd62a4da14a1..30c44c395a24 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -75,124 +75,6 @@ static bool modeset = true; MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disable)"); module_param(modeset, bool, 0600); -/* - * Util/helpers: - */ - -struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count, - const char *name) -{ - int i; - char n[32]; - - snprintf(n, sizeof(n), "%s_clk", name); - - for (i = 0; bulk && i < count; i++) { - if (!strcmp(bulk[i].id, name) || !strcmp(bulk[i].id, n)) - return bulk[i].clk; - } - - - return NULL; -} - -struct clk *msm_clk_get(struct platform_device *pdev, const char *name) -{ - struct clk *clk; - char name2[32]; - - clk = devm_clk_get(&pdev->dev, name); - if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER) - return clk; - - snprintf(name2, sizeof(name2), "%s_clk", name); - - clk = devm_clk_get(&pdev->dev, name2); - if (!IS_ERR(clk)) - dev_warn(&pdev->dev, "Using legacy clk name binding. Use " - "\"%s\" instead of \"%s\"\n", name, name2); - - return clk; -} - -static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *name, - bool quiet, phys_addr_t *psize) -{ - struct resource *res; - unsigned long size; - void __iomem *ptr; - - if (name) - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); - else - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - - if (!res) { - if (!quiet) - DRM_DEV_ERROR(&pdev->dev, "failed to get memory resource: %s\n", name); - return ERR_PTR(-EINVAL); - } - - size = resource_size(res); - - ptr = devm_ioremap(&pdev->dev, res->start, size); - if (!ptr) { - if (!quiet) - DRM_DEV_ERROR(&pdev->dev, "failed to ioremap: %s\n", name); - return ERR_PTR(-ENOMEM); - } - - if (psize) - *psize = size; - - return ptr; -} - -void __iomem *msm_ioremap(struct platform_device *pdev, const char *name) -{ - return _msm_ioremap(pdev, name, false, NULL); -} - -void __iomem *msm_ioremap_quiet(struct platform_device *pdev, const char *name) -{ - return _msm_ioremap(pdev, name, true, NULL); -} - -void __iomem *msm_ioremap_size(struct platform_device *pdev, const char *name, - phys_addr_t *psize) -{ - return _msm_ioremap(pdev, name, false, psize); -} - -static enum hrtimer_restart msm_hrtimer_worktimer(struct hrtimer *t) -{ - struct msm_hrtimer_work *work = container_of(t, - struct msm_hrtimer_work, timer); - - kthread_queue_work(work->worker, &work->work); - - return HRTIMER_NORESTART; -} - -void msm_hrtimer_queue_work(struct msm_hrtimer_work *work, - ktime_t wakeup_time, - enum hrtimer_mode mode) -{ - hrtimer_start(&work->timer, wakeup_time, mode); -} - -void msm_hrtimer_work_init(struct msm_hrtimer_work *work, - struct kthread_worker *worker, - kthread_work_func_t fn, - clockid_t clock_id, - enum hrtimer_mode mode) -{ - hrtimer_init(&work->timer, clock_id, mode); - work->timer.function = msm_hrtimer_worktimer; - work->worker = worker; - kthread_init_work(&work->work, fn); -} - static irqreturn_t msm_irq(int irq, void *arg) { struct drm_device *dev = arg; diff --git a/drivers/gpu/drm/msm/msm_io_utils.c b/drivers/gpu/drm/msm/msm_io_utils.c new file mode 100644 index 000000000000..7b504617833a --- /dev/null +++ b/drivers/gpu/drm/msm/msm_io_utils.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2016-2018, 2020-2021 The Linux Foundation. All rights reserved. + * Copyright (C) 2013 Red Hat + * Author: Rob Clark + */ + +#include "msm_drv.h" + +/* + * Util/helpers: + */ + +struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count, + const char *name) +{ + int i; + char n[32]; + + snprintf(n, sizeof(n), "%s_clk", name); + + for (i = 0; bulk && i < count; i++) { + if (!strcmp(bulk[i].id, name) || !strcmp(bulk[i].id, n)) + return bulk[i].clk; + } + + + return NULL; +} + +struct clk *msm_clk_get(struct platform_device *pdev, const char *name) +{ + struct clk *clk; + char name2[32]; + + clk = devm_clk_get(&pdev->dev, name); + if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER) + return clk; + + snprintf(name2, sizeof(name2), "%s_clk", name); + + clk = devm_clk_get(&pdev->dev, name2); + if (!IS_ERR(clk)) + dev_warn(&pdev->dev, "Using legacy clk name binding. Use " + "\"%s\" instead of \"%s\"\n", name, name2); + + return clk; +} + +static void __iomem *_msm_ioremap(struct platform_device *pdev, const char *name, + bool quiet, phys_addr_t *psize) +{ + struct resource *res; + unsigned long size; + void __iomem *ptr; + + if (name) + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); + else + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + if (!res) { + if (!quiet) + DRM_DEV_ERROR(&pdev->dev, "failed to get memory resource: %s\n", name); + return ERR_PTR(-EINVAL); + } + + size = resource_size(res); + + ptr = devm_ioremap(&pdev->dev, res->start, size); + if (!ptr) { + if (!quiet) + DRM_DEV_ERROR(&pdev->dev, "failed to ioremap: %s\n", name); + return ERR_PTR(-ENOMEM); + } + + if (psize) + *psize = size; + + return ptr; +} + +void __iomem *msm_ioremap(struct platform_device *pdev, const char *name) +{ + return _msm_ioremap(pdev, name, false, NULL); +} + +void __iomem *msm_ioremap_quiet(struct platform_device *pdev, const char *name) +{ + return _msm_ioremap(pdev, name, true, NULL); +} + +void __iomem *msm_ioremap_size(struct platform_device *pdev, const char *name, + phys_addr_t *psize) +{ + return _msm_ioremap(pdev, name, false, psize); +} + +static enum hrtimer_restart msm_hrtimer_worktimer(struct hrtimer *t) +{ + struct msm_hrtimer_work *work = container_of(t, + struct msm_hrtimer_work, timer); + + kthread_queue_work(work->worker, &work->work); + + return HRTIMER_NORESTART; +} + +void msm_hrtimer_queue_work(struct msm_hrtimer_work *work, + ktime_t wakeup_time, + enum hrtimer_mode mode) +{ + hrtimer_start(&work->timer, wakeup_time, mode); +} + +void msm_hrtimer_work_init(struct msm_hrtimer_work *work, + struct kthread_worker *worker, + kthread_work_func_t fn, + clockid_t clock_id, + enum hrtimer_mode mode) +{ + hrtimer_init(&work->timer, clock_id, mode); + work->timer.function = msm_hrtimer_worktimer; + work->worker = worker; + kthread_init_work(&work->work, fn); +}