From: "Winiarska, Iwona" <iwona.winiarska@intel.com>
To: "linux@roeck-us.net" <linux@roeck-us.net>
Cc: "corbet@lwn.net" <corbet@lwn.net>,
"jae.hyun.yoo@linux.intel.com" <jae.hyun.yoo@linux.intel.com>,
"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
"andrew@aj.id.au" <andrew@aj.id.au>,
"Hansen, Dave" <dave.hansen@intel.com>,
"Luck, Tony" <tony.luck@intel.com>,
"jdelvare@suse.com" <jdelvare@suse.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"olof@lixom.net" <olof@lixom.net>,
"rdunlap@infradead.org" <rdunlap@infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
"arnd@arndb.de" <arnd@arndb.de>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"zweiss@equinix.com" <zweiss@equinix.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>,
"bp@alien8.de" <bp@alien8.de>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"pierre-louis.bossart@linux.intel.com"
<pierre-louis.bossart@linux.intel.com>,
"andriy.shevchenko@linux.intel.com"
<andriy.shevchenko@linux.intel.com>,
"Williams, Dan J" <dan.j.williams@intel.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v4 11/13] hwmon: peci: Add dimmtemp driver
Date: Wed, 24 Nov 2021 16:15:17 +0000 [thread overview]
Message-ID: <f6fd690c7cf2019d20968e9b52741c99c259de7b.camel@intel.com> (raw)
In-Reply-To: <20211123155608.GA2258206@roeck-us.net>
On Tue, 2021-11-23 at 07:56 -0800, Guenter Roeck wrote:
> 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".
I'll fix this in v5.
Thanks
-Iwona
>
> Guenter
next prev parent reply other threads:[~2021-11-24 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 15:56 [PATCH v4 11/13] hwmon: peci: Add dimmtemp driver Guenter Roeck
2021-11-24 16:15 ` Winiarska, Iwona [this message]
-- 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=f6fd690c7cf2019d20968e9b52741c99c259de7b.camel@intel.com \
--to=iwona.winiarska@intel.com \
--cc=andrew@aj.id.au \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jae.hyun.yoo@linux.intel.com \
--cc=jdelvare@suse.com \
--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=linux@roeck-us.net \
--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).