From patchwork Mon Nov 12 19:42:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10679185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C2A514DB for ; Mon, 12 Nov 2018 19:44:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85C4C286DF for ; Mon, 12 Nov 2018 19:43:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D54286FD; Mon, 12 Nov 2018 19:43:59 +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.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,TVD_SUBJ_WIPE_DEBT 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 C3F1E286DF for ; Mon, 12 Nov 2018 19:43:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BBA526E219; Mon, 12 Nov 2018 19:43:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9524F6E1BE for ; Mon, 12 Nov 2018 19:43:56 +0000 (UTC) Received: by mail-yb1-xb44.google.com with SMTP id d18-v6so4399318yba.4 for ; Mon, 12 Nov 2018 11:43:56 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=kbKUhAKPqdooP/+Y/EuHxTnpXyviEte14FU/wyJykrQ=; b=P3SaKbTcdh5loaF8UhjtsrceFYkYlCYnoH3Owkub2wlN3Thyqc5z9lBbEy3Dv5hw2I dtwg1rBpr2YN4oyVulQ4dQllznD1GlqQXKVyRxvh+Kv86y28tHV1k8gR7/H/3WSCNYOG Lxt0mrki/h2MNsMk0mt5AFJXxdD1JWD5H0+SLYhfR6cTc9o8geUePNR/kGezQ7iOPPq2 sUnqmmPWbTxqIH4H9X1zqq13o8wnf+ZW7ncpn7q5Z/0VctIAZtsY9DviwXdl+VgkZ9Ng BrITkPSGcuh0Zlj+NptvQqfaEksA8s0CXgZlcE0psOjfNXYoK59/ejXLNf8ImfN1Xbzi 7FDw== X-Gm-Message-State: AGRZ1gIAvs44XJmZnEzuXEGl9AJuzjkR2xBu++gaugxzThIVpJkcw/zL rK4CtviSuZ3I6+KgK57iAHwAvJcg4rB+gg== X-Google-Smtp-Source: AJdET5eX71Sw+Nj37MqS5IGgdYhqvD3eaAWHEn+42lEDIQyPyZq5NHp/LK6Zc1I8xltUxKpvNayLZw== X-Received: by 2002:a25:f43:: with SMTP id 64-v6mr2297534ybp.355.1542051835458; Mon, 12 Nov 2018 11:43:55 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id 123-v6sm4586331ywx.15.2018.11.12.11.43.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 11:43:55 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 03/12] drm/msm: dpu: Remove dpu_power_client Date: Mon, 12 Nov 2018 14:42:07 -0500 Message-Id: <20181112194222.193546-4-sean@poorly.run> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181112194222.193546-1-sean@poorly.run> References: <20181112194222.193546-1-sean@poorly.run> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sean Paul , Abhinav Kumar Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul There's only one client -- core, and it's only used for runtime pm which is already refcounted. Signed-off-by: Sean Paul Reviewed-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 22 +---- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 - .../gpu/drm/msm/disp/dpu1/dpu_power_handle.c | 96 +------------------ .../gpu/drm/msm/disp/dpu1/dpu_power_handle.h | 86 +---------------- 4 files changed, 6 insertions(+), 199 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 985c855796ae..23094d108e81 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -676,11 +676,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms) dpu_hw_catalog_deinit(dpu_kms->catalog); dpu_kms->catalog = NULL; - if (dpu_kms->core_client) - dpu_power_client_destroy(&dpu_kms->phandle, - dpu_kms->core_client); - dpu_kms->core_client = NULL; - if (dpu_kms->vbif[VBIF_NRT]) devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_NRT]); dpu_kms->vbif[VBIF_NRT] = NULL; @@ -913,17 +908,6 @@ static int dpu_kms_hw_init(struct msm_kms *kms) dpu_kms->reg_dma_len = dpu_iomap_size(dpu_kms->pdev, "regdma"); } - dpu_kms->core_client = dpu_power_client_create(&dpu_kms->phandle, - "core"); - if (IS_ERR_OR_NULL(dpu_kms->core_client)) { - rc = PTR_ERR(dpu_kms->core_client); - if (!dpu_kms->core_client) - rc = -EINVAL; - DPU_ERROR("dpu power client create failed: %d\n", rc); - dpu_kms->core_client = NULL; - goto error; - } - pm_runtime_get_sync(&dpu_kms->pdev->dev); _dpu_kms_core_hw_rev_init(dpu_kms); @@ -1157,8 +1141,7 @@ static int __maybe_unused dpu_runtime_suspend(struct device *dev) return rc; } - rc = dpu_power_resource_enable(&dpu_kms->phandle, - dpu_kms->core_client, false); + rc = dpu_power_resource_enable(&dpu_kms->phandle, false); if (rc) DPU_ERROR("resource disable failed: %d\n", rc); @@ -1189,8 +1172,7 @@ static int __maybe_unused dpu_runtime_resume(struct device *dev) return rc; } - rc = dpu_power_resource_enable(&dpu_kms->phandle, - dpu_kms->core_client, true); + rc = dpu_power_resource_enable(&dpu_kms->phandle, true); if (rc) DPU_ERROR("resource enable failed: %d\n", rc); diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h index 2a3625eef6d3..f2c78deb0854 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h @@ -114,7 +114,6 @@ struct dpu_kms { struct dpu_mdss_cfg *catalog; struct dpu_power_handle phandle; - struct dpu_power_client *core_client; struct dpu_power_event *power_event; /* directory entry for debugfs */ diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.c index 8c6f92aaaf87..8e64f0a52147 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.c @@ -35,59 +35,11 @@ static void dpu_power_event_trigger_locked(struct dpu_power_handle *phandle, } } -struct dpu_power_client *dpu_power_client_create( - struct dpu_power_handle *phandle, char *client_name) -{ - struct dpu_power_client *client; - static u32 id; - - if (!client_name || !phandle) { - pr_err("client name is null or invalid power data\n"); - return ERR_PTR(-EINVAL); - } - - client = kzalloc(sizeof(struct dpu_power_client), GFP_KERNEL); - if (!client) - return ERR_PTR(-ENOMEM); - - mutex_lock(&phandle->phandle_lock); - strlcpy(client->name, client_name, MAX_CLIENT_NAME_LEN); - client->usecase_ndx = VOTE_INDEX_DISABLE; - client->id = id; - client->active = true; - pr_debug("client %s created:%pK id :%d\n", client_name, - client, id); - id++; - list_add(&client->list, &phandle->power_client_clist); - mutex_unlock(&phandle->phandle_lock); - - return client; -} - -void dpu_power_client_destroy(struct dpu_power_handle *phandle, - struct dpu_power_client *client) -{ - if (!client || !phandle) { - pr_err("reg bus vote: invalid client handle\n"); - } else if (!client->active) { - pr_err("dpu power deinit already done\n"); - kfree(client); - } else { - pr_debug("bus vote client %s destroyed:%pK id:%u\n", - client->name, client, client->id); - mutex_lock(&phandle->phandle_lock); - list_del_init(&client->list); - mutex_unlock(&phandle->phandle_lock); - kfree(client); - } -} - void dpu_power_resource_init(struct platform_device *pdev, struct dpu_power_handle *phandle) { phandle->dev = &pdev->dev; - INIT_LIST_HEAD(&phandle->power_client_clist); INIT_LIST_HEAD(&phandle->event_list); mutex_init(&phandle->phandle_lock); @@ -96,7 +48,6 @@ void dpu_power_resource_init(struct platform_device *pdev, void dpu_power_resource_deinit(struct platform_device *pdev, struct dpu_power_handle *phandle) { - struct dpu_power_client *curr_client, *next_client; struct dpu_power_event *curr_event, *next_event; if (!phandle || !pdev) { @@ -105,15 +56,6 @@ void dpu_power_resource_deinit(struct platform_device *pdev, } mutex_lock(&phandle->phandle_lock); - list_for_each_entry_safe(curr_client, next_client, - &phandle->power_client_clist, list) { - pr_err("client:%s-%d still registered with refcount:%d\n", - curr_client->name, curr_client->id, - curr_client->refcount); - curr_client->active = false; - list_del(&curr_client->list); - } - list_for_each_entry_safe(curr_event, next_event, &phandle->event_list, list) { pr_err("event:%d, client:%s still registered\n", @@ -125,53 +67,21 @@ void dpu_power_resource_deinit(struct platform_device *pdev, mutex_unlock(&phandle->phandle_lock); } -int dpu_power_resource_enable(struct dpu_power_handle *phandle, - struct dpu_power_client *pclient, bool enable) +int dpu_power_resource_enable(struct dpu_power_handle *phandle, bool enable) { - bool changed = false; - u32 max_usecase_ndx = VOTE_INDEX_DISABLE, prev_usecase_ndx; - struct dpu_power_client *client; u32 event_type; - if (!phandle || !pclient) { + if (!phandle) { pr_err("invalid input argument\n"); return -EINVAL; } mutex_lock(&phandle->phandle_lock); - if (enable) - pclient->refcount++; - else if (pclient->refcount) - pclient->refcount--; - - if (pclient->refcount) - pclient->usecase_ndx = VOTE_INDEX_LOW; - else - pclient->usecase_ndx = VOTE_INDEX_DISABLE; - - list_for_each_entry(client, &phandle->power_client_clist, list) { - if (client->usecase_ndx < VOTE_INDEX_MAX && - client->usecase_ndx > max_usecase_ndx) - max_usecase_ndx = client->usecase_ndx; - } - - if (phandle->current_usecase_ndx != max_usecase_ndx) { - changed = true; - prev_usecase_ndx = phandle->current_usecase_ndx; - phandle->current_usecase_ndx = max_usecase_ndx; - } - - pr_debug("%pS: changed=%d current idx=%d request client %s id:%u enable:%d refcount:%d\n", - __builtin_return_address(0), changed, max_usecase_ndx, - pclient->name, pclient->id, enable, pclient->refcount); - - if (!changed) - goto end; event_type = enable ? DPU_POWER_EVENT_ENABLE : DPU_POWER_EVENT_DISABLE; dpu_power_event_trigger_locked(phandle, event_type); -end: + mutex_unlock(&phandle->phandle_lock); return 0; } diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.h index f627ae28ec68..124ebc93c877 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_power_handle.h @@ -27,30 +27,6 @@ #define DPU_POWER_EVENT_DISABLE BIT(0) #define DPU_POWER_EVENT_ENABLE BIT(1) -/** - * mdss_bus_vote_type: register bus vote type - * VOTE_INDEX_DISABLE: removes the client vote - * VOTE_INDEX_LOW: keeps the lowest vote for register bus - * VOTE_INDEX_MAX: invalid - */ -enum mdss_bus_vote_type { - VOTE_INDEX_DISABLE, - VOTE_INDEX_LOW, - VOTE_INDEX_MAX, -}; - -/** - * enum dpu_power_handle_data_bus_client - type of axi bus clients - * @DPU_POWER_HANDLE_DATA_BUS_CLIENT_RT: core real-time bus client - * @DPU_POWER_HANDLE_DATA_BUS_CLIENT_NRT: core non-real-time bus client - * @DPU_POWER_HANDLE_DATA_BUS_CLIENT_MAX: maximum number of bus client type - */ -enum dpu_power_handle_data_bus_client { - DPU_POWER_HANDLE_DATA_BUS_CLIENT_RT, - DPU_POWER_HANDLE_DATA_BUS_CLIENT_NRT, - DPU_POWER_HANDLE_DATA_BUS_CLIENT_MAX -}; - /** * enum DPU_POWER_HANDLE_DBUS_ID - data bus identifier * @DPU_POWER_HANDLE_DBUS_ID_MNOC: DPU/MNOC data bus @@ -64,31 +40,6 @@ enum DPU_POWER_HANDLE_DBUS_ID { DPU_POWER_HANDLE_DBUS_ID_MAX, }; -/** - * struct dpu_power_client: stores the power client for dpu driver - * @name: name of the client - * @usecase_ndx: current regs bus vote type - * @refcount: current refcount if multiple modules are using same - * same client for enable/disable. Power module will - * aggregate the refcount and vote accordingly for this - * client. - * @id: assigned during create. helps for debugging. - * @list: list to attach power handle master list - * @ab: arbitrated bandwidth for each bus client - * @ib: instantaneous bandwidth for each bus client - * @active: inidcates the state of dpu power handle - */ -struct dpu_power_client { - char name[MAX_CLIENT_NAME_LEN]; - short usecase_ndx; - short refcount; - u32 id; - struct list_head list; - u64 ab[DPU_POWER_HANDLE_DATA_BUS_CLIENT_MAX]; - u64 ib[DPU_POWER_HANDLE_DATA_BUS_CLIENT_MAX]; - bool active; -}; - /* * struct dpu_power_event - local event registration structure * @client_name: name of the client registering @@ -109,14 +60,12 @@ struct dpu_power_event { /** * struct dpu_power_handle: power handle main struct - * @client_clist: master list to store all clients * @phandle_lock: lock to synchronize the enable/disable * @dev: pointer to device structure * @usecase_ndx: current usecase index * @event_list: current power handle event list */ struct dpu_power_handle { - struct list_head power_client_clist; struct mutex phandle_lock; struct device *dev; u32 current_usecase_ndx; @@ -141,47 +90,14 @@ void dpu_power_resource_init(struct platform_device *pdev, void dpu_power_resource_deinit(struct platform_device *pdev, struct dpu_power_handle *pdata); -/** - * dpu_power_client_create() - create the client on power handle - * @pdata: power handle containing the resources - * @client_name: new client name for registration - * - * Return: error code. - */ -struct dpu_power_client *dpu_power_client_create(struct dpu_power_handle *pdata, - char *client_name); - -/** - * dpu_power_client_destroy() - destroy the client on power handle - * @pdata: power handle containing the resources - * @client_name: new client name for registration - * - * Return: none - */ -void dpu_power_client_destroy(struct dpu_power_handle *phandle, - struct dpu_power_client *client); - /** * dpu_power_resource_enable() - enable/disable the power resources * @pdata: power handle containing the resources - * @client: client information to enable/disable its vote * @enable: boolean request for enable/disable * * Return: error code. */ -int dpu_power_resource_enable(struct dpu_power_handle *pdata, - struct dpu_power_client *pclient, bool enable); - -/** - * dpu_power_data_bus_bandwidth_ctrl() - control data bus bandwidth enable - * @phandle: power handle containing the resources - * @client: client information to bandwidth control - * @enable: true to enable bandwidth for data base - * - * Return: none - */ -void dpu_power_data_bus_bandwidth_ctrl(struct dpu_power_handle *phandle, - struct dpu_power_client *pclient, int enable); +int dpu_power_resource_enable(struct dpu_power_handle *pdata, bool enable); /** * dpu_power_handle_register_event - register a callback function for an event.