Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4673697pxj; Wed, 12 May 2021 10:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7R+1uyHK2Ie8lIfPsVtrWulrqQbqy9erps0N7B87kW5HWXc3Y1nmQcQHaePicKUnHCrhc X-Received: by 2002:aa7:cd46:: with SMTP id v6mr43581857edw.16.1620840814034; Wed, 12 May 2021 10:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620840814; cv=none; d=google.com; s=arc-20160816; b=TYywQtPjTtIfu4rgvpNPdolkFjNrAw1WtAW7X0MN5r5y8EKyqkdNnlcEYAY1CcXVWV ujKLZkDpFmilTyhIHCe4O/L9mrpmC0B1GDHMInRTQbZviwIIK9HXaZEB0qBK8vacVH4W UXTzbTBhOrkPtwLQ+Fj7yB6C6TnLHgV0LXOqCW8Kb0OUnGc4pKBnoqPQkYTwV4g0r2EB j/cxsXfH8R07gK2NzIUqY7Fz5M8peGnTuSAkTajtYfO9wycFe3u/n76+C0mGl4wGh7x3 iC5SXbZoS62IMdmOGg0vAq70/77n8iu+nVhWnilumZTdEO3qaOL4r24fZ7XjuETUpmnb sudg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yESb6nwBJQYGhJJluK3XaTK2CZlns6cl7zyyeXD1SV4=; b=Fw6G9o7dLErQ9Hfucamepr6vaCylTXZSDzcs/l9aa8+ZGnqB6sCn92az2oh/UNIZJy 3byFh4NExTFvB6sOhQEMvlOZ7ydThnsQvqho1+1GCNLnFOpDBuhQRxE7s14jQIER/kYl iRCmwUb7xuOCfB/SmusS+bpYSelJsJTHZOagQw7OyRn2JGmAx2mIEkzjjSR2J6QPK9UL gVIcn5HjKo+dOseog98jedx/uEgH8vdxQFD6Uuy73i7MaXBbBdrArG/LXgHzHKgjUGhH GLRdesub/OR3QgTZ02MXdKJETd+o1yT8GKeR0iPo805csbIvXO0qMaogMpGFmcV+cV8R Kr1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1HZ/bxrz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r10si619758ejy.100.2021.05.12.10.33.10; Wed, 12 May 2021 10:33:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1HZ/bxrz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347675AbhELR3T (ORCPT + 99 others); Wed, 12 May 2021 13:29:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:33672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239393AbhELQH6 (ORCPT ); Wed, 12 May 2021 12:07:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DFDA61C5F; Wed, 12 May 2021 15:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833873; bh=3fP+vBQIPJ60+SOvxG67l1Ouj6EAL//zbQx0rbQpVEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HZ/bxrzB0xSu5Cxul3U9poKQR/Gn+KbZs2sDpSKmDKNIFopGjMuD23DqjbiSoZK+ kJMFBOzEEiKYkcZoDHSFIV9clVtUb0ofT56zVG76hX+eJSgIFjB23JB5pDiKK2dILH tmw00S0CdbLrLLgXmOJoP/aMvqFYjcb7buPln1gU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jae Hyun Yoo , Joel Stanley , Eddie James , Stephen Boyd , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.11 321/601] media: aspeed: fix clock handling logic Date: Wed, 12 May 2021 16:46:38 +0200 Message-Id: <20210512144838.383478067@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jae Hyun Yoo [ Upstream commit 3536169f8531c2c5b153921dc7d1ac9fd570cda7 ] Video engine uses eclk and vclk for its clock sources and its reset control is coupled with eclk so the current clock enabling sequence works like below. Enable eclk De-assert Video Engine reset 10ms delay Enable vclk It introduces improper reset on the Video Engine hardware and eventually the hardware generates unexpected DMA memory transfers that can corrupt memory region in random and sporadic patterns. This issue is observed very rarely on some specific AST2500 SoCs but it causes a critical kernel panic with making a various shape of signature so it's extremely hard to debug. Moreover, the issue is observed even when the video engine is not actively used because udevd turns on the video engine hardware for a short time to make a query in every boot. To fix this issue, this commit changes the clock handling logic to make the reset de-assertion triggered after enabling both eclk and vclk. Also, it adds clk_unprepare call for a case when probe fails. clk: ast2600: fix reset settings for eclk and vclk Video engine reset setting should be coupled with eclk to match it with the setting for previous Aspeed SoCs which is defined in clk-aspeed.c since all Aspeed SoCs are sharing a single video engine driver. Also, reset bit 6 is defined as 'Video Engine' reset in datasheet so it should be de-asserted when eclk is enabled. This commit fixes the setting. Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver") Signed-off-by: Jae Hyun Yoo Reviewed-by: Joel Stanley Reviewed-by: Eddie James Fixes: d3d04f6c330a ("clk: Add support for AST2600 SoC") Reviewed-by: Joel Stanley Acked-by: Stephen Boyd Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/clk/clk-ast2600.c | 4 ++-- drivers/media/platform/aspeed-video.c | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c index a55b37fc2c8b..bc3be5f3eae1 100644 --- a/drivers/clk/clk-ast2600.c +++ b/drivers/clk/clk-ast2600.c @@ -61,10 +61,10 @@ static void __iomem *scu_g6_base; static const struct aspeed_gate_data aspeed_g6_gates[] = { /* clk rst name parent flags */ [ASPEED_CLK_GATE_MCLK] = { 0, -1, "mclk-gate", "mpll", CLK_IS_CRITICAL }, /* SDRAM */ - [ASPEED_CLK_GATE_ECLK] = { 1, -1, "eclk-gate", "eclk", 0 }, /* Video Engine */ + [ASPEED_CLK_GATE_ECLK] = { 1, 6, "eclk-gate", "eclk", 0 }, /* Video Engine */ [ASPEED_CLK_GATE_GCLK] = { 2, 7, "gclk-gate", NULL, 0 }, /* 2D engine */ /* vclk parent - dclk/d1clk/hclk/mclk */ - [ASPEED_CLK_GATE_VCLK] = { 3, 6, "vclk-gate", NULL, 0 }, /* Video Capture */ + [ASPEED_CLK_GATE_VCLK] = { 3, -1, "vclk-gate", NULL, 0 }, /* Video Capture */ [ASPEED_CLK_GATE_BCLK] = { 4, 8, "bclk-gate", "bclk", 0 }, /* PCIe/PCI */ /* From dpll */ [ASPEED_CLK_GATE_DCLK] = { 5, -1, "dclk-gate", NULL, CLK_IS_CRITICAL }, /* DAC */ diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index f2c4dadd6a0e..7bb6babdcade 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -514,8 +514,8 @@ static void aspeed_video_off(struct aspeed_video *video) aspeed_video_write(video, VE_INTERRUPT_STATUS, 0xffffffff); /* Turn off the relevant clocks */ - clk_disable(video->vclk); clk_disable(video->eclk); + clk_disable(video->vclk); clear_bit(VIDEO_CLOCKS_ON, &video->flags); } @@ -526,8 +526,8 @@ static void aspeed_video_on(struct aspeed_video *video) return; /* Turn on the relevant clocks */ - clk_enable(video->eclk); clk_enable(video->vclk); + clk_enable(video->eclk); set_bit(VIDEO_CLOCKS_ON, &video->flags); } @@ -1719,8 +1719,11 @@ static int aspeed_video_probe(struct platform_device *pdev) return rc; rc = aspeed_video_setup_video(video); - if (rc) + if (rc) { + clk_unprepare(video->vclk); + clk_unprepare(video->eclk); return rc; + } return 0; } -- 2.30.2