public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Tomas Winkler <tomas.winkler@intel.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mtd: use refcount to prevent corruption
Date: Thu, 28 Jan 2021 21:23:29 +0100 (CET)	[thread overview]
Message-ID: <1363048722.339069.1611865409332.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <10c2e98c393a486cab3bc953e9926e38@intel.com>

Tomas,

----- Ursprüngliche Mail -----
>> As Richard was saying, we are really open to enhance MTD refcounting.
>> 
>> However, the issue you are facing is, IMHO, not related to MTD but to MFD.
>> There should be a way to avoid MFD to vanish by taking a reference of it
>> through mtd->_get_device(). I don't think addressing the case where MFD
>> vanishes while MTD (as a user) is still active is the right approach.
> 
> I think it won't work because MFD sub-driver remove() is called   and it must
> succeed because the main device  is not accessible unlike glueubi which just
> returns -EBUSY.

Well, the trick in glubi (and other MTDs with "hotplug" support) is not to reject
removal of the sub-device. ->_put_device() is of return type void.
The key is grabbing a reference on the sub-device in ->_get_device() such that
the layer below doesn't even try to remove while the MTD is in use.

> so we postpone the mtd unregister to  mtd_info->_put_device()  but it that state
> we have nothing to hold
> on as the device is gone in remove()
> User will fail anyway, as the underlying device is not functional in that state.
> Anyway I've tried your suggestion, the kernel is crashing, hope I haven't done
> some silly bug.

Can you point us to the affected code?
This would help a lot to understand the issue better.
I'm sure we can find a solution.

Thanks,
//richard

  reply	other threads:[~2021-01-28 20:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 20:03 [PATCH] mtd: use refcount to prevent corruption Tomas Winkler
2021-01-27 20:46 ` Richard Weinberger
2021-01-27 20:55   ` Winkler, Tomas
2021-01-27 21:17     ` Richard Weinberger
2021-01-28  6:33       ` Winkler, Tomas
2021-01-28  7:47         ` Richard Weinberger
2021-01-28  8:53           ` Winkler, Tomas
2021-01-28  9:00             ` Miquel Raynal
2021-01-28 17:57               ` Winkler, Tomas
2021-01-28 20:23                 ` Richard Weinberger [this message]
2021-02-13 17:09                   ` Winkler, Tomas
2021-02-15 13:43                     ` Richard Weinberger

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=1363048722.339069.1611865409332.JavaMail.zimbra@nod.at \
    --to=richard@nod.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=tomas.winkler@intel.com \
    --cc=vigneshr@ti.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