From patchwork Tue Jan 7 16:59:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 11323045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70C8B138D for ; Wed, 8 Jan 2020 08:13:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E8EA205F4 for ; Wed, 8 Jan 2020 08:13:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="FMfKFluh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Ploh0OFn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E8EA205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none 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 CE9C86E864; Wed, 8 Jan 2020 08:12:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B53388284 for ; Tue, 7 Jan 2020 17:00:02 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 3CBCC6CD; Tue, 7 Jan 2020 12:00:01 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 07 Jan 2020 12:00:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=F4W/1VWP1mKmEGuteUg12ajW4M xYom8otASm0XcrXXI=; b=FMfKFluh0CLOfrxFHxiNyAo4jVBgaaF8V6hJ8Cek8W CILffx34Pl7+4yeIfeJ98TlSjcWTKNbyYeflt+LLqxSeBCcUf9JBM0DrKLllDFt7 RrLesKmx7VfE+2KXGnI113cspYQxHa1pR4kgj2CgBMX7zNhBJ/jvAvHnZDOuO07y FkyPCoYNECe5w4XwQHdzbnVOWK8ySrUl9LXVyka1vy1vtGjI7H0N/PJurv6wvWyi lCV4LCeCofw7Btb4zOipd1ZSpXTOHb4izg+xr6EvPVsV5F2XLzwPMEA4f5iIt/fi OtJHRmzSftjBDXnAarMFjqvExNWovR+3JtHoxcra9EsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=F4W/1VWP1mKmEGute Ug12ajW4MxYom8otASm0XcrXXI=; b=Ploh0OFn+D3Q9dVFVmzz1qLdrqNvHeSNy u9I5dhFSf1Emv3sZA9WoEN0TFeV4pstPbQE34An8q2DPiQQ82by05EEDmjsFXOx1 qWU0zHnX6lxHDASAx0Sw6CyVc9VZpDoFDAWELv37doDOhzavT5MxZ8FlmFzkPTmy zOwAeCCIBMowPkkRNJgRBmoPnM1c/S9g1vP92Vd/xd8qhOs4cm7Nn7XLdIboWWMO /RycIh6OSzFD7pTjwFLxeAhmOV4khwRjSHJ2kcah/RasarLF+zXmCSCc57cI4XBN +vwf6IH497iImDtaVeKEzybrGTX+PEuQZ+aIL8Ihr0yS1wmyq4u8Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdehhedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhmvgcu tfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecukfhppeeltddrke elrdeikedrjeeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhn ohdrthgvtghhnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id CB7B780060; Tue, 7 Jan 2020 11:59:59 -0500 (EST) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard Subject: [PATCH v2 1/2] drm/sun4i: backend: Make sure we enforce the clock rate Date: Tue, 7 Jan 2020 17:59:56 +0100 Message-Id: <20200107165957.672435-1-maxime@cerno.tech> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 08 Jan 2020 08:12:31 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Kocialkowski , Maxime Ripard , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The backend needs to run at 300MHz to be functional. This was done so far using assigned-clocks in the device tree, but that is easy to forget, and dosen't provide any other guarantee than the rate is going to be roughly the one requested at probe time. Therefore it's pretty fragile, so let's just use the exclusive clock API to enforce it. Signed-off-by: Maxime Ripard --- Changes from v1: - Add test on the clk_set_rate_exclusive return value --- drivers/gpu/drm/sun4i/sun4i_backend.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 4e29f4fe4a05..072ea113e6be 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -856,6 +856,13 @@ static int sun4i_backend_bind(struct device *dev, struct device *master, ret = PTR_ERR(backend->mod_clk); goto err_disable_bus_clk; } + + ret = clk_set_rate_exclusive(backend->mod_clk, 300000000); + if (ret) { + dev_err(dev, "Couldn't set the module clock frequency\n"); + goto err_disable_bus_clk; + } + clk_prepare_enable(backend->mod_clk); backend->ram_clk = devm_clk_get(dev, "ram"); @@ -932,6 +939,7 @@ static int sun4i_backend_bind(struct device *dev, struct device *master, err_disable_ram_clk: clk_disable_unprepare(backend->ram_clk); err_disable_mod_clk: + clk_rate_exclusive_put(backend->mod_clk); clk_disable_unprepare(backend->mod_clk); err_disable_bus_clk: clk_disable_unprepare(backend->bus_clk); @@ -952,6 +960,7 @@ static void sun4i_backend_unbind(struct device *dev, struct device *master, sun4i_backend_free_sat(dev); clk_disable_unprepare(backend->ram_clk); + clk_rate_exclusive_put(backend->mod_clk); clk_disable_unprepare(backend->mod_clk); clk_disable_unprepare(backend->bus_clk); reset_control_assert(backend->reset); From patchwork Tue Jan 7 16:59:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 11323057 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA8A0139A for ; Wed, 8 Jan 2020 08:13:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C7CEE205F4 for ; Wed, 8 Jan 2020 08:13:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="h9BYR5Qh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="SdgjmO5Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7CEE205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none 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 163226E873; Wed, 8 Jan 2020 08:13:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5923589FFD for ; Tue, 7 Jan 2020 17:00:05 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id C19516A5; Tue, 7 Jan 2020 12:00:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 07 Jan 2020 12:00:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=aosMPaE9sZ47Z 7ZiP0Xmd3wgeby5+/lZuZXSIPrpqws=; b=h9BYR5QhpHQrp/T55CCUB1Y4RuoJu aniNHLWE2ZBaRfgMmdQPq7/VfttbE6mgdQG/ueEt3Yr5zNOkf5iMV7prOgl13UMY 2yiPH6YByGWIYe65aNvzAUrcysPrs/FXTfkCYlc21Nsi2poJs8cNXNuo0piJTCdX vGqD4dhb3envajK0yV1ta4gj/iP3N+W9NOfqJOG70RJwZawjmNL1IWaSfwWXH0Rb Qa95hHcznfHo5ExbK25eH5Gyq+Nrc7KAgneIqMVn2aCjkffbwBmsfigZdZ5kovEP jj+ujpYzjwh/dfZaY+Cux3/B++ZxDNffug7LL7pXcFRLrG7fkqVED2E3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=aosMPaE9sZ47Z7ZiP0Xmd3wgeby5+/lZuZXSIPrpqws=; b=SdgjmO5Q dQ/LycdJ5fs1PJZhWm2X/TqWkAAzKZzwdi0g2UY06TBlcSAmMCStVyAbBVSRgow5 SdQhQsg4NbpINiztq5y2/0BYjqkme48gIO0z1Ctaah4vh8VDEHzN0UriY/OAEE6+ din7mDLsLPTUFgrEbexfji2YU6rfa0hAECYgGkA3QHoBH96J9/XgyiIndws47AgN 4tQUv/c0DCktl2FvivIIm29dn5UQKw/1Jb9ohNvCwOHCr34t7pr5U7Ig6Cz4ACnK UUjN2tamczl8DzgFKWM17h7jWctWmUjlKVbZPp88/5fbxL/iAEKZUOrTB2iDX98Z XKZSquoMfKsOoA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdehhedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecukfhppeeltd drkeelrdeikedrjeeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggv rhhnohdrthgvtghhnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 08F3630607D0; Tue, 7 Jan 2020 12:00:02 -0500 (EST) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard Subject: [PATCH v2 2/2] drm/sun4i: drc: Make sure we enforce the clock rate Date: Tue, 7 Jan 2020 17:59:57 +0100 Message-Id: <20200107165957.672435-2-maxime@cerno.tech> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107165957.672435-1-maxime@cerno.tech> References: <20200107165957.672435-1-maxime@cerno.tech> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 08 Jan 2020 08:12:31 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Kocialkowski , Maxime Ripard , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The DRC needs to run at 300MHz to be functional. This was done so far using assigned-clocks in the device tree, but that is easy to forget, and dosen't provide any other guarantee than the rate is going to be roughly the one requested at probe time. Therefore it's pretty fragile, so let's just use the exclusive clock API to enforce it. Signed-off-by: Maxime Ripard --- Changes from v1: - Add test on the clk_set_rate_exclusive return value --- drivers/gpu/drm/sun4i/sun6i_drc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun6i_drc.c b/drivers/gpu/drm/sun4i/sun6i_drc.c index f7ab72244796..4fbe9a6b5182 100644 --- a/drivers/gpu/drm/sun4i/sun6i_drc.c +++ b/drivers/gpu/drm/sun4i/sun6i_drc.c @@ -56,6 +56,13 @@ static int sun6i_drc_bind(struct device *dev, struct device *master, ret = PTR_ERR(drc->mod_clk); goto err_disable_bus_clk; } + + ret = clk_set_rate_exclusive(drc->mod_clk, 300000000); + if (ret) { + dev_err(dev, "Couldn't set the module clock frequency\n"); + goto err_disable_bus_clk; + } + clk_prepare_enable(drc->mod_clk); return 0; @@ -72,6 +79,7 @@ static void sun6i_drc_unbind(struct device *dev, struct device *master, { struct sun6i_drc *drc = dev_get_drvdata(dev); + clk_rate_exclusive_put(drc->mod_clk); clk_disable_unprepare(drc->mod_clk); clk_disable_unprepare(drc->bus_clk); reset_control_assert(drc->reset);