[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3392aea6b112926b063bbe46b1decaad4c9f9e6e.camel@linux.intel.com>
Date: Sun, 26 Sep 2021 18:15:16 -0700
From: "David E. Box" <david.e.box@...ux.intel.com>
To: Greg KH <gregkh@...uxfoundation.org>, lee.jones@...aro.org
Cc: hdegoede@...hat.com, mgross@...ux.intel.com,
andriy.shevchenko@...ux.intel.com, srinivas.pandruvada@...el.com,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
platform-driver-x86@...r.kernel.org
Subject: Re: [PATCH 2/2] platform/x86: Add Intel Software Defined Silicon
driver
On Sat, 2021-09-25 at 08:27 +0200, Greg KH wrote:
> On Fri, Sep 24, 2021 at 02:31:57PM -0700, David E. Box wrote:
>
> Quick review:
>
> > +static int sdsi_probe(struct platform_device *pdev)
> > +{
> > + void __iomem *disc_addr;
> > + struct sdsi_priv *priv;
> > + int ret;
> > +
> > + disc_addr = devm_platform_ioremap_resource(pdev, 0);
> > + if (IS_ERR(disc_addr))
> > + return PTR_ERR(disc_addr);
> > +
> > + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> > + if (!priv)
> > + return -ENOMEM;
> > +
> > + kref_init(&priv->kref);
> > +
> > + platform_set_drvdata(pdev, priv);
> > + priv->pdev = pdev;
> > + mutex_init(&priv->mb_lock);
> > + mutex_init(&priv->akc_lock);
> > +
> > + memcpy_fromio(&priv->disc_table, disc_addr, DISC_TABLE_SIZE);
> > +
> > + ret = sdsi_map_sdsi_registers(pdev);
> > + if (ret)
> > + goto put_kref;
> > +
> > + ret = sdsi_create_misc_device(pdev);
> > + if (ret)
> > + goto put_kref;
> > +
> > + ret = sdsi_add_bin_attrs(pdev);
>
> You just raced with userspace and lost. Please attach your attributes
> to the misc device before registering it.
>
> Also, you need a Documentation/ABI/ entry for your new sysfs file(s).
Ack
>
> > + if (ret)
> > + goto deregister_misc;
> > +
> > + priv->dev_present = true;
> > +
> > + return 0;
> > +
> > +deregister_misc:
> > + misc_deregister(&priv->miscdev);
> > +put_kref:
> > + kref_put(&priv->kref, sdsi_priv_release);
> > +
> > + return ret;
> > +}
> > +
> > +static int sdsi_remove(struct platform_device *pdev)
> > +{
> > + struct sdsi_priv *priv = platform_get_drvdata(pdev);
> > +
> > + priv->dev_present = false;
> > + sysfs_remove_bin_file(&priv->pdev->dev.kobj, &priv->registers_bin_attr);
> > + misc_deregister(&priv->miscdev);
> > + kref_put(&priv->kref, sdsi_priv_release);
>
> Why do you need a kref for a structure that already can be controlled by
> a different lifetime rule?
Which rule am I missing? This kref allows the structure to remain in case the device is removed
while the file is open.
>
> > +
> > + return 0;
> > +}
> > +
> > +static struct platform_driver sdsi_driver = {
> > + .driver = {
> > + .name = SDSI_DEV_NAME,
> > + .dev_groups = sdsi_groups,
> > + },
> > + .probe = sdsi_probe,
> > + .remove = sdsi_remove,
> > +};
> > +module_platform_driver(sdsi_driver);
>
> What causes the platform to know to register, and enable, this platform
> driver? Shouldn't there be some hardware involved that is discoverable
> to enable it to load dynamically?
Ah. The patch that adds the SDSi platform device string was added to a series for the intel_pmt MFD
driver and it's still waiting review. I see that complicates things. I can combine the two series
together.
David
>
> thanks,
>
> greg k-h
Powered by blists - more mailing lists