public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Saravana Kannan <saravanak@google.com>
Cc: Mark Brown <broonie@kernel.org>,
	kernel-team@android.com, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] spi: Don't have controller clean up spi device before driver unbind
Date: Wed, 5 May 2021 07:48:38 +0200	[thread overview]
Message-ID: <20210505054838.GA22603@wunner.de> (raw)
In-Reply-To: <20210505031416.30128-1-saravanak@google.com>

On Tue, May 04, 2021 at 08:14:16PM -0700, Saravana Kannan wrote:
> @@ -415,6 +421,7 @@ static int spi_remove(struct device *dev)
>  				 ERR_PTR(ret));
>  	}
>  
> +	spi_cleanup(to_spi_device(dev));
>  	dev_pm_domain_detach(dev, true);
>  
>  	return 0;

Unfortunately this doesn't look right:  spi_remove() is run on
driver unbind of the spi_device.  With the above change,
->setup is called on spi_device addition and ->cleanup is called
on unbind, which is obviously assymetric.  What can happen
here is that a slave-specific controller_state is allocated on
spi_device addition, then on unbind that controller_state is freed
and on a subsequent rebind it won't be recreated because ->setup
isn't run on spi_device ->probe.

As I've written yesterday, calling spi_cleanup() in
spi_unregister_device() should be fine if you move it to the end
of the function, but before the final put_device().  For that,
you need to open code the calls to device_del() and put_device()
that happen in device_unregister() so far.

Thanks,

Lukas

  reply	other threads:[~2021-05-05  5:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05  3:14 [PATCH v1] spi: Don't have controller clean up spi device before driver unbind Saravana Kannan
2021-05-05  5:48 ` Lukas Wunner [this message]
2021-05-05 12:38   ` Mark Brown
2021-05-05 16:31   ` Saravana Kannan

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=20210505054838.GA22603@wunner.de \
    --to=lukas@wunner.de \
    --cc=broonie@kernel.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=saravanak@google.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