mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Yazen Ghannam <yazen.ghannam@amd.com>, x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, markgross@kernel.org,
	hdegoede@redhat.com, Shyam-sundar.S-k@amd.com,
	linux-edac@vger.kernel.org, clemens@ladisch.de,
	jdelvare@suse.com, linux-hwmon@vger.kernel.org,
	mario.limonciello@amd.com, babu.moger@amd.com
Subject: Re: [PATCH v2 5/6] hwmon: (k10temp) Define helper function to read CCD temp
Date: Thu, 15 Jun 2023 19:22:03 -0700	[thread overview]
Message-ID: <fa773f17-250f-d753-b15a-953efbe972ee@roeck-us.net> (raw)
In-Reply-To: <20230615160328.419610-6-yazen.ghannam@amd.com>

On 6/15/23 09:03, Yazen Ghannam wrote:
> The CCD temperature register is read in two places. These reads are done
> using an AMD SMN access, and a number of parameters are needed for the
> operation.
> 
> Move the SMN access and parameter gathering into a helper function in
> order to simply the code flow. This also has a benefit of centralizing
> the hardware register access in a single place in case fixes or special
> decoding is required.
> 
> Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
> Link:
> https://lore.kernel.org/r/20230516202430.4157216-6-yazen.ghannam@amd.com
> 
> v1->v2:
> * Address comments from Guenter.
> 
>   drivers/hwmon/k10temp.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
> index 70f7b77e6ece..dfbba8b72f43 100644
> --- a/drivers/hwmon/k10temp.c
> +++ b/drivers/hwmon/k10temp.c
> @@ -150,6 +150,13 @@ static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval)
>   		*regval = 0;
>   }
>   
> +static int read_ccd_temp_reg(struct k10temp_data *data, int ccd, u32 *regval)
> +{
> +	u16 node_id = amd_pci_dev_to_node_id(data->pdev);
> +
> +	return amd_smn_read(node_id, ZEN_CCD_TEMP(data->ccd_offset, ccd), regval);
> +}
> +
>   static long get_raw_temp(struct k10temp_data *data)
>   {
>   	u32 regval;
> @@ -215,9 +222,7 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
>   				*val = 0;
>   			break;
>   		case 2 ... 13:		/* Tccd{1-12} */
> -			ret = amd_smn_read(amd_pci_dev_to_node_id(data->pdev),
> -					   ZEN_CCD_TEMP(data->ccd_offset, channel - 2),
> -					   &regval);
> +			ret = read_ccd_temp_reg(data, channel - 2, &regval);
>   
>   			if (ret)
>   				return ret;
> @@ -389,8 +394,7 @@ static void k10temp_get_ccd_support(struct pci_dev *pdev,
>   		 * the register value. And this will incorrectly pass the TEMP_VALID
>   		 * bit check.
>   		 */
> -		if (amd_smn_read(amd_pci_dev_to_node_id(pdev),
> -				 ZEN_CCD_TEMP(data->ccd_offset, i), &regval))
> +		if (read_ccd_temp_reg(data, i, &regval))
>   			continue;
>   
>   		if (regval & ZEN_CCD_TEMP_VALID)


  reply	other threads:[~2023-06-16  2:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 16:03 [PATCH v2 0/6] Enhance AMD SMN Error Checking Yazen Ghannam
2023-06-15 16:03 ` [PATCH v2 1/6] EDAC/amd64: Remove unused register accesses Yazen Ghannam
2023-06-15 16:03 ` [PATCH v2 2/6] EDAC/amd64: Check return value of amd_smn_read() Yazen Ghannam
2023-06-15 16:03 ` [PATCH v2 3/6] hwmon: (k10temp) " Yazen Ghannam
2023-06-16  2:21   ` Guenter Roeck
2023-06-15 16:03 ` [PATCH v2 4/6] x86/amd_nb: Enhance SMN access error checking Yazen Ghannam
2023-06-15 16:03 ` [PATCH v2 5/6] hwmon: (k10temp) Define helper function to read CCD temp Yazen Ghannam
2023-06-16  2:22   ` Guenter Roeck [this message]
2023-06-15 16:03 ` [PATCH v2 6/6] hwmon: (k10temp) Reduce k10temp_get_ccd_support() parameters Yazen Ghannam
2023-06-19  2:42 ` [PATCH v2 0/6] Enhance AMD SMN Error Checking 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=fa773f17-250f-d753-b15a-953efbe972ee@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=babu.moger@amd.com \
    --cc=clemens@ladisch.de \
    --cc=hdegoede@redhat.com \
    --cc=jdelvare@suse.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=x86@kernel.org \
    --cc=yazen.ghannam@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

all inboxes | Powered by JetHome®