public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: George Stark <gnstark@salutedevices.com>
Cc: Harald Geyer <harald@ccbib.org>, <lars@metafoo.de>,
	<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<kernel@salutedevices.com>
Subject: Re: [PATCH] iio: dht11: set debug log level for parsing error messages
Date: Mon, 25 Mar 2024 20:42:00 +0000	[thread overview]
Message-ID: <20240325204200.466ff642@jic23-huawei> (raw)
In-Reply-To: <01ed720d-a990-40dd-8a59-a95ea960ecec@salutedevices.com>

On Mon, 25 Mar 2024 23:18:32 +0300
George Stark <gnstark@salutedevices.com> wrote:

> Hello Harald
> 
> Thanks for the review.
> 
> 
> On 3/25/24 21:48, Harald Geyer wrote:
> > Hi George!
> > 
> > I'm torn on this:
> > 
> > Am Montag, dem 25.03.2024 um 19:54 +0300 schrieb George Stark:  
> >> Protocol parsing errors could happen due to several reasons like
> >> noise
> >> environment, heavy load on system etc. If to poll the sensor
> >> frequently
> >> and/or for a long period kernel log will become polluted with error
> >> messages if their log level is err (i.e. on by default).  
> > 
> > Yes, these error are often recoverable. (As are many other HW errors,
> > that typically are logged. Eg USB bus resets due to EMI)
> > 
> > However they are still genuine errors of the HW.
> >   
> >>   Also some types
> >> of those messages already have dbg level so use unified log level for
> >> all such cases.  
> > 
> > My take so far has been: Debug level messages are for debugging the
> > code (ie adding/testing support of new device variants etc). Users
> > aren't expected to know about or enable debug output. OTOH anything
> > actually going wrong is an error and should be logged as such.
> > 
> > The idea is, that these messages help users understand issues with
> > their HW (like too long cables, broken cables etc). But it is true,
> > that they will slowly accumulate in many real world scenarios without
> > anything being truly wrong.  
> 
> I agree with you that it's very convenient to just take a look to dmesg
> and see device connection problems at once. But unlike e.g. usb user has
> to actually start reading sensor to perform communication and read
> errors will be propagated to the userspace and could be noticed \
> handled.
> 
> Anyway I believe we should use uniform approach for read errors -
> currently in the driver there're already dbg messages:
> 
> "lost synchronisation at edge %d\n"
> "invalid checksum\n"
> 
> I changed log level from err to dbg for the messages:
> 
> "Only %d signal edges detected\n"
> "Don't know how to decode data: %d %d %d %d\n"
> 
> They all are from a single callback and say the same thing -
> communication problem.
> 
> If we make all those messages as errors it'd be great to have mechanism
> to disable them e.g. thru module parameter or somehow without rebuilding
> kernel. Those errors can be bypassed by increasing read rate.

Don't use a parameter for this.  dev_dbg and dynamic debug is the
way to go if this is the choice available.

If Harald is comfortable with the change given this discussion, I'll pick
up this patch.

Jonathan

> 
> > 
> > I don't consider the dmesg buffer being rotated after a month or two a
> > bug. But I suppose this is a corner case. I'll happily accept whatever
> > Jonathan thinks is reasonable.
> > 
> > Best regards,
> > Harald
> > 
> >   
> >> Signed-off-by: George Stark <gnstark@salutedevices.com>
> >> ---
> >> I use DHT22 sensor with Raspberry Pi Zero W as a simple home meteo
> >> station.
> >> Even if to poll the sensor once per tens of seconds after month or
> >> two dmesg
> >> may become full of useless parsing error messages. Anyway those
> >> errors are caught
> >> in the user software thru return values.
> >>
> >>   drivers/iio/humidity/dht11.c | 4 ++--
> >>   1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/iio/humidity/dht11.c
> >> b/drivers/iio/humidity/dht11.c
> >> index c97e25448772..e2cbc442177b 100644
> >> --- a/drivers/iio/humidity/dht11.c
> >> +++ b/drivers/iio/humidity/dht11.c
> >> @@ -156,7 +156,7 @@ static int dht11_decode(struct dht11 *dht11, int
> >> offset)
> >>                  dht11->temperature = temp_int * 1000;
> >>                  dht11->humidity = hum_int * 1000;
> >>          } else {
> >> -               dev_err(dht11->dev,
> >> +               dev_dbg(dht11->dev,
> >>                          "Don't know how to decode data: %d %d %d
> >> %d\n",
> >>                          hum_int, hum_dec, temp_int, temp_dec);
> >>                  return -EIO;
> >> @@ -239,7 +239,7 @@ static int dht11_read_raw(struct iio_dev
> >> *iio_dev,
> >>   #endif
> >>
> >>                  if (ret == 0 && dht11->num_edges <
> >> DHT11_EDGES_PER_READ - 1) {
> >> -                       dev_err(dht11->dev, "Only %d signal edges
> >> detected\n",
> >> +                       dev_dbg(dht11->dev, "Only %d signal edges
> >> detected\n",
> >>                                  dht11->num_edges);
> >>                          ret = -ETIMEDOUT;
> >>                  }
> >> --
> >> 2.25.1
> >>  
> >   
> 


  reply	other threads:[~2024-03-25 20:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 16:54 [PATCH] iio: dht11: set debug log level for parsing error messages George Stark
2024-03-25 18:48 ` Harald Geyer
2024-03-25 19:10   ` Jonathan Cameron
2024-03-25 20:18   ` George Stark
2024-03-25 20:42     ` Jonathan Cameron [this message]
2024-03-26 14:03     ` Harald Geyer
2024-04-05 20:06       ` George Stark

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=20240325204200.466ff642@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=gnstark@salutedevices.com \
    --cc=harald@ccbib.org \
    --cc=kernel@salutedevices.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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