From: Guenter Roeck <linux@roeck-us.net>
To: Mario Limonciello <mario.limonciello@amd.com>,
Clemens Ladisch <clemens@ladisch.de>
Cc: linux-hwmon@vger.kernel.org,
Gabriel Craciunescu <nix.or.die@googlemail.com>,
Wei Huang <wei.huang2@amd.com>
Subject: Re: [PATCH 4/6] hwmon: (k10temp): Show errors failing to read
Date: Thu, 26 Aug 2021 12:50:15 -0700 [thread overview]
Message-ID: <748dd3ab-2659-f4e5-eec2-baed323fd183@roeck-us.net> (raw)
In-Reply-To: <20210826184057.26428-5-mario.limonciello@amd.com>
On 8/26/21 11:40 AM, Mario Limonciello wrote:
> Enabling Yellow Carp in past commit was initially not working "properly"
> because extra IDs were needed, but this wasn't obvious because fail values
> from `amd_smn_read` were ignored.
> If errors are found, show a kernel warning.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/hwmon/k10temp.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
> index 5c1aebf7a56d..41d9c0c0a1f1 100644
> --- a/drivers/hwmon/k10temp.c
> +++ b/drivers/hwmon/k10temp.c
> @@ -164,8 +164,10 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval)
>
> static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval)
> {
> - amd_smn_read(amd_pci_dev_to_node_id(pdev),
> + int ret = amd_smn_read(amd_pci_dev_to_node_id(pdev),
> ZEN_REPORTED_TEMP_CTRL_BASE, regval);
> + if (ret)
> + dev_warn(&pdev->dev, "failed to read core temperature: %d\n", ret);
> }
It would be much better to change the code to return the error to the caller
(and thus to userspace) instead of polluting the kernel log and (presumably)
reporting a random value to userspace.
Guenter
>
> static long get_raw_temp(struct k10temp_data *data)
> @@ -212,6 +214,7 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
> {
> struct k10temp_data *data = dev_get_drvdata(dev);
> u32 regval;
> + int ret;
>
> switch (attr) {
> case hwmon_temp_input:
> @@ -227,10 +230,13 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
> *val = 0;
> break;
> case 2 ... 9: /* Tccd{1-8} */
> - amd_smn_read(amd_pci_dev_to_node_id(data->pdev),
> + ret = amd_smn_read(amd_pci_dev_to_node_id(data->pdev),
> ZEN_CCD_TEMP(data->ccd_offset, channel - 2),
> ®val);
> - *val = (regval & ZEN_CCD_TEMP_MASK) * 125 - 49000;
> + if (ret)
> + dev_warn(dev, "failed to read CCD temperature: %d\n", ret);
This is a static error. Just return the error to userspace, please,
and don't pollute the kernel log.
Guenter
> + else
> + *val = (regval & ZEN_CCD_TEMP_MASK) * 125 - 49000;
> break;
> default:
> return -EOPNOTSUPP;
>
next prev parent reply other threads:[~2021-08-26 19:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 18:40 [PATCH 0/6] Add k10temp support for more client APUs Mario Limonciello
2021-08-26 18:40 ` [PATCH 1/6] hwmon: (k10temp): Add additional missing Zen2 and Zen3 APUs Mario Limonciello
2021-08-26 18:40 ` [PATCH 2/6] x86/amd_nb: Rename PCI_DEVICE_ID_AMD_19H_DF_F3 to match specific model Mario Limonciello
2021-08-26 20:07 ` Guenter Roeck
2021-08-26 18:40 ` [PATCH 3/6] hwmon: (k10temp): Rework the temperature offset calculation Mario Limonciello
2021-08-26 20:02 ` Guenter Roeck
2021-08-26 18:40 ` [PATCH 4/6] hwmon: (k10temp): Show errors failing to read Mario Limonciello
2021-08-26 19:50 ` Guenter Roeck [this message]
2021-08-26 18:40 ` [PATCH 5/6] hwmon: (k10temp): Don't show Tdie for all Zen/Zen2/Zen3 CPU/APU Mario Limonciello
2021-08-26 18:40 ` [PATCH 6/6] hwmon: (k10temp): Add support for yellow carp Mario Limonciello
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=748dd3ab-2659-f4e5-eec2-baed323fd183@roeck-us.net \
--to=linux@roeck-us.net \
--cc=clemens@ladisch.de \
--cc=linux-hwmon@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=nix.or.die@googlemail.com \
--cc=wei.huang2@amd.com \
/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 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).