Linux CXL
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "jehoon.park@samsung.com" <jehoon.park@samsung.com>
Cc: "Jiang, Dave" <dave.jiang@intel.com>,
	"Schofield, Alison" <alison.schofield@intel.com>,
	"jonathan.cameron@huawei.com" <jonathan.cameron@huawei.com>,
	"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
	"im, junhyeok" <junhyeok.im@samsung.com>,
	"Williams, Dan J" <dan.j.williams@intel.com>,
	"Weiny, Ira" <ira.weiny@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
	"dave@stgolabs.net" <dave@stgolabs.net>,
	"ks0204.kim@samsung.com" <ks0204.kim@samsung.com>
Subject: Re: [ndctl PATCH RESEND 2/2] libcxl: Fix accessors for temperature field to support negative value
Date: Mon, 31 Jul 2023 18:45:34 +0000	[thread overview]
Message-ID: <f1a9710dec8697edb50f0ad9941edefa4e2a4498.camel@intel.com> (raw)
In-Reply-To: <20230731031714.GA17128@jehoon-Precision-7920-Tower>

On Mon, 2023-07-31 at 12:17 +0900, Jehoon Park wrote:
> On Mon, Jul 24, 2023 at 09:08:21PM +0000, Verma, Vishal L wrote:
> > On Mon, 2023-07-17 at 15:29 +0900, Jehoon Park wrote:
> > > Add a new macro function to retrieve a signed value such as a temperature.
> > > Replace indistinguishable error numbers with debug message.
> > > 
> > > Signed-off-by: Jehoon Park <jehoon.park@samsung.com>
> > > ---
> > >  cxl/lib/libcxl.c | 36 ++++++++++++++++++++++++++----------
> > >  1 file changed, 26 insertions(+), 10 deletions(-)
> > > 

<..>

> > > 
> > >  CXL_EXPORT int cxl_cmd_health_info_get_temperature(struct cxl_cmd *cmd)
> > >  {
> > >         int rc = health_info_get_temperature_raw(cmd);
> > > +       struct cxl_ctx *ctx = cxl_memdev_get_ctx(cmd->memdev);
> > >  
> > > -       if (rc < 0)
> > > -               return rc;
> > > +       if (rc == 0xffff)
> > > +               dbg(ctx, "%s: Invalid command status\n",
> > > +                   cxl_memdev_get_devname(cmd->memdev));
> > >         if (rc == CXL_CMD_HEALTH_INFO_TEMPERATURE_NOT_IMPL)
> > > -               return -EOPNOTSUPP;
> > > +               dbg(ctx, "%s: Device Temperature not implemented\n",
> > > +                   cxl_memdev_get_devname(cmd->memdev));
> > 
> > Hi Jehoon,
> > 
> > libcxl tends to just return errno codes for simple accessors liek this,
> > and leave it up to the caller to print additional information about why
> > the call might have failed. Even though these are dbg() messages, I'd
> > prefer leaving them out of this patch, and if there is a call site
> > where this fails and there isn't an adequate error message printed as
> > to why, then add these prints there.
> > 
> > Rest of the conversion to s16 looks good.
> > 
> 
> Hi, Vishal.
> 
> Thank you for comment. I agree with the behavior of libcxl accessors as you
> explained. FYI, the reason I replaced errno codes with dbg messages is that
> those accessors are retreiving signed values. I thought returning errno codes
> is not distinguishable from retrieved values when they are negative.
> However, it looks like an overkill because a memory device works below-zero
> temperature would not make sense in real world.
> 
> I'll send revised patch soon after reverting to errno codes and fixing
> related codes in cxl/json.c.
> 
Good point on the negative temperatures - this means we can't use the
negative = error convention, but in this case what you can do is return
something like INT_MAX to indicate an error, and set errno in the
library to whatever error we want to indicate. And adjust all the
callers to check for errors in this way.

      reply	other threads:[~2023-07-31 18:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230717062617epcas2p46229ab9feac5a094afd44761e2b9a403@epcas2p4.samsung.com>
2023-07-17  6:29 ` [ndctl PATCH RESEND 0/2] Fix accessors for temperature field when it is negative Jehoon Park
2023-07-17  6:29   ` [ndctl PATCH RESEND 1/2] cxl: Update a revision by CXL 3.0 specification Jehoon Park
2023-07-17 13:18     ` Nathan Fontenot
2023-07-18  4:34       ` Jehoon Park
2023-07-17  6:29   ` [ndctl PATCH RESEND 2/2] libcxl: Fix accessors for temperature field to support negative value Jehoon Park
2023-07-24 21:08     ` Verma, Vishal L
2023-07-31  3:17       ` Jehoon Park
2023-07-31 18:45         ` Verma, Vishal L [this message]

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=f1a9710dec8697edb50f0ad9941edefa4e2a4498.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jehoon.park@samsung.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=junhyeok.im@samsung.com \
    --cc=ks0204.kim@samsung.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    /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