From: Guenter Roeck <linux@roeck-us.net>
To: Iwona Winiarska <iwona.winiarska@intel.com>
Cc: linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devicetree@vger.kernel.org, linux-aspeed@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org,
linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org,
Rob Herring <robh+dt@kernel.org>, Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@aj.id.au>,
Jean Delvare <jdelvare@suse.com>, Arnd Bergmann <arnd@arndb.de>,
Olof Johansson <olof@lixom.net>, Jonathan Corbet <corbet@lwn.net>,
Borislav Petkov <bp@alien8.de>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Tony Luck <tony.luck@intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Randy Dunlap <rdunlap@infradead.org>,
Zev Weiss <zweiss@equinix.com>,
David Muller <d.mueller@elsoft.ch>,
Dave Hansen <dave.hansen@intel.com>,
Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
Subject: Re: [PATCH v4 11/13] hwmon: peci: Add dimmtemp driver
Date: Tue, 23 Nov 2021 07:56:08 -0800 [thread overview]
Message-ID: <20211123155608.GA2258206@roeck-us.net> (raw)
On Tue, Nov 23, 2021 at 03:07:04PM +0100, Iwona Winiarska wrote:
> Add peci-dimmtemp driver for Temperature Sensor on DIMM readings that
> are accessible via the processor PECI interface.
>
> The main use case for the driver (and PECI interface) is out-of-band
> management, where we're able to obtain thermal readings from an external
> entity connected with PECI, e.g. BMC on server platforms.
>
> Co-developed-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
> Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>
> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
[ ... ]
> +static int check_populated_dimms(struct peci_dimmtemp *priv)
> +{
> + int chan_rank_max = priv->gen_info->chan_rank_max;
> + int dimm_idx_max = priv->gen_info->dimm_idx_max;
> + u32 chan_rank_empty = 0;
> + u64 dimm_mask = 0;
> + int chan_rank, dimm_idx, ret;
> + u32 pcs;
> +
> + BUILD_BUG_ON(BITS_PER_TYPE(chan_rank_empty) < CHAN_RANK_MAX);
> + BUILD_BUG_ON(BITS_PER_TYPE(dimm_mask) < DIMM_NUMS_MAX);
> + if (chan_rank_max * dimm_idx_max > DIMM_NUMS_MAX) {
> + WARN_ONCE(1, "Unsupported number of DIMMs - chan_rank_max: %d, dimm_idx_max: %d",
> + chan_rank_max, dimm_idx_max);
> + return -EINVAL;
> + }
> +
> + for (chan_rank = 0; chan_rank < chan_rank_max; chan_rank++) {
> + ret = peci_pcs_read(priv->peci_dev, PECI_PCS_DDR_DIMM_TEMP, chan_rank, &pcs);
> + if (ret) {
> + /*
> + * Overall, we expect either success or -EINVAL in
> + * order to determine whether DIMM is populated or not.
> + * For anything else we fall back to deferring the
> + * detection to be performed at a later point in time.
> + */
> + if (ret == -EINVAL) {
> + chan_rank_empty |= BIT(chan_rank);
> + continue;
> + }
> +
> + return -EAGAIN;
> + }
> +
> + for (dimm_idx = 0; dimm_idx < dimm_idx_max; dimm_idx++)
> + if (__dimm_temp(pcs, dimm_idx))
> + dimm_mask |= BIT(chan_rank * dimm_idx_max + dimm_idx);
> + }
> +
> + /*
> + * If we got all -EINVALs, it means that the CPU doesn't have any
> + * DIMMs. Unfortunately, it may also happen at the very start of
> + * host platform boot. Retrying a couple of times lets us make sure
> + * that the state is persistent.
> + */
> + if (chan_rank_empty == GENMASK(chan_rank_max - 1, 0)) {
> + if (priv->no_dimm_retry_count < NO_DIMM_RETRY_COUNT_MAX) {
> + priv->no_dimm_retry_count++;
> +
> + return -EAGAIN;
> + } else {
> + return -ENODEV;
> + }
Static analyzers will complain "else after return is unnecessary".
Guenter
next reply other threads:[~2021-11-23 15:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 15:56 Guenter Roeck [this message]
2021-11-24 16:15 ` [PATCH v4 11/13] hwmon: peci: Add dimmtemp driver Winiarska, Iwona
-- strict thread matches above, loose matches on Subject: below --
2021-11-23 14:06 [PATCH v4 00/13] Introduce PECI subsystem Iwona Winiarska
2021-11-23 14:07 ` [PATCH v4 11/13] hwmon: peci: Add dimmtemp driver Iwona Winiarska
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=20211123155608.GA2258206@roeck-us.net \
--to=linux@roeck-us.net \
--cc=andrew@aj.id.au \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=d.mueller@elsoft.ch \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=iwona.winiarska@intel.com \
--cc=jae.hyun.yoo@linux.intel.com \
--cc=jdelvare@suse.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=openbmc@lists.ozlabs.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rdunlap@infradead.org \
--cc=robh+dt@kernel.org \
--cc=tony.luck@intel.com \
--cc=zweiss@equinix.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).