mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: Florian Fainelli <florian.fainelli@broadcom.com>,
	Stefan Wahren <wahrenst@gmx.net>,
	Umang Jain <umang.jain@ideasonboard.com>,
	linux-rpi-kernel@lists.infradead.org
Cc: Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.org>,
	detule <ogjoneski@gmail.com>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE
	<linux-arm-kernel@lists.infradead.org>,
	open list:STAGING SUBSYSTEM <linux-staging@lists.linux.dev>,
	open list <linux-kernel@vger.kernel.org>;
Subject: Re: [PATCH] staging: vc04_services: vchiq_arm: Fix initialisation check
Date: Fri, 14 Jun 2024 12:36:05 +0100	[thread overview]
Message-ID: <171836496531.2248009.11650291484570726735@ping.linuxembedded.co.uk> (raw)
In-Reply-To: <082d9df0-0947-4452-a3fc-87eab2019e01@gmx.net>

Hi Stefan,

Sorry, indeed I completely missed this mail.

Quoting Stefan Wahren (2024-06-13 21:01:42)
> Hi Kieran,
> 
> Am 13.06.24 um 21:41 schrieb Kieran Bingham:
> > The vchiq_state used to be obtained through an accessor
> > which would validate that the VCHIQ had been initialised
> > correctly with the remote.
> >
> > In commit 42a2f6664e18 ("staging: vc04_services: Move global g_state to
> > vchiq_state") the global state was moved to the vchiq_mgnt structures
> > stored as a vchiq instance specific context. This conversion removed the
> > helpers and instead replaced users of this helper with the assumption
> > that the state is always available and the remote connected.
> >
> > Fix this broken assumption by re-introducing the logic that was lost
> > during the conversion.
> 
> thank you for sending this patch. Maybe it's worth to mention that this
> patch also drop some unnecessary NULL checks of state.

I don't understand this comment. Nothing is dropped is it?

The newly added vchiq_remote_initialised() is itself a null-check too!

> > Fixes: 42a2f6664e18 ("staging: vc04_services: Move global g_state to vchiq_state")
> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > ---
> >   .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c  | 4 ++--
> >   .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 5 +++++
> >   .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c  | 7 ++++++-
> >   3 files changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> > index 54467be8c371..67d853f5f2a0 100644
> > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> > @@ -804,7 +804,7 @@ int vchiq_initialise(struct vchiq_state *state, struct vchiq_instance **instance
> >        * block forever.
> >        */
> >       for (i = 0; i < VCHIQ_INIT_RETRIES; i++) {
> > -             if (state)
> > +             if (vchiq_remote_initialised(state))
> >                       break;
> >               usleep_range(500, 600);
> >       }
> > @@ -1299,7 +1299,7 @@ void vchiq_dump_platform_instances(struct vchiq_state *state, struct seq_file *f
> >   {
> >       int i;
> >
> > -     if (!state)
> > +     if (!vchiq_remote_initialised(state))
> >               return;
> >
> >       /*
> > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> > index 8af209e34fb2..382ec08f6a14 100644
> > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> > @@ -413,6 +413,11 @@ struct vchiq_state {
> >       struct opaque_platform_state *platform_state;
> >   };
> >
> > +static inline bool vchiq_remote_initialised(const struct vchiq_state *state)
> > +{
> > +     return state->remote && state->remote->initialised;
> > +}
> > +
> >   struct bulk_waiter {
> >       struct vchiq_bulk *bulk;
> >       struct completion event;
> > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> > index 3c63347d2d08..8c4830df1070 100644
> > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> > @@ -1170,6 +1170,11 @@ static int vchiq_open(struct inode *inode, struct file *file)
> >
> >       dev_dbg(state->dev, "arm: vchiq open\n");
> >
> > +     if (!vchiq_remote_initialised(state)) {
> > +             dev_err(state->dev, "arm: vchiq has no connection to VideoCore\n");
> Can you please downgrade the log level to dev_dbg, because vchiq_open is
> called from userspace, so we can prevent log spamming?

Sure.

> > +             return -ENOTCONN;
> > +     }
> > +
> >       instance = kzalloc(sizeof(*instance), GFP_KERNEL);
> >       if (!instance)
> >               return -ENOMEM;
> > @@ -1200,7 +1205,7 @@ static int vchiq_release(struct inode *inode, struct file *file)
> >
> >       dev_dbg(state->dev, "arm: instance=%p\n", instance);
> >
> > -     if (!state) {
> > +     if (!vchiq_remote_initialised(state)) {
> >               ret = -EPERM;
> >               goto out;
> >       }
>

  reply	other threads:[~2024-06-14 11:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 19:41 Kieran Bingham
2024-06-13 19:41 ` Kieran Bingham
2024-06-13 20:01   ` Stefan Wahren
2024-06-14 11:36     ` Kieran Bingham [this message]
2024-06-14 11:52       ` Stefan Wahren
2024-06-14 12:00         ` Kieran Bingham
2024-06-14  6:50   ` Greg Kroah-Hartman
2024-06-14 10:41     ` Kieran Bingham
2024-06-13 19:58 ` Dan Carpenter
2024-06-14 10:45   ` Kieran Bingham

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=171836496531.2248009.11650291484570726735@ping.linuxembedded.co.uk \
    --to=kieran.bingham@ideasonboard.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dan.carpenter@linaro.org \
    --cc=dave.stevenson@raspberrypi.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=ogjoneski@gmail.com \
    --cc=umang.jain@ideasonboard.com \
    --cc=wahrenst@gmx.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

all inboxes | Powered by JetHome®