89 lines
2.9 KiB
Diff
89 lines
2.9 KiB
Diff
|
From b9d89fb53b5361df87974a223cb4b423a647bc2f Mon Sep 17 00:00:00 2001
|
||
|
From: Vadim Pasternak <vadimp@nvidia.com>
|
||
|
Date: Thu, 24 Aug 2023 11:47:54 +0000
|
||
|
Subject: [PATCH] platform/mellanox: mlxreg-hotplug: Add support for new flavor
|
||
|
of capability registers
|
||
|
X-NVConfidentiality: public
|
||
|
|
||
|
Hotplug platform data is common across the various systems, while
|
||
|
hotplug driver should be able to configure only the instances relevant
|
||
|
to specific system.
|
||
|
|
||
|
For example, platform hoptplug data might contain descriptions for fan1,
|
||
|
fan2, ..., fan{n}, while some systems equipped with all 'n' fans,
|
||
|
others with less.
|
||
|
Same for power units, power controllers, ASICs and so on.
|
||
|
|
||
|
For detection of the real number of equipped devices capability
|
||
|
registers are used.
|
||
|
These registers used to indicate presence of hotplug devices through
|
||
|
the bitmap.
|
||
|
|
||
|
For some new big modular systems, these registers will provide presence
|
||
|
by counters.
|
||
|
|
||
|
Use slot parameter to determine whether capability register contains
|
||
|
bitmask or counter.
|
||
|
|
||
|
Some 'capability' registers can be shared between different resources.
|
||
|
Use fields 'capability_bit' and 'capability_mask' for getting only
|
||
|
relevant capability bits.
|
||
|
|
||
|
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
|
||
|
Reviewed-by: Felix Radensky <fradensky@nvidia.com>
|
||
|
---
|
||
|
drivers/platform/mellanox/mlxreg-hotplug.c | 23 +++++++++++++++++++++--
|
||
|
1 file changed, 21 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
|
||
|
index c5abedd35..3737af0d3 100644
|
||
|
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
|
||
|
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
|
||
|
@@ -275,6 +275,13 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
|
||
|
if (ret)
|
||
|
return ret;
|
||
|
|
||
|
+ if (!regval)
|
||
|
+ continue;
|
||
|
+
|
||
|
+ /* Remove non-relevant bits. */
|
||
|
+ if (item->capability_mask)
|
||
|
+ regval = rol32(regval & item->capability_mask,
|
||
|
+ item->capability_bit);
|
||
|
item->mask = GENMASK((regval & item->mask) - 1, 0);
|
||
|
}
|
||
|
|
||
|
@@ -295,7 +302,19 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
|
||
|
if (ret)
|
||
|
return ret;
|
||
|
|
||
|
- if (!(regval & data->bit)) {
|
||
|
+ /*
|
||
|
+ * In case slot field is provided, capability
|
||
|
+ * register contains counter, otherwise bitmask.
|
||
|
+ * Skip non-relevant entries if slot set and
|
||
|
+ * exceeds counter. Othewise validate entry by
|
||
|
+ * matching bitmask.
|
||
|
+ */
|
||
|
+ if (data->capability_mask)
|
||
|
+ regval = rol32(regval & data->capability_mask,
|
||
|
+ data->capability_bit);
|
||
|
+ if (data->slot > regval) {
|
||
|
+ break;
|
||
|
+ } else if (!(regval & data->bit) && !data->slot) {
|
||
|
data++;
|
||
|
continue;
|
||
|
}
|
||
|
@@ -626,7 +645,7 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv)
|
||
|
if (ret)
|
||
|
goto out;
|
||
|
|
||
|
- if (!(regval & data->bit))
|
||
|
+ if (!(regval & data->bit) && !data->slot)
|
||
|
item->mask &= ~BIT(j);
|
||
|
}
|
||
|
}
|
||
|
--
|
||
|
2.14.1
|
||
|
|