From patchwork Mon Jun 18 16:49:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 139035 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4171006lji; Mon, 18 Jun 2018 09:49:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIY7aOqINyZZsBMWaepK4ASR0cMZ12qkmgZeK8N8DCddDdn2z6RnQjgC/30sgftHa9ACG+k X-Received: by 2002:a62:9652:: with SMTP id c79-v6mr14472980pfe.114.1529340550940; Mon, 18 Jun 2018 09:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529340550; cv=none; d=google.com; s=arc-20160816; b=DEqorESjm2kzfKK0xGtbTT9TaSybLA9uzb2fgWnKVPiVWGXtmFxrm2jIKIPRZWzIe8 bz9Jg/+CDttWG1rl9542eGKvjhHZx6HpyO0QqMWHaznpqEJHDE1V0L6YXMUT88zpdpJt S0wsVws4qG2rBSKKweynx/jktHutGh+0s0FxXVMPXe3ZekoJIvMmiLDP2fi4KD78GY2i Q4I9xiSecRZJ8JsY59zaUpK3rQs5BJjmr5wMkSnAtsHZJSHj29xM+ArnLD0b2mwKI9Ix 8/AKLPScwWZtWFNByYfzdP7mvYR5+2qbsl/uAeNaP1ih85Lvpn/StBfg+XQ1IWbsseMW NJHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=0DXFIwUP4xk5PIBJ8tQytUcshoJ1xukS+g8s7Ud3oCE=; b=cjvpS7kXrzdbtEDy0RLynqh5J5+jAoOjFDjePByZDFLXpWTeMqcusozgfTgAvM98NE y8d5UeI62CBDkQx69QgkkQNTyBY+PrnjX+IGVPlokTWdaFd+PJa9mZD37xLLejCm9HI0 hA6XlS5B4AELCkhjpSkrxAM3gN12z9f5aVg+w9uNjhfVQqkZIwUxFPrARZ9WDSQpERKm O33w/taCzMktUtfazp4M1m44yhxAhGP3O0OUVB0Ze7ECfGqLxMWyx+RvQtCHnruLFFbg Y0Gfda6irXokJSmXVDlRuoS531gj6HWVjZBRHXSJkmigZicRtyhl/cze3d8M+a/sH0rF ieWA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id o1-v6si15183453plb.279.2018.06.18.09.49.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 09:49:10 -0700 (PDT) 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; 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 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F0D2C6E0C5; Mon, 18 Jun 2018 16:49:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04EDF6E0C5 for ; Mon, 18 Jun 2018 16:49:06 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.61]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w5IGn2Vg020899; Mon, 18 Jun 2018 17:49:02 +0100 From: Liviu Dudau To: Mali DP Maintainers Subject: [PATCH] drm/mali-dp: Improve writeback handling for DP500. Date: Mon, 18 Jun 2018 17:49:02 +0100 Message-Id: <20180618164902.10153-1-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.17.1 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: Alexandru-Cosmin Gheorghe , Liviu Dudau , LKML , DRI-devel , Ayan Halder MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Mali DP500 operates in continuous writeback mode (writes frame content until stopped) and it needs special handling in order to behave like a one-shot writeback engine. The original state machine added for DP500 was a bit fragile, as it did not handle correctly cases where a new atomic commit was in progress when the SE IRQ happens and it would commit some partial updates. Improve the handling by adding a parameter to the set_config_valid() function to clear the config valid bit in hardware before starting a new commit and by introducing a MW_RESTART state in the writeback state machine to cater for the case where a new writeback commit gets submitted while the last one is still being active. Reported-by: Brian Starkey Reviewed-by: Brian Starkey Signed-off-by: Liviu Dudau --- drivers/gpu/drm/arm/malidp_drv.c | 3 ++- drivers/gpu/drm/arm/malidp_hw.c | 39 +++++++++++++++++++++++--------- drivers/gpu/drm/arm/malidp_hw.h | 11 +++++---- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c index fc264554c5035..83e8f911f1579 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@ -171,7 +171,7 @@ static int malidp_set_and_wait_config_valid(struct drm_device *drm) struct malidp_hw_device *hwdev = malidp->dev; int ret; - hwdev->hw->set_config_valid(hwdev); + hwdev->hw->set_config_valid(hwdev, 1); /* don't wait for config_valid flag if we are in config mode */ if (hwdev->hw->in_config_mode(hwdev)) { atomic_set(&malidp->config_valid, MALIDP_CONFIG_VALID_DONE); @@ -230,6 +230,7 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state) * know that we are updating registers */ atomic_set(&malidp->config_valid, MALIDP_CONFIG_START); + malidp->dev->hw->set_config_valid(malidp->dev, 0); drm_atomic_helper_commit_modeset_disables(drm, state); diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c index e0de7a35a0beb..8759f90c313d9 100644 --- a/drivers/gpu/drm/arm/malidp_hw.c +++ b/drivers/gpu/drm/arm/malidp_hw.c @@ -27,7 +27,8 @@ enum { MW_NOT_ENABLED = 0, /* SE writeback not enabled */ MW_ONESHOT, /* SE in one-shot mode for writeback */ MW_START, /* SE started writeback */ - MW_STOP, /* SE finished writeback */ + MW_RESTART, /* SE will start another writeback after this one */ + MW_STOP, /* SE needs to stop after this writeback */ }; static const struct malidp_format_id malidp500_de_formats[] = { @@ -231,9 +232,12 @@ static bool malidp500_in_config_mode(struct malidp_hw_device *hwdev) return false; } -static void malidp500_set_config_valid(struct malidp_hw_device *hwdev) +static void malidp500_set_config_valid(struct malidp_hw_device *hwdev, u8 value) { - malidp_hw_setbits(hwdev, MALIDP_CFG_VALID, MALIDP500_CONFIG_VALID); + if (value) + malidp_hw_setbits(hwdev, MALIDP_CFG_VALID, MALIDP500_CONFIG_VALID); + else + malidp_hw_clearbits(hwdev, MALIDP_CFG_VALID, MALIDP500_CONFIG_VALID); } static void malidp500_modeset(struct malidp_hw_device *hwdev, struct videomode *mode) @@ -386,7 +390,11 @@ static int malidp500_enable_memwrite(struct malidp_hw_device *hwdev, /* enable the scaling engine block */ malidp_hw_setbits(hwdev, MALIDP_SCALE_ENGINE_EN, de_base + MALIDP_DE_DISPLAY_FUNC); - hwdev->mw_state = MW_START; + /* restart the writeback if already enabled */ + if (hwdev->mw_state != MW_NOT_ENABLED) + hwdev->mw_state = MW_RESTART; + else + hwdev->mw_state = MW_START; malidp_hw_write(hwdev, fmt_id, base + MALIDP_MW_FORMAT); switch (num_planes) { @@ -415,7 +423,7 @@ static void malidp500_disable_memwrite(struct malidp_hw_device *hwdev) { u32 base = malidp_get_block_base(hwdev, MALIDP_DE_BLOCK); - if (hwdev->mw_state == MW_START) + if (hwdev->mw_state == MW_START || hwdev->mw_state == MW_RESTART) hwdev->mw_state = MW_STOP; malidp_hw_clearbits(hwdev, MALIDP_SE_MEMWRITE_EN, MALIDP500_SE_CONTROL); malidp_hw_clearbits(hwdev, MALIDP_SCALE_ENGINE_EN, base + MALIDP_DE_DISPLAY_FUNC); @@ -500,9 +508,12 @@ static bool malidp550_in_config_mode(struct malidp_hw_device *hwdev) return false; } -static void malidp550_set_config_valid(struct malidp_hw_device *hwdev) +static void malidp550_set_config_valid(struct malidp_hw_device *hwdev, u8 value) { - malidp_hw_setbits(hwdev, MALIDP_CFG_VALID, MALIDP550_CONFIG_VALID); + if (value) + malidp_hw_setbits(hwdev, MALIDP_CFG_VALID, MALIDP550_CONFIG_VALID); + else + malidp_hw_clearbits(hwdev, MALIDP_CFG_VALID, MALIDP550_CONFIG_VALID); } static void malidp550_modeset(struct malidp_hw_device *hwdev, struct videomode *mode) @@ -1004,15 +1015,21 @@ static irqreturn_t malidp_se_irq(int irq, void *arg) /* disable writeback after stop */ hwdev->mw_state = MW_NOT_ENABLED; break; + case MW_RESTART: + drm_writeback_signal_completion(&malidp->mw_connector, 0); + /* fall through to a new start */ case MW_START: /* writeback started, need to emulate one-shot mode */ hw->disable_memwrite(hwdev); /* - * only set config_valid HW bit if there is no - * other update in progress + * only set config_valid HW bit if there is no other update + * in progress or if we raced ahead of the DE IRQ handler + * and config_valid flag will not be update until later */ - if (atomic_read(&malidp->config_valid) != MALIDP_CONFIG_START) - hw->set_config_valid(hwdev); + status = malidp_hw_read(hwdev, hw->map.dc_base + MALIDP_REG_STATUS); + if ((atomic_read(&malidp->config_valid) != MALIDP_CONFIG_START) || + (status & hw->map.dc_irq_map.vsync_irq)) + hw->set_config_valid(hwdev, 1); break; } } diff --git a/drivers/gpu/drm/arm/malidp_hw.h b/drivers/gpu/drm/arm/malidp_hw.h index c479738b81af5..bd41aa6974a06 100644 --- a/drivers/gpu/drm/arm/malidp_hw.h +++ b/drivers/gpu/drm/arm/malidp_hw.h @@ -152,12 +152,13 @@ struct malidp_hw { bool (*in_config_mode)(struct malidp_hw_device *hwdev); /* - * Set configuration valid flag for hardware parameters that can - * be changed outside the configuration mode. Hardware will use - * the new settings when config valid is set after the end of the - * current buffer scanout + * Set/clear configuration valid flag for hardware parameters that can + * be changed outside the configuration mode to the given value. + * Hardware will use the new settings when config valid is set, + * after the end of the current buffer scanout, and will ignore + * any new values for those parameters if config valid flag is cleared */ - void (*set_config_valid)(struct malidp_hw_device *hwdev); + void (*set_config_valid)(struct malidp_hw_device *hwdev, u8 value); /* * Set a new mode in hardware. Requires the hardware to be in