Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9123641pxu; Mon, 28 Dec 2020 07:12:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+URVj38QEC1mOMwgy4RNSC4Nm7kaw8dAbDaoykGaHbBpiJUwDBfqtvJPytaS0Eezm+UEK X-Received: by 2002:a17:906:73d8:: with SMTP id n24mr41380283ejl.14.1609168332001; Mon, 28 Dec 2020 07:12:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609168331; cv=none; d=google.com; s=arc-20160816; b=j3HlzLe6hxw7Enpye0aLwhbiF0+TljvJDYvY9hwPv38wLCj/e5w5Ro3Fv6sqDFwn6/ sxNg3X3aw629DSL5W3f9ZBTzveajCXX2aGyeYaU4WZG0lI+JO6d6nEhjEodwPoLw8ruM 3vIMEoV/Sj0WmsSCJv2szi2EUsh+8BZXNsP7B++wQ3183xRgMMJmf0w+j2PetgvlDFWM Wy6kKB1k0K6/1Arqs1Z1HCLx5zRtfEKhBnBuw4Tcdg40cgkGaSmWohZeh+SNQl72uNf7 uZ4YK7IHlFoPnKQMQj3ULRgKyMC0CZAP8HVEjHvHevEThAogFrp64IO4lyIEDFqOnr74 zP5g== 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=Lb5hec0AcBoFs0Q4MEk+tQWzWNQvuqc7N2hjqXjwa0E=; b=bDjJrgCXTCIbsNBkFN/D7XxCDBifxBSoqaSj4+DQJwChf4BpPpNA92Ock7TaXIBXWj Vi4UiZYZbOK6aj/gpsBZFryHDlLQYI01PTSoHW6S0+w2cNCkogBTTM1YbdkKn3vqxb15 Ckvr7qeT2sIKbXMQv+NtGwbgp8/HDvQrwiPWny6cXcSrIOojBmAps9DKfGgWORju4W6g KEQngM0Xgkcz/RY1algYTko+bvcG5hwj70vzJfodt66DIY+Ob7C9ELrGn/KXnibooWO9 MGc5/RAnbwxdY5SMDlXIkUfvSNREt06Hy1S3iEIOTt0uPc5rlJkR6hUx7sGninXMnuK5 scaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BlunDWrU; 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 hj13si18779965ejb.475.2020.12.28.07.11.47; Mon, 28 Dec 2020 07:12:11 -0800 (PST) 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=BlunDWrU; 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 S2440427AbgL1PJf (ORCPT + 99 others); Mon, 28 Dec 2020 10:09:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:42238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438515AbgL1OHo (ORCPT ); Mon, 28 Dec 2020 09:07:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AAD1E207B6; Mon, 28 Dec 2020 14:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164424; bh=3hOfFZ7oqQW1o/4GO2YXfX/2Tj0BUj8IVjRF20Rsr7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlunDWrUUpRn5smtVlptdCcUOAlMjJPAfyXNC/nstzmbRAF8iIchq2TbYF+4VS3BK vkxOeDO+9H3/GDA7JdzgYNwkmyIjdoe8+W8kR8u1+gNSdqnJGmZckmgV6afxgvvteM AHlU6e57hLurbpxkg7N3/gwvNH3y3ElVminrElow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Neil Armstrong , Sasha Levin Subject: [PATCH 5.10 174/717] drm/meson: dw-hdmi: Disable clocks on driver teardown Date: Mon, 28 Dec 2020 13:42:52 +0100 Message-Id: <20201228125029.298765527@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Marc Zyngier [ Upstream commit 1dfeea904550c11eccf3fd5f6256e4b0f0208dfe ] The HDMI driver request clocks early, but never disable them, leaving the clocks on even when the driver is removed. Fix it by slightly refactoring the clock code, and register a devm action that will eventually disable/unprepare the enabled clocks. Signed-off-by: Marc Zyngier Reviewed-by: Neil Armstrong Signed-off-by: Neil Armstrong Link: https://patchwork.freedesktop.org/patch/msgid/20201120094205.525228-2-maz@kernel.org Signed-off-by: Sasha Levin --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 43 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 7f8eea4941472..29623b309cb11 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -145,8 +145,6 @@ struct meson_dw_hdmi { struct reset_control *hdmitx_apb; struct reset_control *hdmitx_ctrl; struct reset_control *hdmitx_phy; - struct clk *hdmi_pclk; - struct clk *venci_clk; struct regulator *hdmi_supply; u32 irq_stat; struct dw_hdmi *hdmi; @@ -946,6 +944,29 @@ static void meson_disable_regulator(void *data) regulator_disable(data); } +static void meson_disable_clk(void *data) +{ + clk_disable_unprepare(data); +} + +static int meson_enable_clk(struct device *dev, char *name) +{ + struct clk *clk; + int ret; + + clk = devm_clk_get(dev, name); + if (IS_ERR(clk)) { + dev_err(dev, "Unable to get %s pclk\n", name); + return PTR_ERR(clk); + } + + ret = clk_prepare_enable(clk); + if (!ret) + ret = devm_add_action_or_reset(dev, meson_disable_clk, clk); + + return ret; +} + static int meson_dw_hdmi_bind(struct device *dev, struct device *master, void *data) { @@ -1026,19 +1047,13 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, if (IS_ERR(meson_dw_hdmi->hdmitx)) return PTR_ERR(meson_dw_hdmi->hdmitx); - meson_dw_hdmi->hdmi_pclk = devm_clk_get(dev, "isfr"); - if (IS_ERR(meson_dw_hdmi->hdmi_pclk)) { - dev_err(dev, "Unable to get HDMI pclk\n"); - return PTR_ERR(meson_dw_hdmi->hdmi_pclk); - } - clk_prepare_enable(meson_dw_hdmi->hdmi_pclk); + ret = meson_enable_clk(dev, "isfr"); + if (ret) + return ret; - meson_dw_hdmi->venci_clk = devm_clk_get(dev, "venci"); - if (IS_ERR(meson_dw_hdmi->venci_clk)) { - dev_err(dev, "Unable to get venci clk\n"); - return PTR_ERR(meson_dw_hdmi->venci_clk); - } - clk_prepare_enable(meson_dw_hdmi->venci_clk); + ret = meson_enable_clk(dev, "venci"); + if (ret) + return ret; dw_plat_data->regm = devm_regmap_init(dev, NULL, meson_dw_hdmi, &meson_dw_hdmi_regmap_config); -- 2.27.0