From patchwork Mon Jun 18 13:32:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sravanthi Kollukuduru X-Patchwork-Id: 10471471 X-Patchwork-Delegate: agross@codeaurora.org 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 DC4E56053C for ; Mon, 18 Jun 2018 13:34:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA74F289E4 for ; Mon, 18 Jun 2018 13:34:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF69D289ED; Mon, 18 Jun 2018 13:34: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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45B1F289E4 for ; Mon, 18 Jun 2018 13:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934285AbeFRNeR (ORCPT ); Mon, 18 Jun 2018 09:34:17 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:40604 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933557AbeFRNeR (ORCPT ); Mon, 18 Jun 2018 09:34:17 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A349860227; Mon, 18 Jun 2018 13:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529328856; bh=4U/yspJAj4Gd+9LPqDCdb1lSoOrhCrTw+5Kw5yqcaW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OnF9NCQftxw3hFsCe1usq21Q8e14mbNpUM6U8+hEk8rbRxqC47xjHo4xv19VHWCIh zX/QGhV0uXnu543w5oGsrCVQWdK9w4AGQmQeiFTTuYYbMls1TKTlNOJOTs0iTyfPP9 0M5jCH3CK41kHcGa3Bq9zVCz2XWWd/SXPlsvFOpM= Received: from skolluku-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: skolluku@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3A5E960B13; Mon, 18 Jun 2018 13:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529328855; bh=4U/yspJAj4Gd+9LPqDCdb1lSoOrhCrTw+5Kw5yqcaW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Di1N0N+ZNlQV1F4AJAtrzw0Jde/qVHei7ED7PYYeiDGPv1469ZveaKrXmLKiIlwD9 LlJLdrnaBT6Am8hsqbcgye4Ra2mHB2LdPnmyeGn4xzOu5x6NY/AjPEaUHmsSWoXkDP KVI98gFuMF5WgphR+OeigacHaUwvz+96TWRFetl4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3A5E960B13 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=skolluku@codeaurora.org From: Sravanthi Kollukuduru To: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org Cc: Jeykumar Sankaran , robdclark@gmail.com, seanpaul@chromium.org, hoegsberg@chromium.org, Sravanthi Kollukuduru Subject: [DPU PATCH v2 13/14] drm/msm/dpu: add atomic private object to dpu kms Date: Mon, 18 Jun 2018 19:02:51 +0530 Message-Id: <1529328772-5022-14-git-send-email-skolluku@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1529328772-5022-1-git-send-email-skolluku@codeaurora.org> References: <1529328772-5022-1-git-send-email-skolluku@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeykumar Sankaran Subclass drm private state for DPU for handling driver specific data. Adds atomic private object and private object lock to dpu kms. Provides helper function to retrieve DPU private data from current atomic state. changes in v2: - fix return value while retrieving dpu priv state (Jordan) - avoid error on kzalloc failure(Jordan) Signed-off-by: Jeykumar Sankaran Signed-off-by: Sravanthi Kollukuduru --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 65 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 15 ++++++++ 2 files changed, 80 insertions(+) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index fe614c0..b3eaf3f 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -1076,6 +1076,10 @@ static void dpu_kms_destroy(struct msm_kms *kms) dpu_kms = to_dpu_kms(kms); _dpu_kms_hw_destroy(dpu_kms); + + drm_atomic_private_obj_fini(&dpu_kms->priv_obj); + drm_modeset_lock_fini(&dpu_kms->priv_obj_lock); + } static void dpu_kms_preclose(struct msm_kms *kms, struct drm_file *file) @@ -1618,10 +1622,59 @@ static int dpu_kms_hw_init(struct msm_kms *kms) return rc; } +struct dpu_private_state *dpu_get_private_state(struct drm_atomic_state *state) +{ + struct msm_drm_private *priv = state->dev->dev_private; + struct dpu_kms *dpu_kms = to_dpu_kms(priv->kms); + struct drm_private_state *priv_state; + int rc = 0; + + rc = drm_modeset_lock(&dpu_kms->priv_obj_lock, state->acquire_ctx); + if (rc) + return ERR_PTR(rc); + + priv_state = drm_atomic_get_private_obj_state(state, + &dpu_kms->priv_obj); + if (IS_ERR(priv_state)) + return ERR_PTR(-ENOMEM); + + return to_dpu_private_state(priv_state); +} + +static struct drm_private_state * +dpu_private_obj_duplicate_state(struct drm_private_obj *obj) +{ + struct dpu_private_state *dpu_priv_state; + + dpu_priv_state = kmemdup(obj->state, + sizeof(*dpu_priv_state), GFP_KERNEL); + if (!dpu_priv_state) + return NULL; + + __drm_atomic_helper_private_obj_duplicate_state(obj, + &dpu_priv_state->base); + + return &dpu_priv_state->base; +} + +static void dpu_private_obj_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + struct dpu_private_state *dpu_priv_state = to_dpu_private_state(state); + + kfree(dpu_priv_state); +} + +static const struct drm_private_state_funcs priv_obj_funcs = { + .atomic_duplicate_state = dpu_private_obj_duplicate_state, + .atomic_destroy_state = dpu_private_obj_destroy_state, +}; + struct msm_kms *dpu_kms_init(struct drm_device *dev) { struct msm_drm_private *priv; struct dpu_kms *dpu_kms; + struct dpu_private_state *dpu_priv_state; int irq; if (!dev || !dev->dev_private) { @@ -1639,6 +1692,18 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev) } dpu_kms->base.irq = irq; + /* Initialize private obj's */ + drm_modeset_lock_init(&dpu_kms->priv_obj_lock); + + dpu_priv_state = kzalloc(sizeof(*dpu_priv_state), GFP_KERNEL); + if (!dpu_priv_state) + return ERR_PTR(-ENOMEM); + + + drm_atomic_private_obj_init(&dpu_kms->priv_obj, + &dpu_priv_state->base, + &priv_obj_funcs); + return &dpu_kms->base; } diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h index 046e6f7..924d8967 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h @@ -190,6 +190,9 @@ struct dpu_kms { struct dpu_hw_vbif *hw_vbif[VBIF_MAX]; struct dpu_hw_mdp *hw_mdp; + struct drm_modeset_lock priv_obj_lock; + struct drm_private_obj priv_obj; + bool has_danger_ctrl; struct platform_device *pdev; @@ -197,12 +200,24 @@ struct dpu_kms { struct dss_module_power mp; }; +struct dpu_private_state { + struct drm_private_state base; +}; + struct vsync_info { u32 frame_count; u32 line_count; }; #define to_dpu_kms(x) container_of(x, struct dpu_kms, base) +#define to_dpu_private_state(x) container_of(x, struct dpu_private_state, base) + +/** + * dpu_get_private_state - get dpu private state from atomic state + * @state: drm atomic state + * Return: pointer to dpu private state object + */ +struct dpu_private_state *dpu_get_private_state(struct drm_atomic_state *state); /** * dpu_is_custom_client - whether or not to enable non-standard customizations