[PATCH v6 2/9] platform/mellanox mlxreg-hotplug: Add support for new flavor of capability registers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

New 'capability_mask' is introduced to allow sharing of same hoptplug
structure between different systems, equipped with different number of
hotplug devices. It contains superset mask for all systems sharing the
same configuration.

The purpose is to reduce unnecessary duplication of hoptplug structures
between different systems - same structure is to be used for example for
system equipped fir for 4, 6 or 8 fans.

For detection of the real number of equipped devices capability
registers are used. These registers used to indicate presence of
hotplug devices. On some systems presence is porvided 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.

Reviewed-by: Felix Radensky <fradensky@xxxxxxxxxx>
Signed-off-by: Vadim Pasternak <vadimp@xxxxxxxxxx>
---
v5->v6
Revised after comments pointed out by Ilpo:
- Drop 'capability_bit' from structure 'mlxreg_core_data', since it is
  not used.
---
 drivers/platform/mellanox/mlxreg-hotplug.c | 25 ++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index 0ce9fff1f7d4..93bdd20fd71a 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -274,6 +274,16 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
 			if (ret)
 				return ret;
 
+			if (!regval)
+				continue;
+
+			/*
+			 * Remove non-relevant bits: 'regval' contains bitmask of attributes or
+			 * number of attributtes, which should be handled. While 'capability mask'
+			 * is superset mask.
+			 */
+			if (item->capability_mask)
+				regval = (regval & item->capability_mask);
 			item->mask = GENMASK((regval & item->mask) - 1, 0);
 		}
 
@@ -294,7 +304,18 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
 				if (ret)
 					return ret;
 
-				if (!(regval & data->bit)) {
+				if (data->capability_mask)
+					regval = (regval & data->capability_mask);
+
+				/*
+				 * In case slot field is provided, capability register contains
+				 * counter, otherwise bitmask. Skip non-relevant entries if slot
+				 * is set and exceeds counter. Othewise validate entry by matching
+				 * bitmask.
+				 */
+				if (data->slot > regval)
+					break;
+				if (!(regval & data->bit) && !data->slot) {
 					data++;
 					continue;
 				}
@@ -611,7 +632,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.44.0





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux