Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3449551ybt; Tue, 30 Jun 2020 03:07:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwODAKYOcn4PSe3sSRUdI9x6+wZ9kcilGb/KA08hbv8rw1uBvhgX80NWydMJYeOxQneXim7 X-Received: by 2002:a17:906:c285:: with SMTP id r5mr17165853ejz.153.1593511639495; Tue, 30 Jun 2020 03:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593511639; cv=none; d=google.com; s=arc-20160816; b=NJG2AwFXS0u2uXq7fiQiRp3f0t+bs22+ge3d52vPfvy2pH+KXGTGLWr9QcQg/bVWyf gCsU2A7LppaYWL14hc9zc7nsdqoKOwI+C2+3rlF4T9LfKcNFlckEtcXOwciGKdSxl3ze R+u02VxYCqcpZNmBNvWUyzbiy92otP4SPXt8Mz9VCFfJn7gVBIjXE+/78HLbZMC5tvud nySTsbrXGU72f/AhdC8rRwQrECe0x62Eth++D2YonBQ/T1d5d8bJilM7tWkdpthVqkgG ek/H9l/FAf37geeAM123f9/xLxI/pO+AFHjU5f3KojcVyhcO+46LIDLbZYkDKM8is9HY t1NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=oQUedL8TbScAqYKvSyEJGT96mylw/Z0QVJkevgdZ2x8=; b=XTUOCNHu+ZQs/3Im9E1Tr0gIJjOozfjnCE58w1gxtfINfvUdiINhmU+wzF+IzmYn5h 3sxtq7l3wIbAVO+yNmWNx6MXkkY91ISYpJbdVYk3CaAWFcwy3S1r3ESvpat5bI6Ug5Ft 5WOg6vqWEczcbL2bn4f3HM7EJw7j069K4BLELYXwbsKgHjV4jnlK0U5W73ZRZjzOAHcg UEMEWC/olVh7ZQm5l35svGhb8m9DjbGpHBbXyPx+CIUG98QIRPSIwQLmlep7XvYDp6t/ Q3ZfZZt/bk6YBvXCi8anxhp6vtp7SXH21nwG7zDe9VJ0qVzr4E+/eCGdbWv+/zbT5Lwh d0Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=um9iXcbb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si1444273edb.399.2020.06.30.03.06.56; Tue, 30 Jun 2020 03:07:19 -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=@kernel.org header.s=default header.b=um9iXcbb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732198AbgF3KFx (ORCPT + 99 others); Tue, 30 Jun 2020 06:05:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:44640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732078AbgF3KFw (ORCPT ); Tue, 30 Jun 2020 06:05:52 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02BA62073E; Tue, 30 Jun 2020 10:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593511552; bh=WGsfVoaT6gosQlq2ySDAquPdQTa/aXDxRdmxD1Nsln8=; h=From:To:Cc:Subject:Date:From; b=um9iXcbbiq0/h4rBLL3CVKNNpdpKp8XNwiBmhB/N1BOewXCoTQv7OhhXdXZq6f9ui Ijow/waRSxqxqtWZvi2jPWc9y+xoFjYJ/OGRAqwMc0EOJkcvDXR1W1S/yQT7zbDCba +uBUUkYa6Ti/Pk+a4NA0Euc+oJuMGK+VCk/70QcA= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqD9C-007hs2-EG; Tue, 30 Jun 2020 11:05:50 +0100 From: Marc Zyngier To: Chanwoo Choi , Enric Balletbo i Serra Cc: MyungJoo Ham , Kyungmin Park , Heiko Stuebner , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, stable@vger.kernel.org Subject: [PATCH v3] PM / devfreq: rk3399_dmc: Fix kernel oops when rockchip,pmu is absent Date: Tue, 30 Jun 2020 11:05:46 +0100 Message-Id: <20200630100546.862468-1-maz@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: cw00.choi@samsung.com, enric.balletbo@collabora.com, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, heiko@sntech.de, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Booting a recent kernel on a rk3399-based system (nanopc-t4), equipped with a recent u-boot and ATF results in an Oops due to a NULL pointer dereference. This turns out to be due to the rk3399-dmc driver looking for an *undocumented* property (rockchip,pmu), and happily using a NULL pointer when the property isn't there. Instead, make most of what was brought in with 9173c5ceb035 ("PM / devfreq: rk3399_dmc: Pass ODT and auto power down parameters to TF-A.") conditioned on finding this property in the device-tree, preventing the driver from exploding. Cc: stable@vger.kernel.org Fixes: 9173c5ceb035 ("PM / devfreq: rk3399_dmc: Pass ODT and auto power down parameters to TF-A.") Signed-off-by: Marc Zyngier --- * From v2: - Trimmed down commit message - Cc stable drivers/devfreq/rk3399_dmc.c | 42 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c index 24f04f78285b..027769e39f9b 100644 --- a/drivers/devfreq/rk3399_dmc.c +++ b/drivers/devfreq/rk3399_dmc.c @@ -95,18 +95,20 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, mutex_lock(&dmcfreq->lock); - if (target_rate >= dmcfreq->odt_dis_freq) - odt_enable = true; - - /* - * This makes a SMC call to the TF-A to set the DDR PD (power-down) - * timings and to enable or disable the ODT (on-die termination) - * resistors. - */ - arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, dmcfreq->odt_pd_arg0, - dmcfreq->odt_pd_arg1, - ROCKCHIP_SIP_CONFIG_DRAM_SET_ODT_PD, - odt_enable, 0, 0, 0, &res); + if (dmcfreq->regmap_pmu) { + if (target_rate >= dmcfreq->odt_dis_freq) + odt_enable = true; + + /* + * This makes a SMC call to the TF-A to set the DDR PD + * (power-down) timings and to enable or disable the + * ODT (on-die termination) resistors. + */ + arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, dmcfreq->odt_pd_arg0, + dmcfreq->odt_pd_arg1, + ROCKCHIP_SIP_CONFIG_DRAM_SET_ODT_PD, + odt_enable, 0, 0, 0, &res); + } /* * If frequency scaling from low to high, adjust voltage first. @@ -371,13 +373,14 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) } node = of_parse_phandle(np, "rockchip,pmu", 0); - if (node) { - data->regmap_pmu = syscon_node_to_regmap(node); - of_node_put(node); - if (IS_ERR(data->regmap_pmu)) { - ret = PTR_ERR(data->regmap_pmu); - goto err_edev; - } + if (!node) + goto no_pmu; + + data->regmap_pmu = syscon_node_to_regmap(node); + of_node_put(node); + if (IS_ERR(data->regmap_pmu)) { + ret = PTR_ERR(data->regmap_pmu); + goto err_edev; } regmap_read(data->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val); @@ -399,6 +402,7 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) goto err_edev; }; +no_pmu: arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, 0, 0, ROCKCHIP_SIP_CONFIG_DRAM_INIT, 0, 0, 0, 0, &res); -- 2.27.0