Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, kuba@kernel.org,
Edwin Peer <edwin.peer@broadcom.com>
Subject: [PATCH net 2/6] bnxt_en: return proper error codes in bnxt_show_temp
Date: Sun, 20 Sep 2020 21:08:55 -0400 [thread overview]
Message-ID: <1600650539-19967-3-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1600650539-19967-1-git-send-email-michael.chan@broadcom.com>
From: Edwin Peer <edwin.peer@broadcom.com>
Returning "unknown" as a temperature value violates the hwmon interface
rules. Appropriate error codes should be returned via device_attribute
show instead. These will ultimately be propagated to the user via the
file system interface.
In addition to the corrected error handling, it is an even better idea to
not present the sensor in sysfs at all if it is known that the read will
definitely fail. Given that temp1_input is currently the only sensor
reported, ensure no hwmon registration if TEMP_MONITOR_QUERY is not
supported or if it will fail due to access permissions. Something smarter
may be needed if and when other sensors are added.
Fixes: 12cce90b934b ("bnxt_en: fix HWRM error when querying VF temperature")
Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 4af42b1..2865e24 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -9311,18 +9311,16 @@ static ssize_t bnxt_show_temp(struct device *dev,
struct hwrm_temp_monitor_query_output *resp;
struct bnxt *bp = dev_get_drvdata(dev);
u32 len = 0;
+ int rc;
resp = bp->hwrm_cmd_resp_addr;
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_TEMP_MONITOR_QUERY, -1, -1);
mutex_lock(&bp->hwrm_cmd_lock);
- if (!_hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT))
+ rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
+ if (!rc)
len = sprintf(buf, "%u\n", resp->temp * 1000); /* display millidegree */
mutex_unlock(&bp->hwrm_cmd_lock);
-
- if (len)
- return len;
-
- return sprintf(buf, "unknown\n");
+ return rc ?: len;
}
static SENSOR_DEVICE_ATTR(temp1_input, 0444, bnxt_show_temp, NULL, 0);
@@ -9342,7 +9340,16 @@ static void bnxt_hwmon_close(struct bnxt *bp)
static void bnxt_hwmon_open(struct bnxt *bp)
{
+ struct hwrm_temp_monitor_query_input req = {0};
struct pci_dev *pdev = bp->pdev;
+ int rc;
+
+ bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_TEMP_MONITOR_QUERY, -1, -1);
+ rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
+ if (rc == -EACCES || rc == -EOPNOTSUPP) {
+ bnxt_hwmon_close(bp);
+ return;
+ }
if (bp->hwmon_dev)
return;
--
1.8.3.1
next prev parent reply other threads:[~2020-09-21 1:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 1:08 [PATCH net 0/6] bnxt_en: Bug fixes Michael Chan
2020-09-21 1:08 ` [PATCH net 1/6] bnxt_en: Use memcpy to copy VPD field info Michael Chan
2020-09-21 1:08 ` Michael Chan [this message]
2020-09-21 1:08 ` [PATCH net 3/6] bnxt_en: Protect bnxt_set_eee() and bnxt_set_pauseparam() with mutex Michael Chan
2020-09-21 1:08 ` [PATCH net 4/6] bnxt_en: Return -EOPNOTSUPP for ETHTOOL_GREGS on VFs Michael Chan
2020-09-21 1:08 ` [PATCH net 5/6] bnxt_en: Fix HWRM_FUNC_QSTATS_EXT firmware call Michael Chan
2020-09-21 1:08 ` [PATCH net 6/6] bnxt_en: Fix wrong flag value passed to HWRM_PORT_QSTATS_EXT fw call Michael Chan
2020-09-21 2:05 ` [PATCH net 0/6] bnxt_en: Bug fixes David Miller
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=1600650539-19967-3-git-send-email-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=davem@davemloft.net \
--cc=edwin.peer@broadcom.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--subject='Re: [PATCH net 2/6] bnxt_en: return proper error codes in bnxt_show_temp' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).