Message ID | 20240207091100.4001428-1-u-kumar1@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-56172-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2100784dyb; Wed, 7 Feb 2024 01:11:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIHKhg9HJeFO/LuejfJtfrif7ol3YPVrug+YJbnOIvqOx0RGwd1r+sWSOxR5L6nHfJy6RC X-Received: by 2002:a05:6214:301b:b0:68c:8ac5:7381 with SMTP id ke27-20020a056214301b00b0068c8ac57381mr5964869qvb.0.1707297098175; Wed, 07 Feb 2024 01:11:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707297098; cv=pass; d=google.com; s=arc-20160816; b=ntZnjCG5pU2dFbduyfqaekDLB7ocLaPO+U0N0cUGb4DtLkcDqlD8NoelgIDR5K0voi uQ+qRuZMQ6t1E6c4qELG5vy/RC3Z3Ru2NBtYtZqVAxaTJEMduTV43VzsbztSXbbZlroJ Oomj1DWk5kago/vY+txZnfeX2+TV1n3uWssdQbkGz4nzaYrWq6yzc0Ht4ORkLf+exzkv nTkuqXhwkMPOiFIIqG2VbtNe98sWt7CB777yORF8dNyYXHBbLWf+ZmSf6k8wFPH6EGS9 eV2PRkAEXkSEPWMtVc/OpjOcHL/QTBukJpEBHxhHXiGw73bgM4O1yJTJhyvRx17dkm6u dloQ== 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=8+z5AzK6gRUDQ16vqNk0y0fkfcURB4sVIOGrxpLSLVQ=; fh=+cJaOzzKKuO/XxBZgQ0gXfI2HUg5YsPxEVZEPtpM9lM=; b=cQFNcnpBMe9Fw8+ECTKJmXDgWx7NC+E43lV1cXGh3Kpl/k50nCdtBvAAzJI20gPu0o 5NHzok42Am5eEdSCRC7Jpi1iB0wIVwveQ9ZpNVLZ5rMlblCcN/bG1Fsm7ux8dbCxqsxg toKC0sAzPoz0DQqL7bnhaxHboI4TAYRo3eFeZX1nsDXqLE6zxzVuk6oywI2c78ovuAce 89WWOOVlbXXcMY/2bIyBSZsxD5zARwy1gqEn/5MllSz3EDyQv//FPMpKVCTwRIPKT7p+ DWp2rMJB6IYBCi6WWv0NMks/UyM/X9LDRK7jTjFN0i6CnuDturCZ3NjAfkR2Qf1dqFo6 JNcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=pFm0o0fG; 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-56172-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56172-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=2; AJvYcCXfjY7mQ+G7dSqly/ZWh2bFXtNznJA0VG3jnqG5tTam4NJd+fZx7EVOEZ49lBWd/O9Sl0WdCfvEpZfl9eLfG0WA05mAoA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i5-20020ad44ba5000000b0068cb809bf8asi710372qvw.352.2024.02.07.01.11.38 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 01:11:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56172-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=pFm0o0fG; 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-56172-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56172-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E1C7F1C22C87 for <ouuuleilei@gmail.com>; Wed, 7 Feb 2024 09:11:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4FD921106; Wed, 7 Feb 2024 09:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="pFm0o0fG" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 ED72120B12; Wed, 7 Feb 2024 09:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707297084; cv=none; b=Isq8gawBMisMC6xKyJE0A4+ZKdOXVQ99ojKsbl9BcgISbMxd7dAxDQRhPqgP6RaQtKZ5qwlGvgjtaNB9XUrqQ6eTfgUrpqdPI1qcjL7K4XVy9cB6b2ggXiJIkPfgVxglXu9RstsqAeqlGIlXVuBr+mbYUeyzGi22F5tzBweal0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707297084; c=relaxed/simple; bh=ZNLMFoWciTitck67uVg21vy3FddYxalS3S4xIpSkUpA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gukTrbTMVUIRJR1HEmCC1qgknEdZCl1SfnbJpyxh6Pi6AItUkisfDQVbNlfLqHrVnm2s+1S6ELr7vL5z2P2tIraLE2wXAqX1ClWth1+fKvv+c+SdU3Cx+NqiuTO3n8u6AGC0LZuKLKcV1T/hUgp/jb8lUCfj7PdFtIm5LbMqvcA= 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=pFm0o0fG; arc=none smtp.client-ip=198.47.23.249 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 fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 4179BFoU003395; Wed, 7 Feb 2024 03:11:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707297075; bh=8+z5AzK6gRUDQ16vqNk0y0fkfcURB4sVIOGrxpLSLVQ=; h=From:To:CC:Subject:Date; b=pFm0o0fG+mElxBrb5cYKgYBaajTfxN6chy8yBq4qp6SAx/+VCq4LApq0ul6e8FvRT DmQsmFBnmCvrceGBbFY3mQMGameS8aTEvxqEJkLWgZX/OOjAQ/S1C8QlGlIMnBiprs 3QZ4c3CJPorGxaTyWOKFHqJ24wnAOQL57g+3uOyI= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4179BFmt115582 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 7 Feb 2024 03:11:15 -0600 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 7 Feb 2024 03:11:15 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE115.ent.ti.com (10.64.6.36) 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; Wed, 7 Feb 2024 03:11:15 -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 4179BBeQ034511; Wed, 7 Feb 2024 03:11:12 -0600 From: Udit Kumar <u-kumar1@ti.com> To: <nm@ti.com>, <kristo@kernel.org>, <ssantosh@kernel.org>, <chandru@ti.com>, <rishabh@ti.com>, <kamlesh@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 v3] clk: keystone: sci-clk: Adding support for non contiguous clocks Date: Wed, 7 Feb 2024 14:41:00 +0530 Message-ID: <20240207091100.4001428-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: 1790230761907591768 X-GMAIL-MSGID: 1790230761907591768 |
Series |
[v3] clk: keystone: sci-clk: Adding support for non contiguous clocks
|
|
Commit Message
Kumar, Udit
Feb. 7, 2024, 9:11 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 v3
- instead of get_freq, is_auto API is used to check validilty of clock
- Address comments of v2, to have preindex increment
Link to v2 https://lore.kernel.org/all/20240206104357.3803517-1-u-kumar1@ti.com/
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 v3
https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9#file-v3
Line 2586
drivers/clk/keystone/sci-clk.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Comments
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> > --- > Changelog > Changes in v3 > - instead of get_freq, is_auto API is used to check validilty of clock > - Address comments of v2, to have preindex increment > Link to v2 https://lore.kernel.org/all/20240206104357.3803517-1-u-kumar1@ti.com/ > > 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 v3 > https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9#file-v3 > Line 2586 > > > 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..31b7df05d7bb 100644 > --- a/drivers/clk/keystone/sci-clk.c > +++ b/drivers/clk/keystone/sci-clk.c > @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > struct sci_clk *sci_clk, *prev; > int num_clks = 0; > int num_parents; > + bool state; > int clk_id; > const char * const clk_names[] = { > "clocks", "assigned-clocks", "assigned-clock-parents", NULL > @@ -583,16 +584,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > num_parents = 255; > } > > - clk_id = args.args[1] + 1; > + clk_id = args.args[1]; > > while (num_parents--) { > + /* Check if this clock id is valid */ > + ret = provider->ops->is_auto(provider->sci, > + sci_clk->dev_id, ++clk_id, &state); > + > + 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; > sci_clk->provider = provider; > list_add_tail(&sci_clk->node, &clks); > Looks good to me. Reviewed-by: Kamlesh Gurudasani <kamlesh@ti.com> > -- > 2.34.1
On 14:41-20240207, 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 v3 > - instead of get_freq, is_auto API is used to check validilty of clock > - Address comments of v2, to have preindex increment > Link to v2 https://lore.kernel.org/all/20240206104357.3803517-1-u-kumar1@ti.com/ > > 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 v3 > https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9#file-v3 > Line 2586 > > > 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..31b7df05d7bb 100644 > --- a/drivers/clk/keystone/sci-clk.c > +++ b/drivers/clk/keystone/sci-clk.c > @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > struct sci_clk *sci_clk, *prev; > int num_clks = 0; > int num_parents; > + bool state; > int clk_id; > const char * const clk_names[] = { > "clocks", "assigned-clocks", "assigned-clock-parents", NULL > @@ -583,16 +584,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > num_parents = 255; > } > > - clk_id = args.args[1] + 1; > + clk_id = args.args[1]; > > while (num_parents--) { > + /* Check if this clock id is valid */ > + ret = provider->ops->is_auto(provider->sci, > + sci_clk->dev_id, ++clk_id, &state); A bit too nice coding ;) => I had been confused momentarily by clk_id = args.args[1] change just above till I saw that you are pre-incrementing clk_id - Is there a harm in leaving the original clk_id increment logic alone (it was much simpler to read up)? > + > + 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; > sci_clk->provider = provider; > list_add_tail(&sci_clk->node, &clks); > > -- > 2.34.1 >
Nishanth Menon <nm@ti.com> writes: > > A bit too nice coding ;) => I had been confused momentarily by clk_id = args.args[1] > change just above till I saw that you are pre-incrementing > clk_id - Is there a harm in leaving the original clk_id increment logic > alone (it was much simpler to read up)? > Personlly, I think this is simpler as this keeps everything related to parents inside while loop and increment only at one place. The other logic will have increment inside condition and also at 2 other places. Let's Udit take a call. Kamlesh
Hi Nishanth, On 2/7/2024 6:24 PM, Nishanth Menon wrote: > On 14:41-20240207, 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 v3 >> - instead of get_freq, is_auto API is used to check validilty of clock >> - Address comments of v2, to have preindex increment >> Link to v2 https://lore.kernel.org/all/20240206104357.3803517-1-u-kumar1@ti.com/ >> >> 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 v3 >> https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9#file-v3 >> Line 2586 >> >> >> 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..31b7df05d7bb 100644 >> --- a/drivers/clk/keystone/sci-clk.c >> +++ b/drivers/clk/keystone/sci-clk.c >> @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) >> struct sci_clk *sci_clk, *prev; >> int num_clks = 0; >> int num_parents; >> [..] /* Check if this clock id is valid */ >> + ret = provider->ops->is_auto(provider->sci, >> + sci_clk->dev_id, ++clk_id, &state); > A bit too nice coding ;) => I had been confused momentarily by clk_id = args.args[1] > change just above till I saw that you are pre-incrementing > clk_id - Is there a harm in leaving the original clk_id increment logic > alone (it was much simpler to read up)? No warm in using original code but want to avoid, two statement for increment in case of failure and success. Let me know, if i need to add few comments around this or if you think, code is confusing I can move to original one >> + >> + 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; >> sci_clk->provider = provider; >> list_add_tail(&sci_clk->node, &clks); >> >> -- >> 2.34.1 >>
On 19:53-20240207, Kumar, Udit wrote: > Hi Nishanth, > > On 2/7/2024 6:24 PM, Nishanth Menon wrote: > > On 14:41-20240207, 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 v3 > > > - instead of get_freq, is_auto API is used to check validilty of clock > > > - Address comments of v2, to have preindex increment > > > Link to v2 https://lore.kernel.org/all/20240206104357.3803517-1-u-kumar1@ti.com/ > > > > > > 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 v3 > > > https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9#file-v3 > > > Line 2586 > > > > > > > > > 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..31b7df05d7bb 100644 > > > --- a/drivers/clk/keystone/sci-clk.c > > > +++ b/drivers/clk/keystone/sci-clk.c > > > @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > > > struct sci_clk *sci_clk, *prev; > > > int num_clks = 0; > > > int num_parents; > > > [..] /* Check if this clock id is valid */ > > > + ret = provider->ops->is_auto(provider->sci, > > > + sci_clk->dev_id, ++clk_id, &state); > > A bit too nice coding ;) => I had been confused momentarily by clk_id = args.args[1] > > change just above till I saw that you are pre-incrementing > > clk_id - Is there a harm in leaving the original clk_id increment logic > > alone (it was much simpler to read up)? > > No warm in using original code but want to avoid, two statement for > increment in case of failure and success. > > Let me know, if i need to add few comments around this > > or if you think, code is confusing I can move to original one Yes, please drop the un-necessary changes. In this case, original increment code should work just fine.
Nishanth Menon <nm@ti.com> writes: > On 19:53-20240207, Kumar, Udit wrote: >> Hi Nishanth, >> >> On 2/7/2024 6:24 PM, Nishanth Menon wrote: >> > On 14:41-20240207, 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 v3 >> > > - instead of get_freq, is_auto API is used to check validilty of clock >> > > - Address comments of v2, to have preindex increment >> > > Link to v2 https://lore.kernel.org/all/20240206104357.3803517-1-u-kumar1@ti.com/ >> > > >> > > 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 v3 >> > > https://gist.github.com/uditkumarti/94e3e28d62282fd708dbfe37435ce1d9#file-v3 >> > > Line 2586 >> > > >> > > >> > > 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..31b7df05d7bb 100644 >> > > --- a/drivers/clk/keystone/sci-clk.c >> > > +++ b/drivers/clk/keystone/sci-clk.c >> > > @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) >> > > struct sci_clk *sci_clk, *prev; >> > > int num_clks = 0; >> > > int num_parents; >> > > [..] /* Check if this clock id is valid */ >> > > + ret = provider->ops->is_auto(provider->sci, >> > > + sci_clk->dev_id, ++clk_id, &state); >> > A bit too nice coding ;) => I had been confused momentarily by clk_id = args.args[1] >> > change just above till I saw that you are pre-incrementing >> > clk_id - Is there a harm in leaving the original clk_id increment logic >> > alone (it was much simpler to read up)? >> >> No warm in using original code but want to avoid, two statement for >> increment in case of failure and success. >> >> Let me know, if i need to add few comments around this >> >> or if you think, code is confusing I can move to original one > > Yes, please drop the un-necessary changes. In this case, original > increment code should work just fine. I wouldn't call it unnecessary, If I have to track increment/addition at 3 different places just to understand the loop, it is hard. On other hand, pre-increment code is solving the problem by having increment at only one place(easier to track). On the plus side, every clk_id belonging to parent is handled completely inside the loop. For a new person looking at this code, pre-increment code would be actually easier to undertsand. Also, Udit feels the same. Would you please explain why do you think the original increment code make more sense? It's not simple to understand or track, that's for sure. Kamlesh >\ > -- > Regards, > Nishanth Menon > Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
On 00:25-20240210, Kamlesh Gurudasani wrote: > >> > > > >> > > diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c > >> > > index 35fe197dd303..31b7df05d7bb 100644 > >> > > --- a/drivers/clk/keystone/sci-clk.c > >> > > +++ b/drivers/clk/keystone/sci-clk.c > >> > > @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) > >> > > struct sci_clk *sci_clk, *prev; > >> > > int num_clks = 0; > >> > > int num_parents; > >> > > [..] /* Check if this clock id is valid */ > >> > > + ret = provider->ops->is_auto(provider->sci, > >> > > + sci_clk->dev_id, ++clk_id, &state); > >> > A bit too nice coding ;) => I had been confused momentarily by clk_id = args.args[1] > >> > change just above till I saw that you are pre-incrementing > >> > clk_id - Is there a harm in leaving the original clk_id increment logic > >> > alone (it was much simpler to read up)? > >> > >> No warm in using original code but want to avoid, two statement for > >> increment in case of failure and success. > >> > >> Let me know, if i need to add few comments around this > >> > >> or if you think, code is confusing I can move to original one > > > > Yes, please drop the un-necessary changes. In this case, original > > increment code should work just fine. > I wouldn't call it unnecessary, If I have to track increment/addition at > 3 different places just to understand the loop, it is hard. On other > hand, pre-increment code is solving the problem by having increment at > only one place(easier to track). On the plus side, every clk_id belonging to > parent is handled completely inside the loop. > > For a new person looking at this code, pre-increment code would be > actually easier to undertsand. > > Also, Udit feels the same. > > Would you please explain why do you think the original increment code > make more sense? It's not simple to understand or track, that's for sure. the context of the fix is the is_auto call to know what parent options are valid or not. Do the absolutely what is necessary in the change. if you want to beautify etc, move it to some other patch and debate about it. So, this is un-necessary change in this patch.
Nishanth Menon <nm@ti.com> writes: > On 00:25-20240210, Kamlesh Gurudasani wrote: >> >> > > >> >> > > diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c >> >> > > index 35fe197dd303..31b7df05d7bb 100644 >> >> > > --- a/drivers/clk/keystone/sci-clk.c >> >> > > +++ b/drivers/clk/keystone/sci-clk.c >> >> > > @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) >> >> > > struct sci_clk *sci_clk, *prev; >> >> > > int num_clks = 0; >> >> > > int num_parents; >> >> > > [..] /* Check if this clock id is valid */ >> >> > > + ret = provider->ops->is_auto(provider->sci, >> >> > > + sci_clk->dev_id, ++clk_id, &state); >> >> > A bit too nice coding ;) => I had been confused momentarily by clk_id = args.args[1] >> >> > change just above till I saw that you are pre-incrementing >> >> > clk_id - Is there a harm in leaving the original clk_id increment logic >> >> > alone (it was much simpler to read up)? >> >> >> >> No warm in using original code but want to avoid, two statement for >> >> increment in case of failure and success. >> >> >> >> Let me know, if i need to add few comments around this >> >> >> >> or if you think, code is confusing I can move to original one >> > >> > Yes, please drop the un-necessary changes. In this case, original >> > increment code should work just fine. >> I wouldn't call it unnecessary, If I have to track increment/addition at >> 3 different places just to understand the loop, it is hard. On other >> hand, pre-increment code is solving the problem by having increment at >> only one place(easier to track). On the plus side, every clk_id belonging to >> parent is handled completely inside the loop. >> >> For a new person looking at this code, pre-increment code would be >> actually easier to undertsand. >> >> Also, Udit feels the same. >> >> Would you please explain why do you think the original increment code >> make more sense? It's not simple to understand or track, that's for sure. > > the context of the fix is the is_auto call to know what parent options > are valid or not. Do the absolutely what is necessary in the change. if > you want to beautify etc, move it to some other patch and debate about > it. So, this is un-necessary change in this patch. The context of the fix i.e. handling non contiguous parents is making the loop logic complex. Before this patch, i.e. contiguous clock handling was simple. In this fix, we are solving the problem as well as keeping the loop simple. clk_id is basically the part of the same loop and it's affecting nothing but the loop count. This is not just beautification, this is also simplifying the logic and improving the readibility. If the patch can provide the solution and avoid the complexity, then I don't understand why we need a patch that introduce the complexity and another patch to solve the complexity. My original question below is still not answered so I guess there is no debate here actually. "Would you please explain why do you think the original increment code make more sense? It's not simple to understand or track, that's for sure." Kamlesh > > -- > Regards, > Nishanth Menon > Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
On Wed, Feb 07, 2024 at 02:41:00PM +0530, 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> no empty lines in between tags and only tags at the end of the commit message, this [0] reference needs to be before or moved to a `Link:` tag, whatever works best for you. Francesco
On 2/11/2024 9:24 PM, Francesco Dolcini wrote: > On Wed, Feb 07, 2024 at 02:41:00PM +0530, 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> > no empty lines in between tags and only tags at the end of the commit > message, this [0] reference needs to be before or moved to a `Link:` tag, > whatever works best for you. Thanks will below works ? [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 Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") Udit
On Mon, Feb 12, 2024 at 10:06:30AM +0530, Kumar, Udit wrote: > > On 2/11/2024 9:24 PM, Francesco Dolcini wrote: > > On Wed, Feb 07, 2024 at 02:41:00PM +0530, Udit Kumar wrote: > > > 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> > > no empty lines in between tags and only tags at the end of the commit > > message, this [0] reference needs to be before or moved to a `Link:` tag, > > whatever works best for you. > will below works ? No, it does not fullfil the expectation to have only tags at the end. > [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 > Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically > probing clocks")
diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 35fe197dd303..31b7df05d7bb 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -516,6 +516,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) struct sci_clk *sci_clk, *prev; int num_clks = 0; int num_parents; + bool state; int clk_id; const char * const clk_names[] = { "clocks", "assigned-clocks", "assigned-clock-parents", NULL @@ -583,16 +584,23 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) num_parents = 255; } - clk_id = args.args[1] + 1; + clk_id = args.args[1]; while (num_parents--) { + /* Check if this clock id is valid */ + ret = provider->ops->is_auto(provider->sci, + sci_clk->dev_id, ++clk_id, &state); + + 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; sci_clk->provider = provider; list_add_tail(&sci_clk->node, &clks);