All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Hemant Kumar <hemantk@codeaurora.org>
Cc: manivannan.sadhasivam@linaro.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, jhugo@codeaurora.org,
	bbhatt@codeaurora.org
Subject: Re: [PATCH v5 4/4] bus: mhi: clients: Add userspace client interface driver
Date: Fri, 11 Sep 2020 09:47:52 +0200	[thread overview]
Message-ID: <20200911074752.GB3324216@kroah.com> (raw)
In-Reply-To: <010101747bd97269-a941d364-78ea-488c-baae-5a1c924d9e43-000000@us-west-2.amazonses.com>

On Fri, Sep 11, 2020 at 06:28:02AM +0000, Hemant Kumar wrote:
> > > +struct uci_dev {
> > > +	unsigned int minor;
> > > +	struct mhi_device *mhi_dev;
> > > +	const char *chan;
> > > +
> > > +	/* protects uci_dev struct members */
> > > +	struct mutex lock;
> > > +
> > > +	struct uci_chan ul_chan;
> > > +	struct uci_chan dl_chan;
> > > +	size_t mtu;
> > > +	size_t actual_mtu;
> > > +	struct kref ref_count;
> > > +	struct kref open_count;
> > 
> > I'm stopping right here.  A structure can only have ONE reference count
> > to control its lifespan.  You have 2 here, which guarantees that either
> > you are using a kref incorrectly, or your code is totally confused and
> > will break easily.
> > 
> > Please fix this as this is not how to do this.
> > 
> > Also, why does anyone need to care about the number of times that open()
> > is called?  The vfs layer should handle all of that for you, right?
> Reason for using open_count was to allow start MHI channel only when first
> open() was called and stop the MHI channel when last release() is called.
> Since uci driver just need to handle one open() from user space
> other calls to open can simply return -EBUSY. i will get rid of open_count
> and does not let multiple threads to open same file node.

You will fail in trying to attempt only one open on your device node,
sorry.  You can properly trigger off of the first/last things, but
having two different reference counts is NOT how to do this, those are
to control the lifetime of a structure/object.

greg k-h

  parent reply	other threads:[~2020-09-11  7:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06  6:40 [PATCH v5 0/4] user space client interface driver Hemant Kumar
2020-08-06  6:41 ` [PATCH v5 1/4] bus: mhi: core: Add helper API to return number of free TREs Hemant Kumar
2020-08-06  6:41 ` [PATCH v5 2/4] bus: mhi: core: Move MHI_MAX_MTU to external header file Hemant Kumar
2020-08-06  6:41 ` [PATCH v5 3/4] docs: Add documentation for userspace client interface Hemant Kumar
2020-08-06  6:41 ` [PATCH v5 4/4] bus: mhi: clients: Add userspace client interface driver Hemant Kumar
2020-09-07  9:37   ` Greg KH
2020-09-11  6:28     ` Hemant Kumar
     [not found]     ` <010101747bd97269-a941d364-78ea-488c-baae-5a1c924d9e43-000000@us-west-2.amazonses.com>
2020-09-11  7:47       ` Greg KH [this message]
2020-09-02 20:31 ` [PATCH v5 0/4] user space " Hemant Kumar

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=20200911074752.GB3324216@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bbhatt@codeaurora.org \
    --cc=hemantk@codeaurora.org \
    --cc=jhugo@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.