* [PATCH 03/49] net: mellanox: fix open-coded for_each_set_bit()
[not found] <20220210224933.379149-1-yury.norov@gmail.com>
@ 2022-02-10 22:48 ` Yury Norov
2022-02-11 9:01 ` David Laight
2022-02-10 22:49 ` [PATCH 17/49] cpufreq: replace cpumask_weight with cpumask_empty where appropriate Yury Norov
1 sibling, 1 reply; 5+ messages in thread
From: Yury Norov @ 2022-02-10 22:48 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Sebastian Andrzej Siewior, Christophe JAILLET, Rikard Falkeborn,
linux-pm
Cc: Tariq Toukan
Mellanox driver has an open-coded for_each_set_bit(). Fix it.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx4/cmd.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index e10b7b04b894..c56d2194cbfc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -1994,21 +1994,16 @@ static void mlx4_allocate_port_vpps(struct mlx4_dev *dev, int port)
static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
{
- int port, err;
+ int p, port, err;
struct mlx4_vport_state *vp_admin;
struct mlx4_vport_oper_state *vp_oper;
struct mlx4_slave_state *slave_state =
&priv->mfunc.master.slave_state[slave];
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
&priv->dev, slave);
- int min_port = find_first_bit(actv_ports.ports,
- priv->dev.caps.num_ports) + 1;
- int max_port = min_port - 1 +
- bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
- for (port = min_port; port <= max_port; port++) {
- if (!test_bit(port - 1, actv_ports.ports))
- continue;
+ for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
+ port = p + 1;
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
priv->mfunc.master.vf_admin[slave].enable_smi[port];
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
@@ -2063,19 +2058,13 @@ static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
static void mlx4_master_deactivate_admin_state(struct mlx4_priv *priv, int slave)
{
- int port;
+ int p, port;
struct mlx4_vport_oper_state *vp_oper;
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
&priv->dev, slave);
- int min_port = find_first_bit(actv_ports.ports,
- priv->dev.caps.num_ports) + 1;
- int max_port = min_port - 1 +
- bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
-
- for (port = min_port; port <= max_port; port++) {
- if (!test_bit(port - 1, actv_ports.ports))
- continue;
+ for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
+ port = p + 1;
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
MLX4_VF_SMI_DISABLED;
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 17/49] cpufreq: replace cpumask_weight with cpumask_empty where appropriate
[not found] <20220210224933.379149-1-yury.norov@gmail.com>
2022-02-10 22:48 ` [PATCH 03/49] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
@ 2022-02-10 22:49 ` Yury Norov
2022-02-11 4:30 ` Viresh Kumar
1 sibling, 1 reply; 5+ messages in thread
From: Yury Norov @ 2022-02-10 22:49 UTC (permalink / raw)
To: Yury Norov, Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Andy Gross, Bjorn Andersson, Rafael J. Wysocki, Viresh Kumar,
Sudeep Holla, Cristian Marussi, linux-arm-msm, linux-pm,
linux-arm-kernel
drivers/cpufreq calls cpumask_weight() to check if any bit of a given
cpumask is set. We can do it more efficiently with cpumask_empty() because
cpumask_empty() stops traversing the cpumask as soon as it finds first set
bit, while cpumask_weight() counts all bits unconditionally.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> (for SCMI cpufreq driver)
---
drivers/cpufreq/qcom-cpufreq-hw.c | 2 +-
drivers/cpufreq/scmi-cpufreq.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 05f3d7876e44..95a0c57ab5bb 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -482,7 +482,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
}
qcom_get_related_cpus(index, policy->cpus);
- if (!cpumask_weight(policy->cpus)) {
+ if (cpumask_empty(policy->cpus)) {
dev_err(dev, "Domain-%d failed to get related CPUs\n", index);
ret = -ENOENT;
goto error;
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 1e0cd4d165f0..919fa6e3f462 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -154,7 +154,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
* table and opp-shared.
*/
ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->opp_shared_cpus);
- if (ret || !cpumask_weight(priv->opp_shared_cpus)) {
+ if (ret || cpumask_empty(priv->opp_shared_cpus)) {
/*
* Either opp-table is not set or no opp-shared was found.
* Use the CPU mask from SCMI to designate CPUs sharing an OPP
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 17/49] cpufreq: replace cpumask_weight with cpumask_empty where appropriate
2022-02-10 22:49 ` [PATCH 17/49] cpufreq: replace cpumask_weight with cpumask_empty where appropriate Yury Norov
@ 2022-02-11 4:30 ` Viresh Kumar
2022-02-11 5:17 ` Yury Norov
0 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2022-02-11 4:30 UTC (permalink / raw)
To: Yury Norov
Cc: Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Andy Gross, Bjorn Andersson, Rafael J. Wysocki, Sudeep Holla,
Cristian Marussi, linux-arm-msm, linux-pm, linux-arm-kernel
On 10-02-22, 14:49, Yury Norov wrote:
> drivers/cpufreq calls cpumask_weight() to check if any bit of a given
> cpumask is set. We can do it more efficiently with cpumask_empty() because
> cpumask_empty() stops traversing the cpumask as soon as it finds first set
> bit, while cpumask_weight() counts all bits unconditionally.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> (for SCMI cpufreq driver)
> ---
> drivers/cpufreq/qcom-cpufreq-hw.c | 2 +-
> drivers/cpufreq/scmi-cpufreq.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
I already applied it yesterday and replied to you as well. Did I miss
something ?
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 17/49] cpufreq: replace cpumask_weight with cpumask_empty where appropriate
2022-02-11 4:30 ` Viresh Kumar
@ 2022-02-11 5:17 ` Yury Norov
0 siblings, 0 replies; 5+ messages in thread
From: Yury Norov @ 2022-02-11 5:17 UTC (permalink / raw)
To: Viresh Kumar
Cc: Andy Shevchenko, Rasmus Villemoes, Andrew Morton,
Michał Mirosław, Greg Kroah-Hartman, Peter Zijlstra,
David Laight, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov, linux-kernel,
Andy Gross, Bjorn Andersson, Rafael J. Wysocki, Sudeep Holla,
Cristian Marussi, linux-arm-msm, linux-pm, linux-arm-kernel
On Fri, Feb 11, 2022 at 10:00:57AM +0530, Viresh Kumar wrote:
> On 10-02-22, 14:49, Yury Norov wrote:
> > drivers/cpufreq calls cpumask_weight() to check if any bit of a given
> > cpumask is set. We can do it more efficiently with cpumask_empty() because
> > cpumask_empty() stops traversing the cpumask as soon as it finds first set
> > bit, while cpumask_weight() counts all bits unconditionally.
> >
> > Signed-off-by: Yury Norov <yury.norov@gmail.com>
> > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> (for SCMI cpufreq driver)
> > ---
> > drivers/cpufreq/qcom-cpufreq-hw.c | 2 +-
> > drivers/cpufreq/scmi-cpufreq.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
>
> I already applied it yesterday and replied to you as well. Did I miss
> something ?
It appeared in next today after I prepared this series, that's why it
slipped through. Sorry for that. Please ignore this patch.
Thanks,
Yury
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 03/49] net: mellanox: fix open-coded for_each_set_bit()
2022-02-10 22:48 ` [PATCH 03/49] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
@ 2022-02-11 9:01 ` David Laight
0 siblings, 0 replies; 5+ messages in thread
From: David Laight @ 2022-02-11 9:01 UTC (permalink / raw)
To: 'Yury Norov', Andy Shevchenko, Rasmus Villemoes,
Andrew Morton, Michał Mirosław, Greg Kroah-Hartman,
Peter Zijlstra, Joe Perches, Dennis Zhou, Emil Renner Berthing,
Nicholas Piggin, Matti Vaittinen, Alexey Klimov,
linux-kernel@vger.kernel.org, Rafael J. Wysocki, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Sebastian Andrzej Siewior,
Christophe JAILLET, Rikard Falkeborn, linux-pm@vger.kernel.org
Cc: Tariq Toukan
From: Yury Norov
> Sent: 10 February 2022 22:49
>
> Mellanox driver has an open-coded for_each_set_bit(). Fix it.
>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/cmd.c | 23 ++++++-----------------
> 1 file changed, 6 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> index e10b7b04b894..c56d2194cbfc 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
> @@ -1994,21 +1994,16 @@ static void mlx4_allocate_port_vpps(struct mlx4_dev *dev, int port)
>
> static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
> {
> - int port, err;
> + int p, port, err;
> struct mlx4_vport_state *vp_admin;
> struct mlx4_vport_oper_state *vp_oper;
> struct mlx4_slave_state *slave_state =
> &priv->mfunc.master.slave_state[slave];
> struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
> &priv->dev, slave);
> - int min_port = find_first_bit(actv_ports.ports,
> - priv->dev.caps.num_ports) + 1;
> - int max_port = min_port - 1 +
> - bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
>
> - for (port = min_port; port <= max_port; port++) {
> - if (!test_bit(port - 1, actv_ports.ports))
> - continue;
> + for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
> + port = p + 1;
This is an 'interesting' change in behaviour, and looks like a bug fix.
Did anyone actually test the old code?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-11 9:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220210224933.379149-1-yury.norov@gmail.com>
2022-02-10 22:48 ` [PATCH 03/49] net: mellanox: fix open-coded for_each_set_bit() Yury Norov
2022-02-11 9:01 ` David Laight
2022-02-10 22:49 ` [PATCH 17/49] cpufreq: replace cpumask_weight with cpumask_empty where appropriate Yury Norov
2022-02-11 4:30 ` Viresh Kumar
2022-02-11 5:17 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox