Skip to content

Commit 0996bd1

Browse files
committed
habanalabs: display card name as sensors header
To allow the user to use a custom file for the HWMON lm-sensors library per card type, the driver needs to register the HWMON sensors with the specific card type name. The card name is supplied by the F/W running on the device. If the F/W is old and doesn't supply a card name, a default card name is displayed as the sensors group name. Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com> Reviewed-by: Omer Shpigelman <oshpigelman@habana.ai>
1 parent e973076 commit 0996bd1

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎drivers/misc/habanalabs/goya/goya.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4961,6 +4961,10 @@ int goya_armcp_info_get(struct hl_device *hdev)
49614961
prop->dram_end_address = prop->dram_base_address + dram_size;
49624962
}
49634963

4964+
if (!strlen(prop->armcp_info.card_name))
4965+
strncpy(prop->armcp_info.card_name, GOYA_DEFAULT_CARD_NAME,
4966+
CARD_NAME_MAX_LEN);
4967+
49644968
return 0;
49654969
}
49664970

‎drivers/misc/habanalabs/goya/goyaP.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555

5656
#define DRAM_PHYS_DEFAULT_SIZE 0x100000000ull /* 4GB */
5757

58+
#define GOYA_DEFAULT_CARD_NAME "HL1000"
59+
5860
/* DRAM Memory Map */
5961

6062
#define CPU_FW_IMAGE_SIZE 0x10000000 /* 256MB */

‎drivers/misc/habanalabs/hwmon.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
421421
int hl_hwmon_init(struct hl_device *hdev)
422422
{
423423
struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev;
424+
struct asic_fixed_properties *prop = &hdev->asic_prop;
424425
int rc;
425426

426427
if ((hdev->hwmon_initialized) || !(hdev->fw_loading))
@@ -430,7 +431,8 @@ int hl_hwmon_init(struct hl_device *hdev)
430431
hdev->hl_chip_info->ops = &hl_hwmon_ops;
431432

432433
hdev->hwmon_dev = hwmon_device_register_with_info(dev,
433-
"habanalabs", hdev, hdev->hl_chip_info, NULL);
434+
prop->armcp_info.card_name, hdev,
435+
hdev->hl_chip_info, NULL);
434436
if (IS_ERR(hdev->hwmon_dev)) {
435437
rc = PTR_ERR(hdev->hwmon_dev);
436438
dev_err(hdev->dev,

‎drivers/misc/habanalabs/include/armcp_if.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0
22
*
3-
* Copyright 2016-2018 HabanaLabs, Ltd.
3+
* Copyright 2016-2019 HabanaLabs, Ltd.
44
* All Rights Reserved.
55
*
66
*/
@@ -310,6 +310,7 @@ struct eq_generic_event {
310310
* ArmCP info
311311
*/
312312

313+
#define CARD_NAME_MAX_LEN 16
313314
#define VERSION_MAX_LEN 128
314315
#define ARMCP_MAX_SENSORS 128
315316

@@ -318,6 +319,19 @@ struct armcp_sensor {
318319
__le32 flags;
319320
};
320321

322+
/**
323+
* struct armcp_info - host driver's necessary info from ArmCP.
324+
* @sensors: available sensors description.
325+
* @kernel_version: ArmCP linux kernel version.
326+
* @reserved: reserved field.
327+
* @cpld_version: CPLD programmed F/W version.
328+
* @infineon_version: Infineon main DC-DC version.
329+
* @fuse_version: silicon production FUSE information.
330+
* @thermal_version: thermald S/W version.
331+
* @armcp_version: ArmCP S/W version.
332+
* @dram_size: available DRAM size.
333+
* @card_name: card name that will be displayed in HWMON subsystem on the host
334+
*/
321335
struct armcp_info {
322336
struct armcp_sensor sensors[ARMCP_MAX_SENSORS];
323337
__u8 kernel_version[VERSION_MAX_LEN];
@@ -328,6 +342,7 @@ struct armcp_info {
328342
__u8 thermal_version[VERSION_MAX_LEN];
329343
__u8 armcp_version[VERSION_MAX_LEN];
330344
__le64 dram_size;
345+
char card_name[CARD_NAME_MAX_LEN];
331346
};
332347

333348
#endif /* ARMCP_IF_H */

0 commit comments

Comments
 (0)