Message ID | 20240206104357.3803517-1-u-kumar1@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-54708-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1452932dyb; Tue, 6 Feb 2024 02:46:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIm1+gVbRSwMzJqiRgqb9EPDCEli2lMyprARUZKyE+QRrB0Vdo12MaH85OGj8Cz1s0hb1E X-Received: by 2002:a17:906:314a:b0:a38:35c5:76f0 with SMTP id e10-20020a170906314a00b00a3835c576f0mr746556eje.11.1707216390829; Tue, 06 Feb 2024 02:46:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707216390; cv=pass; d=google.com; s=arc-20160816; b=XdeK0e7983WDobILGKneW/Kw1R0yD89y0I8scM9SDhjyn1w//YwJRW8bdCXTVl89PN cMbnlElDlBaYkGcvYSI8LSMpZhVvRD5yblE4ruVNnnpHI23B/zF7vdBhA65QCo2ON+E5 emy5MRgdwdMfn86s1AVRoKIP6e4wHQoJFQ2WoZ0w3lw3l3DsHkmlrrUw5pD3aqllcrfW M7isxW2GtJCWPJKtwKal8x8MYxt9dkE3fmn87UNc8g+daFrwg2QdaKq+Ze5qzCMFrFUR CoJpKlXB8jTF6Nn25C6BK5kz+jwMFYeKFMJEmhpq9AcTED+hhYql4ETp/jN7R5tJl4S2 ha/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=fnMZZfEYZdxyhfRJnAJGVe2SVYyE9V81+i0dqrp0+hM=; fh=2K2UoowDSxQmJ+ZJOZ0+MOrx/+U21d3SU8MYiLj+wSY=; b=aaAw0IrHVX/uj2Q7hu6IefxZnoyDhtrlgEizQ578MByfLjsqWRMcVRTvKbau42GngN XRz+Q6k/yOi2u9e9NhOJIGGazNFShQdTqsFl6qNMoETvQ+KXsxDoiZIO9ZtxyAyz34Qu KFCcJ5O90Qfbzg2MEtAIRXEj+z6CqloZaXU2HW8TOWo6ThdcxzI4HPXnpjC7yAYofV0+ TgiLD775+hJGPHkEbBdYtD0w1/Un4D2pRPcm/qlJSTXa5rBf1J/RbsI07fmxs1lvOFuC U+CrZfdg3AMJAHHFGVPLIAtEt9ThP5dBiMG0pOOe72U37uTyETScjHO1ynezHXDzUhdl KrhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="LH/jS+gs"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-54708-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54708-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXwgvf5YinO/AycN5tP1tRHXyeu4fQMpcLJqgVtU1Ngb59OawFUNY79dcXYvegyOkSNOwu6xyi7WthGRsNmNnFUG0lXRA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lc4-20020a170906f90400b00a35cb30b546si962072ejb.936.2024.02.06.02.46.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 02:46:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54708-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="LH/jS+gs"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-54708-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54708-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7681A1F233E5 for <ouuuleilei@gmail.com>; Tue, 6 Feb 2024 10:46:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B029658233; Tue, 6 Feb 2024 10:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="LH/jS+gs" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7932112F59C; Tue, 6 Feb 2024 10:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707216259; cv=none; b=OKD+i07NJhpIl3WMXR/x9T5aA4IafMprcaGR5GTHPVRErXmNI8XGC8pEG1n7SHht5GUi9OTyX2b4o4d2AgrfPeGb4+jAOdW1/Pb3ZLMueDMiTrlhsdg7beV+SdJU7AtZmEnk2gRcum3NA/UCKljdTzzQ5uinNxgr0i7ESSuQUFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707216259; c=relaxed/simple; bh=i371UdEhQpXaJ8mvQCXn8mXTIx12rvp+EJtokqwZJ0o=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=h4HYfnUZH8+Q2YbdqTHfdjviRW0iwSRHmfRtvu4GpkZniCV5HGCmS3E5CkSBeHJiU9PEm4FjMNI0tCW9L/Lqp7w7oMVwaiaq+V+dyxQeBhvY/kW0ebEvjsEMU3awP8Oh8FaaXDnmMngXucy2TBK99RnPN9pOX5a8IXtaBkpGNDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=LH/jS+gs; arc=none smtp.client-ip=198.47.23.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 416AiApb113600; Tue, 6 Feb 2024 04:44:10 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707216250; bh=fnMZZfEYZdxyhfRJnAJGVe2SVYyE9V81+i0dqrp0+hM=; h=From:To:CC:Subject:Date; b=LH/jS+gsZAjdpWXQCEkzCns5tn8qrTjMBvLE30s913ioKACAbH/Q09rDAgSctLJQE kvHqUhmrdM/Il5wflJ4yo4AUGV5PGJ0g9yw4mI5ylN6K5UCVKylHX7P4JUQ4NAnfuo xTp1TKQwgQmJ5dJsZHFWXlk4v1ziyqOUAJOB6Kuc= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 416AiAet028004 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Feb 2024 04:44:10 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 6 Feb 2024 04:44:10 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 6 Feb 2024 04:44:10 -0600 Received: from udit-HP-Z2-Tower-G9-Workstation-Desktop-PC.dhcp.ti.com (udit-hp-z2-tower-g9-workstation-desktop-pc.dhcp.ti.com [172.24.227.18]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 416Ai6iS105184; Tue, 6 Feb 2024 04:44:07 -0600 From: Udit Kumar <u-kumar1@ti.com> To: <nm@ti.com>, <kristo@kernel.org>, <ssantosh@kernel.org>, <chandru@ti.com>, <rishabh@ti.com> CC: <vigneshr@ti.com>, <mturquette@baylibre.com>, <sboyd@kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <linux-clk@vger.kernel.org>, Udit Kumar <u-kumar1@ti.com> Subject: [PATCH v2] clk: keystone: sci-clk: Adding support for non contiguous clocks Date: Tue, 6 Feb 2024 16:13:57 +0530 Message-ID: <20240206104357.3803517-1-u-kumar1@ti.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790146134184238528 X-GMAIL-MSGID: 1790146134184238528 |
Series |
[v2] clk: keystone: sci-clk: Adding support for non contiguous clocks
|
|
Commit Message
Kumar, Udit
Feb. 6, 2024, 10:43 a.m. UTC
Most of clocks and their parents are defined in contiguous range,
But in few cases, there is gap in clock numbers[0].
Driver assumes clocks to be in contiguous range, and add their clock
ids incrementally.
New firmware started returning error while calling get_freq and is_on
API for non-available clock ids.
In this fix, driver checks and adds only valid clock ids.
Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")
[0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html
Section Clocks for NAVSS0_CPTS_0 Device,
clock id 12-15 not present.
Signed-off-by: Udit Kumar <u-kumar1@ti.com>
---
Changelog
Changes in v2
- Updated commit message
- Simplified logic for valid clock id
link to v1 https://lore.kernel.org/all/20240205044557.3340848-1-u-kumar1@ti.com/
P.S
Firmawre returns total num_parents count including non available ids.
For above device id NAVSS0_CPTS_0, number of parents clocks are 16
i.e from id 2 to 17. But out of these ids few are not valid.
So driver adds only valid clock ids out ot total.
Original logs
https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-original-logs
Line 2630 for error
Logs with fix v2
https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9
Line 2591
drivers/clk/keystone/sci-clk.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Comments
On 16:13-20240206, Udit Kumar wrote: > Most of clocks and their parents are defined in contiguous range, > But in few cases, there is gap in clock numbers[0]. > Driver assumes clocks to be in contiguous range, and add their clock > ids incrementally. > > New firmware started returning error while calling get_freq and is_on > API for non-available clock ids. > > In this fix, driver checks and adds only valid clock ids. > > Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") > > [0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html > Section Clocks for NAVSS0_CPTS_0 Device, > clock id 12-15 not present. > > Signed-off-by: Udit Kumar <u-kumar1@ti.com> > --- > Changelog > > Changes in v2 > - Updated commit message > - Simplified logic for valid clock id > link to v1 https://lore.kernel.org/all/20240205044557.3340848-1-u-kumar1@ti.com/ > > > P.S > Firmawre returns total num_parents count including non available ids. > For above device id NAVSS0_CPTS_0, number of parents clocks are 16 > i.e from id 2 to 17. But out of these ids few are not valid. > So driver adds only valid clock ids out ot total. > > Original logs > https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-original-logs > Line 2630 for error > > Logs with fix v2 > https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9 > Line 2591 > > > drivers/clk/keystone/sci-clk.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c > index 35fe197dd303..ff249cbd54a1 100644 > --- a/drivers/clk/keystone/sci-clk.c > +++ b/drivers/clk/keystone/sci-clk.c > @@ -517,6 +517,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > int num_clks = 0; > int num_parents; > int clk_id; > + u64 freq; > const char * const clk_names[] = { > "clocks", "assigned-clocks", "assigned-clock-parents", NULL > }; > @@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > clk_id = args.args[1] + 1; > > while (num_parents--) { > + /* Check if this clock id is valid */ > + ret = provider->ops->get_freq(provider->sci, > + sci_clk->dev_id, clk_id, &freq); get_freq is a bit expensive as it has to walk the clock tree to find the clock frequency (at least the first time?). just wondering if there is lighter alternative here? > + > + clk_id++; > + if (ret) > + continue; > + > sci_clk = devm_kzalloc(dev, > sizeof(*sci_clk), > GFP_KERNEL); > if (!sci_clk) > return -ENOMEM; > sci_clk->dev_id = args.args[0]; > - sci_clk->clk_id = clk_id++; > + sci_clk->clk_id = clk_id - 1; > sci_clk->provider = provider; > list_add_tail(&sci_clk->node, &clks); > - Spurious change. > num_clks++; > } > } > -- > 2.34.1 >
Nishanth Menon <nm@ti.com> writes: > On 16:13-20240206, Udit Kumar wrote: >> Most of clocks and their parents are defined in contiguous range, >> But in few cases, there is gap in clock numbers[0]. >> Driver assumes clocks to be in contiguous range, and add their clock >> ids incrementally. >> >> New firmware started returning error while calling get_freq and is_on >> API for non-available clock ids. >> >> In this fix, driver checks and adds only valid clock ids. >> >> Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") >> >> [0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html >> Section Clocks for NAVSS0_CPTS_0 Device, >> clock id 12-15 not present. >> >> Signed-off-by: Udit Kumar <u-kumar1@ti.com> >> while (num_parents--) { >> + /* Check if this clock id is valid */ >> + ret = provider->ops->get_freq(provider->sci, >> + sci_clk->dev_id, clk_id, &freq); > > get_freq is a bit expensive as it has to walk the clock tree to find > the clock frequency (at least the first time?). just wondering if > there is lighter alternative here? > How about get_clock? Doesn't read the registers at least. Regards, Kamlesh
On 2/6/2024 6:44 PM, Nishanth Menon wrote: > On 16:13-20240206, Udit Kumar wrote: >> Most of clocks and their parents are defined in contiguous range, >> But in few cases, there is gap in clock numbers[0]. >> Driver assumes clocks to be in contiguous range, and add their clock >> ids incrementally. >> >> New firmware started returning error while calling get_freq and is_on >> API for non-available clock ids. >> >> In this fix, driver checks and adds only valid clock ids. >> >> Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") >> >> [0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html >> Section Clocks for NAVSS0_CPTS_0 Device, >> clock id 12-15 not present. >> >> Signed-off-by: Udit Kumar <u-kumar1@ti.com> >> --- >> Changelog >> >> Changes in v2 >> - Updated commit message >> - Simplified logic for valid clock id >> link to v1 https://lore.kernel.org/all/20240205044557.3340848-1-u-kumar1@ti.com/ >> >> >> P.S >> Firmawre returns total num_parents count including non available ids. >> For above device id NAVSS0_CPTS_0, number of parents clocks are 16 >> i.e from id 2 to 17. But out of these ids few are not valid. >> So driver adds only valid clock ids out ot total. >> >> Original logs >> https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-original-logs >> Line 2630 for error >> >> Logs with fix v2 >> https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9 >> Line 2591 >> >> >> drivers/clk/keystone/sci-clk.c | 12 ++++++++++-- >> 1 file changed, 10 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c >> index 35fe197dd303..ff249cbd54a1 100644 >> --- a/drivers/clk/keystone/sci-clk.c >> +++ b/drivers/clk/keystone/sci-clk.c >> @@ -517,6 +517,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) >> int num_clks = 0; >> int num_parents; >> int clk_id; >> + u64 freq; >> const char * const clk_names[] = { >> "clocks", "assigned-clocks", "assigned-clock-parents", NULL >> }; >> @@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) >> clk_id = args.args[1] + 1; >> >> while (num_parents--) { >> + /* Check if this clock id is valid */ >> + ret = provider->ops->get_freq(provider->sci, >> + sci_clk->dev_id, clk_id, &freq); > get_freq is a bit expensive as it has to walk the clock tree to find > the clock frequency (at least the first time?). just wondering if > there is lighter alternative here? Let me check , if we have some other alternative here >> + >> + clk_id++; >> + if (ret) >> + continue; >> + >> sci_clk = devm_kzalloc(dev, >> sizeof(*sci_clk), >> GFP_KERNEL); >> if (!sci_clk) >> return -ENOMEM; >> sci_clk->dev_id = args.args[0]; >> - sci_clk->clk_id = clk_id++; >> + sci_clk->clk_id = clk_id - 1; >> sci_clk->provider = provider; >> list_add_tail(&sci_clk->node, &clks); >> - > Spurious change. I think, you meant by deleting the line ? If yes then will address in next version >> num_clks++; >> } >> } >> -- >> 2.34.1 >>
On 2/6/2024 7:24 PM, Kamlesh Gurudasani wrote: > Nishanth Menon <nm@ti.com> writes: > >> On 16:13-20240206, Udit Kumar wrote: >>> Most of clocks and their parents are defined in contiguous range, >>> But in few cases, there is gap in clock numbers[0]. >>> Driver assumes clocks to be in contiguous range, and add their clock >>> ids incrementally. >>> >>> New firmware started returning error while calling get_freq and is_on >>> API for non-available clock ids. >>> >>> In this fix, driver checks and adds only valid clock ids. >>> >>> Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") >>> >>> [0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html >>> Section Clocks for NAVSS0_CPTS_0 Device, >>> clock id 12-15 not present. >>> >>> Signed-off-by: Udit Kumar <u-kumar1@ti.com> >>> while (num_parents--) { >>> + /* Check if this clock id is valid */ >>> + ret = provider->ops->get_freq(provider->sci, >>> + sci_clk->dev_id, clk_id, &freq); >> get_freq is a bit expensive as it has to walk the clock tree to find >> the clock frequency (at least the first time?). just wondering if >> there is lighter alternative here? >> > How about get_clock? Doesn't read the registers at least. Said API needs, some flags to be passed, Can those flag be set to zero, Chandru ? > Regards, > Kamlesh
Udit Kumar <u-kumar1@ti.com> writes: > Most of clocks and their parents are defined in contiguous range, > But in few cases, there is gap in clock numbers[0]. > Driver assumes clocks to be in contiguous range, and add their clock > ids incrementally. > > New firmware started returning error while calling get_freq and is_on > API for non-available clock ids. > > In this fix, driver checks and adds only valid clock ids. > > Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") > > [0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html > Section Clocks for NAVSS0_CPTS_0 Device, > clock id 12-15 not present. > > Signed-off-by: Udit Kumar <u-kumar1@ti.com> .. > @@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > clk_id = args.args[1] + 1; > > while (num_parents--) { > + /* Check if this clock id is valid */ > + ret = provider->ops->get_freq(provider->sci, > + sci_clk->dev_id, clk_id, &freq); > + > + clk_id++; Why increment it here and subtract if get_freq succeeds (sci_clk->clk_id = clk_id - 1;), rather if(ret) { clk_id++; continue; } > + if (ret) > + continue; > + > sci_clk = devm_kzalloc(dev, > sizeof(*sci_clk), > GFP_KERNEL); > if (!sci_clk) > return -ENOMEM; > sci_clk->dev_id = args.args[0]; > - sci_clk->clk_id = clk_id++; > + sci_clk->clk_id = clk_id - 1; and keep sci_clk->clk_id = clk_id++; intact saves one subtraction or even better - clk_id = args.args[1] + 1; + clk_id = args.args[1]; while (num_parents--) { + /* Check if this clock id is valid */ + ret = provider->ops->get_freq(provider->sci, + sci_clk->dev_id, ++clk_id, &freq); and then no increments after, for clk_id Regards, Kamlesh
On 06/02/24 19:45, Kumar, Udit wrote: > > On 2/6/2024 7:24 PM, Kamlesh Gurudasani wrote: >> Nishanth Menon <nm@ti.com> writes: >> >>> On 16:13-20240206, Udit Kumar wrote: >>>> Most of clocks and their parents are defined in contiguous range, >>>> But in few cases, there is gap in clock numbers[0]. >>>> Driver assumes clocks to be in contiguous range, and add their clock >>>> ids incrementally. >>>> >>>> New firmware started returning error while calling get_freq and is_on >>>> API for non-available clock ids. >>>> >>>> In this fix, driver checks and adds only valid clock ids. >>>> >>>> Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for >>>> dynamically probing clocks") >>>> >>>> [0] >>>> https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html >>>> >>>> Section Clocks for NAVSS0_CPTS_0 Device, >>>> clock id 12-15 not present. >>>> >>>> Signed-off-by: Udit Kumar <u-kumar1@ti.com> >>>> while (num_parents--) { >>>> + /* Check if this clock id is valid */ >>>> + ret = provider->ops->get_freq(provider->sci, >>>> + sci_clk->dev_id, clk_id, &freq); >>> get_freq is a bit expensive as it has to walk the clock tree to find >>> the clock frequency (at least the first time?). just wondering if >>> there is lighter alternative here? >>> >> How about get_clock? Doesn't read the registers at least. > > Said API needs, some flags to be passed, > > Can those flag be set to zero, Chandru ? get_clock doesn't require any flags to be passed. > > >> Regards, >> Kamlesh
On 2/6/2024 7:56 PM, CHANDRU DHAVAMANI wrote: > > On 06/02/24 19:45, Kumar, Udit wrote: >> >> On 2/6/2024 7:24 PM, Kamlesh Gurudasani wrote: >>> Nishanth Menon <nm@ti.com> writes: >>> >>>> On 16:13-20240206, Udit Kumar wrote: >>>>> Most of clocks and their parents are defined in contiguous range, >>>>> But in few cases, there is gap in clock numbers[0]. >>>>> Driver assumes clocks to be in contiguous range, and add their clock >>>>> ids incrementally. >>>>> >>>>> New firmware started returning error while calling get_freq and is_on >>>>> API for non-available clock ids. >>>>> >>>>> In this fix, driver checks and adds only valid clock ids. >>>>> >>>>> Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for >>>>> dynamically probing clocks") >>>>> >>>>> [0] >>>>> https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html >>>>> >>>>> Section Clocks for NAVSS0_CPTS_0 Device, >>>>> clock id 12-15 not present. >>>>> >>>>> Signed-off-by: Udit Kumar <u-kumar1@ti.com> >>>>> while (num_parents--) { >>>>> + /* Check if this clock id is valid */ >>>>> + ret = provider->ops->get_freq(provider->sci, >>>>> + sci_clk->dev_id, clk_id, &freq); >>>> get_freq is a bit expensive as it has to walk the clock tree to find >>>> the clock frequency (at least the first time?). just wondering if >>>> there is lighter alternative here? >>>> >>> How about get_clock? Doesn't read the registers at least. >> >> Said API needs, some flags to be passed, >> >> Can those flag be set to zero, Chandru ? > > > get_clock doesn't require any flags to be passed. May be firmware does not need it but I was referring to https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78 > > >> >> >>> Regards, >>> Kamlesh
"Kumar, Udit" <u-kumar1@ti.com> writes: >>>>> get_freq is a bit expensive as it has to walk the clock tree to find >>>>> the clock frequency (at least the first time?). just wondering if >>>>> there is lighter alternative here? >>>>> >>>> How about get_clock? Doesn't read the registers at least. >>> >>> Said API needs, some flags to be passed, >>> >>> Can those flag be set to zero, Chandru ? >> >> >> get_clock doesn't require any flags to be passed. > > > May be firmware does not need it but I was referring to > > https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78 Just took a look, I now understand the reason for confusion, #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100 #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101 cops->get_clock = ti_sci_cmd_get_clock; --> refers to TI_SCI_MSG_SET_CLOCK_STATE That's why we are passing the flag from linux for get_clock Linux is using terminology of get/put. As Chandru pointed, we don't have to pass flags, cause he is refering to TI_SCI_MSG_GET_CLOCK_STATE Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what we actually want. cops->is_auto = ti_sci_cmd_clk_is_auto; cops->is_on = ti_sci_cmd_clk_is_on; cops->is_off = ti_sci_cmd_clk_is_off; Which should be safe to call, Chandru can confirm. Regards, Kamlesh > > > >> >> >>> >>> >>>> Regards, >>>> Kamlesh
On 2/6/2024 9:24 PM, Kamlesh Gurudasani wrote: > "Kumar, Udit" <u-kumar1@ti.com> writes: > >>>>>> get_freq is a bit expensive as it has to walk the clock tree to find >>>>>> the clock frequency (at least the first time?). just wondering if >>>>>> there is lighter alternative here? >>>>>> >>>>> How about get_clock? Doesn't read the registers at least. >>>> Said API needs, some flags to be passed, >>>> >>>> Can those flag be set to zero, Chandru ? >>> >>> get_clock doesn't require any flags to be passed. >> >> May be firmware does not need it but I was referring to >> >> https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78 > Just took a look, > > I now understand the reason for confusion, > > #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100 > #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101 > > cops->get_clock = ti_sci_cmd_get_clock; --> refers to > TI_SCI_MSG_SET_CLOCK_STATE > That's why we are passing the flag from linux for get_clock > > Linux is using terminology of get/put. > > As Chandru pointed, we don't have to pass flags, cause he is refering > to TI_SCI_MSG_GET_CLOCK_STATE > > Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what > we actually want. > cops->is_auto = ti_sci_cmd_clk_is_auto; > cops->is_on = ti_sci_cmd_clk_is_on; > cops->is_off = ti_sci_cmd_clk_is_off; I think calling ti_sci_cmd_clk_is_auto should be good . other functions needs current state and requested state. Chandru ? > > Which should be safe to call, Chandru can confirm. > > Regards, > Kamlesh >> >> >>> >>>> >>>>> Regards, >>>>> Kamlesh
On 07/02/24 11:03, Kumar, Udit wrote: > > On 2/6/2024 9:24 PM, Kamlesh Gurudasani wrote: >> "Kumar, Udit" <u-kumar1@ti.com> writes: >> >>>>>>> get_freq is a bit expensive as it has to walk the clock tree to >>>>>>> find >>>>>>> the clock frequency (at least the first time?). just wondering if >>>>>>> there is lighter alternative here? >>>>>>> >>>>>> How about get_clock? Doesn't read the registers at least. >>>>> Said API needs, some flags to be passed, >>>>> >>>>> Can those flag be set to zero, Chandru ? >>>> >>>> get_clock doesn't require any flags to be passed. >>> >>> May be firmware does not need it but I was referring to >>> >>> https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78 >>> >> Just took a look, >> >> I now understand the reason for confusion, >> >> #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100 >> #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101 >> >> cops->get_clock = ti_sci_cmd_get_clock; --> refers to >> TI_SCI_MSG_SET_CLOCK_STATE >> That's why we are passing the flag from linux for get_clock >> >> Linux is using terminology of get/put. >> >> As Chandru pointed, we don't have to pass flags, cause he is refering >> to TI_SCI_MSG_GET_CLOCK_STATE >> >> Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what >> we actually want. >> cops->is_auto = ti_sci_cmd_clk_is_auto; >> cops->is_on = ti_sci_cmd_clk_is_on; >> cops->is_off = ti_sci_cmd_clk_is_off; > > > I think calling ti_sci_cmd_clk_is_auto should be good . other > functions needs current state and requested state. > > Chandru ? > ti_sci_cmd_clk_is_auto is internal function to linux. For TI_SCI_MSG_GET_CLOCK_STATE, linux only needs to pass pointers to the variables where result will be stored. >> >> Which should be safe to call, Chandru can confirm. >> >> Regards, >> Kamlesh >>> >>> >>>> >>>>> >>>>>> Regards, >>>>>> Kamlesh
On 2/7/2024 12:53 PM, CHANDRU DHAVAMANI wrote: > > On 07/02/24 11:03, Kumar, Udit wrote: >> >> On 2/6/2024 9:24 PM, Kamlesh Gurudasani wrote: >>> "Kumar, Udit" <u-kumar1@ti.com> writes: >>> >>>>>>>> get_freq is a bit expensive as it has to walk the clock tree to >>>>>>>> find >>>>>>>> the clock frequency (at least the first time?). just wondering if >>>>>>>> there is lighter alternative here? >>>>>>>> >>>>>>> How about get_clock? Doesn't read the registers at least. >>>>>> Said API needs, some flags to be passed, >>>>>> >>>>>> Can those flag be set to zero, Chandru ? >>>>> >>>>> get_clock doesn't require any flags to be passed. >>>> >>>> May be firmware does not need it but I was referring to >>>> >>>> https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78 >>>> >>> Just took a look, >>> >>> I now understand the reason for confusion, >>> >>> #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100 >>> #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101 >>> >>> cops->get_clock = ti_sci_cmd_get_clock; --> refers to >>> TI_SCI_MSG_SET_CLOCK_STATE >>> That's why we are passing the flag from linux for get_clock >>> >>> Linux is using terminology of get/put. >>> >>> As Chandru pointed, we don't have to pass flags, cause he is refering >>> to TI_SCI_MSG_GET_CLOCK_STATE >>> >>> Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what >>> we actually want. >>> cops->is_auto = ti_sci_cmd_clk_is_auto; >>> cops->is_on = ti_sci_cmd_clk_is_on; >>> cops->is_off = ti_sci_cmd_clk_is_off; >> >> >> I think calling ti_sci_cmd_clk_is_auto should be good . other >> functions needs current state and requested state. >> >> Chandru ? >> > > ti_sci_cmd_clk_is_auto is internal function to linux. > For TI_SCI_MSG_GET_CLOCK_STATE, linux only needs to pass pointers to > the variables where result will be stored. Yes this internal function calls TI_SCI_MSG_GET_CLOCK_STATE > > >>> >>> Which should be safe to call, Chandru can confirm. >>> >>> Regards, >>> Kamlesh >>>> >>>> >>>>> >>>>>> >>>>>>> Regards, >>>>>>> Kamlesh
On 07/02/24 13:03, Kumar, Udit wrote: > > On 2/7/2024 12:53 PM, CHANDRU DHAVAMANI wrote: >> >> On 07/02/24 11:03, Kumar, Udit wrote: >>> >>> On 2/6/2024 9:24 PM, Kamlesh Gurudasani wrote: >>>> "Kumar, Udit" <u-kumar1@ti.com> writes: >>>> >>>>>>>>> get_freq is a bit expensive as it has to walk the clock tree >>>>>>>>> to find >>>>>>>>> the clock frequency (at least the first time?). just wondering if >>>>>>>>> there is lighter alternative here? >>>>>>>>> >>>>>>>> How about get_clock? Doesn't read the registers at least. >>>>>>> Said API needs, some flags to be passed, >>>>>>> >>>>>>> Can those flag be set to zero, Chandru ? >>>>>> >>>>>> get_clock doesn't require any flags to be passed. >>>>> >>>>> May be firmware does not need it but I was referring to >>>>> >>>>> https://elixir.bootlin.com/linux/latest/source/drivers/clk/keystone/sci-clk.c#L78 >>>>> >>>> Just took a look, >>>> >>>> I now understand the reason for confusion, >>>> >>>> #define TI_SCI_MSG_SET_CLOCK_STATE 0x0100 >>>> #define TI_SCI_MSG_GET_CLOCK_STATE 0x0101 >>>> >>>> cops->get_clock = ti_sci_cmd_get_clock; --> refers to >>>> TI_SCI_MSG_SET_CLOCK_STATE >>>> That's why we are passing the flag from linux for get_clock >>>> >>>> Linux is using terminology of get/put. >>>> >>>> As Chandru pointed, we don't have to pass flags, cause he is refering >>>> to TI_SCI_MSG_GET_CLOCK_STATE >>>> >>>> Below functions passes TI_SCI_MSG_GET_CLOCK_STATE to DM, which is what >>>> we actually want. >>>> cops->is_auto = ti_sci_cmd_clk_is_auto; >>>> cops->is_on = ti_sci_cmd_clk_is_on; >>>> cops->is_off = ti_sci_cmd_clk_is_off; >>> >>> >>> I think calling ti_sci_cmd_clk_is_auto should be good . other >>> functions needs current state and requested state. >>> >>> Chandru ? >>> >> >> ti_sci_cmd_clk_is_auto is internal function to linux. >> For TI_SCI_MSG_GET_CLOCK_STATE, linux only needs to pass pointers to >> the variables where result will be stored. > > > Yes this internal function calls TI_SCI_MSG_GET_CLOCK_STATE > Okay. We can use TI_SCI_MSG_GET_CLOCK_STATE to check to if clock is valid or not. > >> >> >>>> >>>> Which should be safe to call, Chandru can confirm. >>>> >>>> Regards, >>>> Kamlesh >>>>> >>>>> >>>>>> >>>>>>> >>>>>>>> Regards, >>>>>>>> Kamlesh
diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 35fe197dd303..ff249cbd54a1 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -517,6 +517,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) int num_clks = 0; int num_parents; int clk_id; + u64 freq; const char * const clk_names[] = { "clocks", "assigned-clocks", "assigned-clock-parents", NULL }; @@ -586,16 +587,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) clk_id = args.args[1] + 1; while (num_parents--) { + /* Check if this clock id is valid */ + ret = provider->ops->get_freq(provider->sci, + sci_clk->dev_id, clk_id, &freq); + + clk_id++; + if (ret) + continue; + sci_clk = devm_kzalloc(dev, sizeof(*sci_clk), GFP_KERNEL); if (!sci_clk) return -ENOMEM; sci_clk->dev_id = args.args[0]; - sci_clk->clk_id = clk_id++; + sci_clk->clk_id = clk_id - 1; sci_clk->provider = provider; list_add_tail(&sci_clk->node, &clks); - num_clks++; } }