All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vadim Pasternak <vadimp@nvidia.com>
To: <hdegoede@redhat.com>
Cc: <michaelsh@nvidia.com>, <crajank@nvidia.com>,
	<fradensky@nvidia.com>, <oleksandrs@nvidia.com>,
	<platform-driver-x86@vger.kernel.org>,
	"Vadim Pasternak" <vadimp@nvidia.com>
Subject: [PATCH v3 05/10] platform/mellanox: mlxreg-hotplug: Add support for new flavor of capability registers
Date: Thu, 16 Jan 2025 09:59:11 +0200	[thread overview]
Message-ID: <20250116075919.34270-6-vadimp@nvidia.com> (raw)
In-Reply-To: <20250116075919.34270-1-vadimp@nvidia.com>

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.

Reviewed-by: Felix Radensky <fradensky@nvidia.com>
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
v2->v3
Comments pointed out by Ilpo:
- Change rol32() to shift left.
---
 drivers/platform/mellanox/mlxreg-hotplug.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index 0ce9fff1f7d4..c525b8754d48 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -274,6 +274,12 @@ 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 = (regval & item->capability_mask) << item->capability_bit;
 			item->mask = GENMASK((regval & item->mask) - 1, 0);
 		}
 
@@ -294,7 +300,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 = (regval & item->capability_mask) <<
+						 item->capability_bit;
+				if (data->slot > regval) {
+					break;
+				} else if (!(regval & data->bit) && !data->slot) {
 					data++;
 					continue;
 				}
@@ -611,7 +629,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


  parent reply	other threads:[~2025-01-16  8:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16  7:59 [PATCH v3 00/10] platform/mellanox: Add support for new systems, amendments, relocate mlx-platform module Vadim Pasternak
2025-01-16  7:59 ` [PATCH v3 01/10] mellanox: Relocate mlx-platform driver Vadim Pasternak
2025-01-16  7:59 ` [PATCH v3 02/10] platform: mellanox: mlx-platform: Cosmetic changes Vadim Pasternak
2025-01-16  7:59 ` [PATCH v3 03/10] platform: mellanox: mlx-platform: Change register name Vadim Pasternak
2025-01-16  7:59 ` [PATCH v3 04/10] platform_data/mlxreg: Add capability bit and mask fields Vadim Pasternak
2025-01-16  7:59 ` Vadim Pasternak [this message]
2025-01-16  7:59 ` [PATCH v3 06/10] platform/mellanox: mlxreg-dpu: Add initial support for Nvidia DPU Vadim Pasternak
2025-01-17 16:58   ` Ilpo Järvinen
2025-01-23 11:12     ` Vadim Pasternak
2025-01-23 13:24       ` Ilpo Järvinen
2025-01-16  7:59 ` [PATCH v3 07/10] platform: mellanox: Introduce support of Nvidia smart switch Vadim Pasternak
2025-01-17 17:12   ` Ilpo Järvinen
2025-01-16  7:59 ` [PATCH v3 08/10] platform: mellanox: mlx-platform: Add support for new Nvidia system Vadim Pasternak
2025-01-16  7:59 ` [PATCH v3 09/10] platform: mellanox: nvsw-sn2200: Add support for new system flavour Vadim Pasternak
2025-01-16  7:59 ` [PATCH v3 10/10] Documentation/ABI: Add new attribute for mlxreg-io sysfs interfaces Vadim Pasternak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250116075919.34270-6-vadimp@nvidia.com \
    --to=vadimp@nvidia.com \
    --cc=crajank@nvidia.com \
    --cc=fradensky@nvidia.com \
    --cc=hdegoede@redhat.com \
    --cc=michaelsh@nvidia.com \
    --cc=oleksandrs@nvidia.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.