From patchwork Wed Sep 27 03:57:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13399863 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E885913AF0 for ; Wed, 27 Sep 2023 03:58:13 +0000 (UTC) Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E5C2009B for ; Tue, 26 Sep 2023 20:58:12 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-690d8c05784so7936556b3a.2 for ; Tue, 26 Sep 2023 20:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1695787092; x=1696391892; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=NbcD5QbJf/+Bo+NZ7PVbYwqdMqhmtUDrH5ej23aZEqA=; b=apW6IJVwTQmRkp2Zv1oC9QlWVb1PYBxJHx+LEE6S6aL3jRKj5ybLKECWtro4dR8TNY 7Ms4uZ0sKA8O4RpImkNjKUMUaLOL5N6uMzrssBQcmD6ry01c0R+At98ZtRpDOh2TUw8k cX55qiWFwUMl2PA0UCbuv9GE1MVjQ/Fi06lXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695787092; x=1696391892; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NbcD5QbJf/+Bo+NZ7PVbYwqdMqhmtUDrH5ej23aZEqA=; b=qh7DhobpZ3aroqK+VBR/F3Z0F6TLS8zBFI5cdkbyQDyVZn4cW+moiaGzgyHO4dzTws 7kgFAidbjod1vahGgY5qZeZHggWhZLHD1gZcYav4RNgvuOJ1+D6IcqGJGZqOsMec1LUc vr+kcVbMvG47icLLgxRR/wok6BuavRWNRHccxFP89z+UsWZ1HsuPQIwJJCf+mLsfKkO7 nH6f9lv9sTAN3V2oYhDNAtw2ouidVrGpAbEldZI+umTB65LobzyG+rdz74cF5dJx90DA lkZUOWZ0YRwLeb0N0JPyd0Qo7GqoWIhQ1b/zqApQ0srckNCP0FzQoin1swNBQoJIBBRP MIEw== X-Gm-Message-State: AOJu0YxpV6QwbReGScjKS9yKjaPimMMDMa9tHfEdfuCZ1J9u42GKT0g5 bae2LBoNRcNsYdyxvxIQK8EDqg== X-Google-Smtp-Source: AGHT+IHA08KsmXWFl3xsixFFapqLo4TLEDM6J72UUi6CsCCpdbPkn3971jMy+KLtFaAHOQjJxr1tvA== X-Received: by 2002:a05:6a20:3d90:b0:14c:a53c:498c with SMTP id s16-20020a056a203d9000b0014ca53c498cmr889406pzi.10.1695787091156; Tue, 26 Sep 2023 20:58:11 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id k67-20020a633d46000000b00577bc070c6bsm9736097pga.68.2023.09.26.20.58.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2023 20:58:10 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Kalesh AP , Andy Gospodarek Subject: [PATCH net-next v2 6/9] bnxt_en: Use non-standard attribute to expose shutdown temperature Date: Tue, 26 Sep 2023 20:57:31 -0700 Message-Id: <20230927035734.42816-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230927035734.42816-1-michael.chan@broadcom.com> References: <20230927035734.42816-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Kalesh AP Implement the sysfs attributes directly in the driver for shutdown threshold temperature and pass an extra attribute group to the hwmon core when registering the hwmon device. Link: https://lore.kernel.org/netdev/20230815045658.80494-12-michael.chan@broadcom.com/ Cc: Jean Delvare Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Reviewed-by: Andy Gospodarek Signed-off-by: Kalesh AP Signed-off-by: Michael Chan --- .../net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c index 6a2cad5cc159..6d36158df26e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c @@ -131,6 +131,57 @@ static const struct hwmon_chip_info bnxt_hwmon_chip_info = { .info = bnxt_hwmon_info, }; +static ssize_t temp1_shutdown_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct bnxt *bp = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%u\n", bp->shutdown_thresh_temp * 1000); +} + +static ssize_t temp1_shutdown_alarm_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct bnxt *bp = dev_get_drvdata(dev); + u8 temp; + int rc; + + rc = bnxt_hwrm_temp_query(bp, &temp); + if (rc) + return -EIO; + + return sysfs_emit(buf, "%u\n", temp >= bp->shutdown_thresh_temp); +} + +static DEVICE_ATTR_RO(temp1_shutdown); +static DEVICE_ATTR_RO(temp1_shutdown_alarm); + +static struct attribute *bnxt_temp_extra_attrs[] = { + &dev_attr_temp1_shutdown.attr, + &dev_attr_temp1_shutdown_alarm.attr, + NULL, +}; + +static umode_t bnxt_temp_extra_attrs_visible(struct kobject *kobj, + struct attribute *attr, int index) +{ + struct device *dev = kobj_to_dev(kobj); + struct bnxt *bp = dev_get_drvdata(dev); + + /* Shutdown temperature setting in NVM is optional */ + if (!(bp->fw_cap & BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED) || + !bp->shutdown_thresh_temp) + return 0; + + return attr->mode; +} + +static const struct attribute_group bnxt_temp_extra_group = { + .attrs = bnxt_temp_extra_attrs, + .is_visible = bnxt_temp_extra_attrs_visible, +}; +__ATTRIBUTE_GROUPS(bnxt_temp_extra); + void bnxt_hwmon_uninit(struct bnxt *bp) { if (bp->hwmon_dev) { @@ -156,7 +207,8 @@ void bnxt_hwmon_init(struct bnxt *bp) bp->hwmon_dev = hwmon_device_register_with_info(&pdev->dev, DRV_MODULE_NAME, bp, - &bnxt_hwmon_chip_info, NULL); + &bnxt_hwmon_chip_info, + bnxt_temp_extra_groups); if (IS_ERR(bp->hwmon_dev)) { bp->hwmon_dev = NULL; dev_warn(&pdev->dev, "Cannot register hwmon device\n");