Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp744418ybl; Fri, 30 Aug 2019 06:35:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUiVScYexJ9TEP5cE7ch1Z41AyLHUot8teghtd4NUUP/dKLM6vOTCxpk0aiudp3sPjcD/a X-Received: by 2002:a17:902:2b81:: with SMTP id l1mr15757123plb.107.1567172127245; Fri, 30 Aug 2019 06:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567172127; cv=none; d=google.com; s=arc-20160816; b=edNaNOKWy4k7hTFCyAz97lZfak6ilhfHU7DpK1qN2evWnRUJHXQ4Ry3mKacxqPKLBm WGtnoSQRNmvJxcmh4syce80Wlj/VdGMvvIXsVBabdUXQPiUAoo0pS2+oclGJoQgBfQ8Y Tr+APNqiqe+NdTux7yCH4Llfw/l/5iqaCJG/p6jV2Yk1yHYFEWyx6aXJTwGzreCrNfQg yIuS4X8tg+b7kH5G3BPly9yQiNAaW4W6uzdYzUWjHVOppmsdn0672WDgaUE0OfflaVHC qKnbxLtTVdyujR5LM3LmBzEh7vmqpOTgyBIPRl1c/DIvFBv7s8YVS7RF0UzkVahXPhQi FXrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=F9xpA9YEFObwvI8dY+JY+1p/cXOMcHmHG8GrzDw/c3k=; b=uxzS6bFoJh98rj9CudTeHjk4PjPMk7iG2uzBPkU1sdl10OaIXsjrbKvBxK7/uXuLi+ AOzKVizZ/OWM0yiAeCNj+zqcYXC4AlXv11dzz8pT3OdhagoVX/JkPxpJQLe3841Lh/Q0 QU2cUU/xmzmrV9dwDj+8Wp3Ti2ZNo4C6YuHWkEhEj3XkOHcQsr+m3PyToE6tfkblHctk 7JD2Inx41QEorYvGSpJHP4bAoyx2rKDWOBlOtw94FCH2a1xaEDCV39X8DNwNbNw26pmT EFtLeKW7zXSArxDT9CghMEDFvdrpZ3OEG+uyZcezYzA7jdWpbxxYLLg6MnE8qh4NyH0B THzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YJzO+Iif; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k144si5907241pfd.34.2019.08.30.06.35.10; Fri, 30 Aug 2019 06:35:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YJzO+Iif; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727781AbfH3NeR (ORCPT + 99 others); Fri, 30 Aug 2019 09:34:17 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40906 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727135AbfH3NeR (ORCPT ); Fri, 30 Aug 2019 09:34:17 -0400 Received: by mail-wm1-f68.google.com with SMTP id t9so7465866wmi.5 for ; Fri, 30 Aug 2019 06:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=F9xpA9YEFObwvI8dY+JY+1p/cXOMcHmHG8GrzDw/c3k=; b=YJzO+Iif88RxSjWuEZ7mu5uUV3EZWtpDGnJYlB6iuTBOnWHHBMker+JAi2gZ7QOFnS RIhJp6RNKIq3l8TJLMSwXRcm87ribtTozWuMhtf8fmSQz8kQpqI29sT8z2WaQngbr6Ta +bvOSPJb8+aQgzsvdG+DTxfwiJwj99VNTl+f8f2uT21GgzHJR8HjQ8TajJWbKfthcZce I/6QZw4SN9wWAnM+ME5zLun9tba0wMlW9aFlzUuwKRBu6PTaHoDuDikbXShaHpwniF/y RSOP/LGyign6LiF6VSzzW7pwqiNGJabWwFgETYQwJkuK1XiCD2XUMmMm6a8jhYGsuWyH e9ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=F9xpA9YEFObwvI8dY+JY+1p/cXOMcHmHG8GrzDw/c3k=; b=ULhUP0cCHsMP47WmJfS424zfeRPI0SXs0qom/FZu0N6vwJxFWZGyIxX/pagU53ieqy kb0E2iqP0jM09b/7EJtnIVaFrOklAyspGsq3srQiIGscKIeveoFGq1ju16e3C05jxfm/ FsnKY1oZSkEYCk13s/m+9QCsitJY/BXLKDfWCLhT+HM2rSUdbi/WTwIHvoVF94IbTp2q rhDzyESuh475zMyICjpx+fs7Pg6hr2xpFkyXLTmo+lYv+EhPayJivaRiYwDnwvPnaczF XDjp054ziQrvRsxFlkjzGRMT+pP7Av2s+4mXtcKFh75k79RfbtnT8a16F7JQSSSzFsVJ BMuw== X-Gm-Message-State: APjAAAUjKCwywpJoJplgbhcttcBaWfMmhznhRF8meUQJvS0oEkknUrN1 7n3BqbAPol4AMfWstxfPgogRCBaZ X-Received: by 2002:a05:600c:34d:: with SMTP id u13mr5771336wmd.97.1567172054334; Fri, 30 Aug 2019 06:34:14 -0700 (PDT) Received: from ogabbay-VM.habana-labs.com ([31.154.190.6]) by smtp.gmail.com with ESMTPSA id x6sm9289624wrt.63.2019.08.30.06.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 06:34:13 -0700 (PDT) From: Oded Gabbay To: linux-kernel@vger.kernel.org, oshpigelman@habana.ai, ttayar@habana.ai Cc: gregkh@linuxfoundation.org Subject: [PATCH] habanalabs: display card name as sensors header Date: Fri, 30 Aug 2019 16:34:11 +0300 Message-Id: <20190830133411.24697-1-oded.gabbay@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/misc/habanalabs/goya/goya.c | 4 ++++ drivers/misc/habanalabs/goya/goyaP.h | 2 ++ drivers/misc/habanalabs/hwmon.c | 4 +++- drivers/misc/habanalabs/include/armcp_if.h | 17 ++++++++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index 1267ec75b19f..c88c2fea97b9 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -4961,6 +4961,10 @@ int goya_armcp_info_get(struct hl_device *hdev) prop->dram_end_address = prop->dram_base_address + dram_size; } + if (!strlen(prop->armcp_info.card_name)) + strncpy(prop->armcp_info.card_name, GOYA_DEFAULT_CARD_NAME, + CARD_NAME_MAX_LEN); + return 0; } diff --git a/drivers/misc/habanalabs/goya/goyaP.h b/drivers/misc/habanalabs/goya/goyaP.h index f830cfd5c04d..06da71e8d7ea 100644 --- a/drivers/misc/habanalabs/goya/goyaP.h +++ b/drivers/misc/habanalabs/goya/goyaP.h @@ -55,6 +55,8 @@ #define DRAM_PHYS_DEFAULT_SIZE 0x100000000ull /* 4GB */ +#define GOYA_DEFAULT_CARD_NAME "HL1000" + /* DRAM Memory Map */ #define CPU_FW_IMAGE_SIZE 0x10000000 /* 256MB */ diff --git a/drivers/misc/habanalabs/hwmon.c b/drivers/misc/habanalabs/hwmon.c index 6c60b901e375..7be4bace9b4f 100644 --- a/drivers/misc/habanalabs/hwmon.c +++ b/drivers/misc/habanalabs/hwmon.c @@ -421,6 +421,7 @@ void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, int hl_hwmon_init(struct hl_device *hdev) { struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev; + struct asic_fixed_properties *prop = &hdev->asic_prop; int rc; if ((hdev->hwmon_initialized) || !(hdev->fw_loading)) @@ -430,7 +431,8 @@ int hl_hwmon_init(struct hl_device *hdev) hdev->hl_chip_info->ops = &hl_hwmon_ops; hdev->hwmon_dev = hwmon_device_register_with_info(dev, - "habanalabs", hdev, hdev->hl_chip_info, NULL); + prop->armcp_info.card_name, hdev, + hdev->hl_chip_info, NULL); if (IS_ERR(hdev->hwmon_dev)) { rc = PTR_ERR(hdev->hwmon_dev); dev_err(hdev->dev, diff --git a/drivers/misc/habanalabs/include/armcp_if.h b/drivers/misc/habanalabs/include/armcp_if.h index 1f1e35e86d84..5565bce60bc9 100644 --- a/drivers/misc/habanalabs/include/armcp_if.h +++ b/drivers/misc/habanalabs/include/armcp_if.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 * - * Copyright 2016-2018 HabanaLabs, Ltd. + * Copyright 2016-2019 HabanaLabs, Ltd. * All Rights Reserved. * */ @@ -310,6 +310,7 @@ struct eq_generic_event { * ArmCP info */ +#define CARD_NAME_MAX_LEN 16 #define VERSION_MAX_LEN 128 #define ARMCP_MAX_SENSORS 128 @@ -318,6 +319,19 @@ struct armcp_sensor { __le32 flags; }; +/** + * struct armcp_info - host driver's necessary info from ArmCP. + * @sensors: available sensors description. + * @kernel_version: ArmCP linux kernel version. + * @reserved: reserved field. + * @cpld_version: CPLD programmed F/W version. + * @infineon_version: Infineon main DC-DC version. + * @fuse_version: silicon production FUSE information. + * @thermal_version: thermald S/W version. + * @armcp_version: ArmCP S/W version. + * @dram_size: available DRAM size. + * @card_name: card name that will be displayed in HWMON subsystem on the host + */ struct armcp_info { struct armcp_sensor sensors[ARMCP_MAX_SENSORS]; __u8 kernel_version[VERSION_MAX_LEN]; @@ -328,6 +342,7 @@ struct armcp_info { __u8 thermal_version[VERSION_MAX_LEN]; __u8 armcp_version[VERSION_MAX_LEN]; __le64 dram_size; + char card_name[CARD_NAME_MAX_LEN]; }; #endif /* ARMCP_IF_H */ -- 2.17.1