linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@codeconstruct.com.au>
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: minyard@acm.org, openipmi-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, aladyshev22@gmail.com,
	jk@codeconstruct.com.au
Subject: Re: [PATCH 05/10] ipmi: kcs_bmc: Define client actions in terms of kcs_bmc_client
Date: Tue, 07 Nov 2023 17:02:37 +1030	[thread overview]
Message-ID: <f3b30b70563c68b56451e3eb7a3e22ce4c142651.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20231103151651.000045ae@Huawei.com>

On Fri, 2023-11-03 at 15:16 +0000, Jonathan Cameron wrote:
> On Fri,  3 Nov 2023 16:45:17 +1030
> Andrew Jeffery <andrew@codeconstruct.com.au> wrote:
> 
> > Operations such as reading and writing from hardware and updating the
> > events of interest are operations in which the client is interested, but
> > are applied to the device. Strengthen the concept of the client in the
> > subsystem and clean up some call-sites by translating between the client
> > and device types in the core of the KCS subsystem.
> > 
> > Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
> > ---
> >  drivers/char/ipmi/kcs_bmc.c           | 67 ++++++++++++++++++---------
> >  drivers/char/ipmi/kcs_bmc_cdev_ipmi.c | 50 ++++++++++----------
> >  drivers/char/ipmi/kcs_bmc_client.h    | 15 +++---
> >  drivers/char/ipmi/kcs_bmc_serio.c     | 10 ++--
> >  4 files changed, 81 insertions(+), 61 deletions(-)
> > 
> > diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c
> > index 5a3f199241d2..d70e503041bd 100644
> > --- a/drivers/char/ipmi/kcs_bmc.c
> > +++ b/drivers/char/ipmi/kcs_bmc.c
> > @@ -22,33 +22,53 @@ static LIST_HEAD(kcs_bmc_drivers);
> >  
> >  /* Consumer data access */
> >  
> > -u8 kcs_bmc_read_data(struct kcs_bmc_device *kcs_bmc)
> > +static void kcs_bmc_client_validate(struct kcs_bmc_client *client)
> >  {
> > -	return kcs_bmc->ops->io_inputb(kcs_bmc, kcs_bmc->ioreg.idr);
> > +	WARN_ONCE(client != READ_ONCE(client->dev->client), "KCS client confusion detected");
> 
> Is this intended as runtime validation or to catch bugs?
> If just catch bugs then fair enough.

Ah, I think I missed replying here.

So for "runtime validation" I assume you mean "things userspace might
do that are not valid - the error condition should be detected and
punted back to userspace", vs "catch bugs" meaning "the implementation
in the kernel failed to uphold an invariant and now there are
Problems".

If that sounds accurate, then it's the latter: The WARN_ONCE() is
asserting "don't operate on a client that doesn't own the device". It
isn't an error that can be punted back for handling in userspace as it
should not be possible for the kernel to get into this state to begin
with. If we reach this state it's an error in the programming of the
kernel module that's a client of the KCS subsystem.

> 
> With that question answered based on my somewhat vague understanding of the kcs subsystem.
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Thanks,

Andrew

  reply	other threads:[~2023-11-07  6:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03  6:15 [PATCH 00/10] ipmi: kcs_bmc: Miscellaneous cleanups Andrew Jeffery
2023-11-03  6:15 ` [PATCH 01/10] ipmi: kcs_bmc: Update module description Andrew Jeffery
2023-11-03 14:34   ` Jonathan Cameron
2023-11-03  6:15 ` [PATCH 02/10] ipmi: kcs_bmc: Include spinlock.h Andrew Jeffery
2023-11-03 14:36   ` Jonathan Cameron
2023-11-05 22:47     ` Andrew Jeffery
2023-11-03  6:15 ` [PATCH 03/10] ipmi: kcs_bmc: Make kcs_bmc_update_event_mask() static Andrew Jeffery
2023-11-03 14:40   ` Jonathan Cameron
2023-11-05 22:52     ` Andrew Jeffery
2023-11-03  6:15 ` [PATCH 04/10] ipmi: kcs_bmc: Make remove_device() callback return void Andrew Jeffery
2023-11-03 14:43   ` Jonathan Cameron
2023-11-05 22:54     ` Andrew Jeffery
2023-11-03  6:15 ` [PATCH 05/10] ipmi: kcs_bmc: Define client actions in terms of kcs_bmc_client Andrew Jeffery
2023-11-03 15:16   ` Jonathan Cameron
2023-11-07  6:32     ` Andrew Jeffery [this message]
2023-11-03  6:15 ` [PATCH 06/10] ipmi: kcs_bmc: Integrate buffers into driver struct Andrew Jeffery
2023-11-03 14:45   ` Jonathan Cameron
2023-11-05 22:55     ` Andrew Jeffery
2023-11-03  6:15 ` [PATCH 07/10] ipmi: kcs_bmc: Disassociate client from device lifetimes Andrew Jeffery
2023-11-03 14:51   ` Jonathan Cameron
2023-11-05 23:01     ` Andrew Jeffery
2023-11-03  6:15 ` [PATCH 08/10] ipmi: kcs_bmc: Track clients in core Andrew Jeffery
2023-11-03 15:05   ` Jonathan Cameron
2023-11-05 23:56     ` Andrew Jeffery
2023-11-20 12:40       ` Jonathan Cameron
2023-11-27  3:02         ` Andrew Jeffery
2023-11-03  6:15 ` [PATCH 09/10] ipmi: kcs_bmc: Add module_kcs_bmc_driver() Andrew Jeffery
2023-11-03 15:06   ` Jonathan Cameron
2023-11-03  6:15 ` [PATCH 10/10] ipmi: kcs_bmc: Add subsystem kerneldoc Andrew Jeffery
2023-11-03 15:12   ` Jonathan Cameron
2023-11-06  0:05     ` Andrew Jeffery

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=f3b30b70563c68b56451e3eb7a3e22ce4c142651.camel@codeconstruct.com.au \
    --to=andrew@codeconstruct.com.au \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=aladyshev22@gmail.com \
    --cc=jk@codeconstruct.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minyard@acm.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    /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).