From: Dave Jiang <dave.jiang@intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
Vinod Koul <vkoul@kernel.org>,
dmaengine@vger.kernel.org
Subject: Re: [PATCH v7 8/8] dmaengine: idxd: fix cdev setup and free device lifetime issues
Date: Tue, 23 Mar 2021 07:48:30 -0700 [thread overview]
Message-ID: <8314b924-007c-47b6-d04f-ab8bde7168e9@intel.com> (raw)
In-Reply-To: <20210323000257.GY2356281@nvidia.com>
On 3/22/2021 5:02 PM, Jason Gunthorpe wrote:
> On Mon, Mar 22, 2021 at 04:44:24PM -0700, Dave Jiang wrote:
>> On 3/22/2021 4:38 PM, Dan Williams wrote:
>>> On Mon, Mar 22, 2021 at 4:32 PM Dave Jiang <dave.jiang@intel.com> wrote:
>>>> The char device setup and cleanup has device lifetime issues regarding when
>>>> parts are initialized and cleaned up. The initialization of struct device is
>>>> done incorrectly. device_initialize() needs to be called on the 'struct
>>>> device' and then additional changes can be added. The ->release() function
>>>> needs to be setup via device_type before dev_set_name() to allow proper
>>>> cleanup. The change re-parents the cdev under the wq->conf_dev to get
>>>> natural reference inheritance. No known dependency on the old device path exists.
>>>>
>>>> Reported-by: Jason Gunthorpe <jgg@nvidia.com>
>>>> Fixes: 42d279f9137a ("dmaengine: idxd: add char driver to expose submission portal to userland")
>>>> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>>>> Reviewed-by: Dan Williams <dan.j.williams@intel.com>
>>> [..]
>>>> diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
>>>> index 03079ff54889..8a08988ea9d1 100644
>>>> +++ b/drivers/dma/idxd/sysfs.c
>>>> @@ -1174,8 +1174,14 @@ static ssize_t wq_cdev_minor_show(struct device *dev,
>>>> struct device_attribute *attr, char *buf)
>>>> {
>>>> struct idxd_wq *wq = container_of(dev, struct idxd_wq, conf_dev);
>>>> + int minor = -1;
>>>>
>>>> - return sprintf(buf, "%d\n", wq->idxd_cdev.minor);
>>>> + mutex_lock(&wq->wq_lock);
>>>> + if (wq->idxd_cdev)
>>>> + minor = wq->idxd_cdev->minor;
>>>> + mutex_unlock(&wq->wq_lock);
>>>> +
>>>> + return sprintf(buf, "%d\n", minor);
>>> As I mentioned, let's not emit a negative value here. ...not that
>>> userspace should be using this awkward recreation of the existing core
>>> 'dev' attribute anyway.
>>>
>>> if (minor == -1)
>>> return -ENXIO;
>>> return sprintf(buf, "%d\n", minor);
>> Ok I'll update. This will go away when we convert to UACCE based driver.
> Also ensure all new syfs callbacks are using sysfs_emit()
>
Thanks Jason! I have posted a patch that fixes all the instances [1].
But I can fix it locally here as well.
[1]:
https://lore.kernel.org/dmaengine/161495936863.573579.5804720281778882171.stgit@djiang5-desk3.ch.intel.com/
next prev parent reply other threads:[~2021-03-23 14:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 23:31 [PATCH v7 0/8] idxd 'struct device' lifetime handling fixes Dave Jiang
2021-03-22 23:31 ` [PATCH v7 1/8] dmaengine: idxd: fix dma device lifetime Dave Jiang
2021-03-22 23:31 ` [PATCH v7 2/8] dmaengine: idxd: cleanup pci interrupt vector allocation management Dave Jiang
2021-03-22 23:31 ` [PATCH v7 3/8] dmaengine: idxd: removal of pcim managed mmio mapping Dave Jiang
2021-03-22 23:31 ` [PATCH v7 4/8] dmaengine: idxd: fix idxd conf_dev 'struct device' lifetime Dave Jiang
2021-03-22 23:31 ` [PATCH v7 5/8] dmaengine: idxd: fix wq " Dave Jiang
2021-03-22 23:31 ` [PATCH v7 6/8] dmaengine: idxd: fix engine conf_dev lifetime Dave Jiang
2021-03-22 23:31 ` [PATCH v7 7/8] dmaengine: idxd: fix group " Dave Jiang
2021-03-22 23:32 ` [PATCH v7 8/8] dmaengine: idxd: fix cdev setup and free device lifetime issues Dave Jiang
2021-03-22 23:38 ` Dan Williams
2021-03-22 23:44 ` Dave Jiang
2021-03-23 0:02 ` Jason Gunthorpe
2021-03-23 14:48 ` Dave Jiang [this message]
2021-03-23 11:45 ` [PATCH v7 0/8] idxd 'struct device' lifetime handling fixes Vinod Koul
2021-03-23 11:56 ` Jason Gunthorpe
2021-03-23 15:44 ` Dave Jiang
2021-03-24 13:56 ` Jason Gunthorpe
2021-03-24 14:57 ` Dave Jiang
2021-03-24 15:03 ` Jason Gunthorpe
2021-03-25 6:28 ` Vinod Koul
2021-03-25 15:25 ` Dave Jiang
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=8314b924-007c-47b6-d04f-ab8bde7168e9@intel.com \
--to=dave.jiang@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=jgg@nvidia.com \
--cc=vkoul@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