public inbox for linuxppc-dev@ozlabs.org
 help / color / mirror / Atom feed
From: Haren Myneni <haren@linux.ibm.com>
To: Greg KH <gregkh@linuxfoundation.org>,
	Jori Koolstra <jkoolstra@xs4all.nl>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman	 <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
	Srikar Dronamraju <srikar@linux.ibm.com>,
	Jonathan Greental	 <yonatan02greental@gmail.com>,
	Kees Cook <kees@kernel.org>,
	Shrikanth Hegde	 <sshegde@linux.ibm.com>,
	"open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)"	
	<linuxppc-dev@lists.ozlabs.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] powerpc: vas-api: constify dynamic struct class in coproc api register
Date: Wed, 11 Mar 2026 16:27:38 -0700	[thread overview]
Message-ID: <b0a99a20f5f56ad8291d91b209d8ad5f7515bb23.camel@linux.ibm.com> (raw)
In-Reply-To: <2026031154-labored-frivolous-154b@gregkh>

On Wed, 2026-03-11 at 09:23 +0100, Greg KH wrote:
> On Mon, Mar 09, 2026 at 11:48:57AM +0100, Jori Koolstra wrote:
> > My bad, the earlier email went out to soon.
> > 
> > > Op 09-03-2026 07:01 CET schreef Greg KH
> > > <gregkh@linuxfoundation.org>:
> > > >  arch/powerpc/platforms/book3s/vas-api.c | 34
> > > > +++++++++++++++++++------
> > > >  1 file changed, 26 insertions(+), 8 deletions(-)
> > > > 
> > > > diff --git a/arch/powerpc/platforms/book3s/vas-api.c
> > > > b/arch/powerpc/platforms/book3s/vas-api.c
> > > > index ea4ffa63f043..e377981fd533 100644
> > > > --- a/arch/powerpc/platforms/book3s/vas-api.c
> > > > +++ b/arch/powerpc/platforms/book3s/vas-api.c
> > > > @@ -45,7 +45,7 @@ static struct coproc_dev {
> > > >  	struct device *device;
> > > >  	char *name;
> > > >  	dev_t devt;
> > > > -	struct class *class;
> > > > +	const struct class *class;
> > > >  	enum vas_cop_type cop_type;
> > > >  	const struct vas_user_win_ops *vops;
> > > >  } coproc_device;
> > > > @@ -599,6 +599,21 @@ static struct file_operations coproc_fops
> > > > = {
> > > >  	.unlocked_ioctl = coproc_ioctl,
> > > >  };
> > > >  
> > > > +static const struct class nx_gzip_class = {
> > > > +	.name		= "nx-gzip",
> > > > +	.devnode	= coproc_devnode
> > > > +};
> > > > +
> > > > +static const struct class* cop_to_class(enum vas_cop_type cop)
> > > > +{
> > > > +	switch (cop) {
> > > > +	case VAS_COP_TYPE_GZIP:		return
> > > > &nx_gzip_class;
> > > > +	default:
> > > > +		pr_err("No device class defined for cop type
> > > > %d\n", cop);
> > > > +		return NULL;
> > > > +	}
> > > > +}
> > > > +
> > > >  /*
> > > >   * Supporting only nx-gzip coprocessor type now, but this API
> > > > code
> > > >   * extended to other coprocessor types later.
> > > > @@ -609,6 +624,10 @@ int vas_register_coproc_api(struct module
> > > > *mod, enum vas_cop_type cop_type,
> > > >  {
> > > >  	int rc = -EINVAL;
> > > >  	dev_t devno;
> > > > +	const struct class* class = cop_to_class(cop_type);
> > > > +
> > > > +	if (!class)
> > > > +		return rc;
> > > 
> > > How can this happen?
> > > 
> > > This feels odd, are different types of devices being registered
> > > here?  I
> > > don't see where VAS_COP_TYPE_GZIP was being tested in the
> > > original code,
> > > why add this additional logic?
> > > 
> > 
> > My line of thought is this:
> > 
> > There is a function vas_register_coproc_api() that does some kind
> > of registering
> > for different coprocessor types. It has the following comment
> > above:
> > 
> > /*
> >  * Supporting only nx-gzip coprocessor type now, but this API code
> >  * extended to other coprocessor types later.
> >  */
> 
> I guess "later" never happened :(

Yes, VAS is virtual accelerator switchboard which can support multiple
accelerator types. Hence added vas_register_api* interface for
different accelerators. But no plans to add other accelerators on
powerpc right now. So can we use only VAS_COP_TYPE_GZIP class and can
visit later. 


diff --git a/arch/powerpc/platforms/powernv/vas-window.c
b/arch/powerpc/platforms/powernv/vas-window.c
index 9f093176b8db..360fdd8f200e 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -1459,6 +1459,8 @@ static const struct vas_user_win_ops vops =  {
 int vas_register_api_powernv(struct module *mod, enum vas_cop_type
cop_type,
                             const char *name)
 {
+       if (cop_type != VAS_COP_TYPE_GZIP)
+               return -ENOTSUPP;
 
        return vas_register_coproc_api(mod, cop_type, name, &vops);
 }
diff --git a/arch/powerpc/platforms/pseries/vas.c
b/arch/powerpc/platforms/pseries/vas.c
index 9a28f2899716..19e11056e6aa 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -574,6 +574,9 @@ int vas_register_api_pseries(struct module *mod,
enum vas_cop_type cop_type,
        if (!copypaste_feat)
                return -ENOTSUPP;
 
+       if (cop_type != VAS_COP_TYPE_GZIP)
+               return -ENOTSUPP;
+
        return vas_register_coproc_api(mod, cop_type, name,
&vops_pseries);
 }
 EXPORT_SYMBOL_GPL(vas_register_api_pseries);

Thanks
Haren


  reply	other threads:[~2026-03-11 23:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-08 21:46 [PATCH v2] powerpc: vas-api: constify dynamic struct class in coproc api register Jori Koolstra
2026-03-09  6:01 ` Greg KH
2026-03-09 10:35   ` Jori Koolstra
2026-03-09 10:46   ` Jori Koolstra
2026-03-09 10:48   ` Jori Koolstra
2026-03-11  8:23     ` Greg KH
2026-03-11 23:27       ` Haren Myneni [this message]
2026-04-01 17:14         ` Jori Koolstra

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=b0a99a20f5f56ad8291d91b209d8ad5f7515bb23.camel@linux.ibm.com \
    --to=haren@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkoolstra@xs4all.nl \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=srikar@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    --cc=yonatan02greental@gmail.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