Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp1786997imc; Fri, 22 Feb 2019 11:09:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ4kLVllXW4kELu7BzoXX29Y5W2ZPnEoaKojuKSGeehSkHLL6rMobJxrjChzFsfegRjBtPY X-Received: by 2002:a63:6881:: with SMTP id d123mr5387329pgc.10.1550862549088; Fri, 22 Feb 2019 11:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550862549; cv=none; d=google.com; s=arc-20160816; b=pP2hxfjyL/L8yRXT8rykx7P5G61hRb2lfgmQai98FLrYf4+gZGeI6nLmV9f8AEVuS5 HXxkSBeFEtDFSVS3VMUCFwOLHMPkqg28kSWu//WwnrsTwOY1Nuwn44agmSx+Skrja0Gg zpZmGoJj9zF3GRARir8RXl2Pkvpmff0zf+1lEK73Z5Gt9TuH5TI4gdKajxgRLSuexR/g 70PcpYDH+MGBDgzQ9OZ8RAoUAdZfjDiDkobKUVRy1AS1nQRXA9k36OpNCgScfPCaXfIM hxvW69vh8ZC9n4547x3oH3aqZ0j+dUgckLZjUcNRzXMdyVuV/xM3azpDIsdWBY8u1tjf InoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:in-reply-to:from:references :user-agent:message-id:subject:content-transfer-encoding :mime-version:dkim-signature; bh=bYwmQa9QRMVlMP/k7k5cN/2KDSh3fgpNhbY1isUrjAM=; b=RpCjlM8skdbZe+NBlhMHDYNvSPbVQJbx+SdiA4a8/byzI3JQS8wFZhRX4nwVuhQV95 pEiV0RhTg6hw5PA1RtDLP2ITqqHvv4gnQlcn9xBTSD+sEphW5wUbSdUZt0bMh9F3aCpM EbOUpRVT2FaVx6Dq20JE+4EbR78A5ztKYdUpcfqf/x/ErbhfCwGaPNUV/dWWxseZWoHz NB4f5R5y1YijJ3QOgUmUOGpJ3J38GX9rGev5DNDaIFTJW5dD5JrQigUyp5eWxTPZvUqf EUvsqX1J3SgdVR8k07CZUV6xscBoBgyHIsMmyr9qIkYNpJPpsS6ZbXCGh7kS2HCxm1TO PwGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rvJ71P0v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id z31si1955370plb.402.2019.02.22.11.08.53; Fri, 22 Feb 2019 11:09:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rvJ71P0v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726313AbfBVTIM (ORCPT + 99 others); Fri, 22 Feb 2019 14:08:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:50606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfBVTIL (ORCPT ); Fri, 22 Feb 2019 14:08:11 -0500 Received: from localhost (unknown [104.132.0.74]) (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 D23B3206BB; Fri, 22 Feb 2019 19:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550862490; bh=zn5gREfnAEgVz2BI4KrdGye4NvLUosAjzJ0G//JMftY=; h=Subject:References:From:In-Reply-To:To:Cc:Date:From; b=rvJ71P0vQdSAFNlEJjZ4Pe8azzNtfsV9AtdZmcTkrOuZxK9geLTwKtG7YAf3l8Vwm qWX1lnThkUN9xUae0vOKy2p3arrmCbUPxQZo2AWLVfKPqH/orPjaPlLAAxHIC359l6 YxCnzqmv8kafRdWDmgPjp8LHeKyvH7XdIBIXTvIQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH RESEND V6 2/2] clk: imx: scu: add cpu frequency scaling support Message-ID: <155086249004.77512.8709011386763447047@swboyd.mtv.corp.google.com> User-Agent: alot/0.8 References: <1550802436-13007-1-git-send-email-Anson.Huang@nxp.com> <1550802436-13007-2-git-send-email-Anson.Huang@nxp.com> From: Stephen Boyd In-Reply-To: <1550802436-13007-2-git-send-email-Anson.Huang@nxp.com> To: "devicetree@vger.kernel.org" , "festevam@gmail.com" , "kernel@pengutronix.de" , "linux-arm-kernel@lists.infradead.org" , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "mark.rutland@arm.com" , "mturquette@baylibre.com" , "robh+dt@kernel.org" , "s.hauer@pengutronix.de" , "shawnguo@kernel.org" , Aisheng Dong , Anson Huang , Daniel Baluta Cc: dl-linux-imx Date: Fri, 22 Feb 2019 11:08:10 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Anson Huang (2019-02-21 18:32:10) > On NXP's i.MX SoCs with system controller inside, CPU frequency > scaling can ONLY be done by system controller firmware, and it > can ONLY be requested from secure mode, so Linux kernel has to > call ARM SMC to trap to ARM-Trusted-Firmware to request system > controller firmware to do CPU frequency scaling. >=20 > This patch adds i.MX system controller CPU frequency scaling support, > it reuses cpufreq-dt driver and implement the CPU frequency scaling > inside SCU clock driver. >=20 > Signed-off-by: Anson Huang Ah I missed one thing, see below. > @@ -180,6 +185,23 @@ static long clk_scu_round_rate(struct clk_hw *hw, un= signed long rate, > return rate; > } > =20 > +static int clk_scu_atf_set_cpu_rate(struct clk_hw *hw, unsigned long rat= e, > + unsigned long parent_rate) > +{ > + struct clk_scu *clk =3D to_clk_scu(hw); > + struct arm_smccc_res res; > + unsigned long cluster_id; > + > + if (clk->rsrc_id =3D=3D IMX_SC_R_A35) > + cluster_id =3D 0; Do we still need to check this anymore? Why not just always use cluster_id 0? > + > + /* CPU frequency scaling can ONLY be done by ARM-Trusted-Firmware= */ > + arm_smccc_smc(IMX_SIP_CPUFREQ, IMX_SIP_SET_CPUFREQ, > + cluster_id, rate, 0, 0, 0, 0, &res); Because not checking would make this work, vs. checking causes this code to sometimes use an uninitialized value from the stack. > + > + return 0; > +} > +