Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1641923 > unrolled thread

[PATCH v3] Add "shutdown" to "struct class".

Started byJosh Zimmerman <joshz@google.com>
First post2017-05-15 19:40 +0200
Last post2017-05-18 17:30 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v3] Add "shutdown" to "struct class". Josh Zimmerman <joshz@google.com> - 2017-05-15 19:40 +0200
    Re: [PATCH v3] Add "shutdown" to "struct class". Josh Zimmerman <joshz@google.com> - 2017-05-15 19:40 +0200
      Re: [PATCH v3] Add "shutdown" to "struct class". Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-05-15 19:50 +0200
        RE: [PATCH v3] Add "shutdown" to "struct class". "Winkler, Tomas" <tomas.winkler@intel.com> - 2017-05-15 22:50 +0200
          Re: [PATCH v3] Add "shutdown" to "struct class". Josh Zimmerman <joshz@google.com> - 2017-05-18 17:30 +0200

#1641923 — [PATCH v3] Add "shutdown" to "struct class".

FromJosh Zimmerman <joshz@google.com>
Date2017-05-15 19:40 +0200
Subject[PATCH v3] Add "shutdown" to "struct class".
Message-ID<tHs8p-2IK-3@gated-at.bofh.it>
The TPM class has some common shutdown code that must be executed for
all drivers. This adds some needed functionality for that.

Usage example: 'tpm: Issue a TPM2_Shutdown for TPM2 devices.'
(see https://patchwork.kernel.org/patch/9724919/ for v2).

Signed-off-by: Josh Zimmerman <joshz@google.com>

-----
v2: Add Signed-off-by.
v3: Remove logically separate change.
---
 drivers/base/core.c    | 5 +++++
 include/linux/device.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index bbecaf9293be..5c1648875e94 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2667,6 +2667,11 @@ void device_shutdown(void)
 		pm_runtime_get_noresume(dev);
 		pm_runtime_barrier(dev);
 
+		if (dev->class && dev->class->shutdown) {
+			if (initcall_debug)
+				dev_info(dev, "shutdown\n");
+			dev->class->shutdown(dev);
+		}
 		if (dev->bus && dev->bus->shutdown) {
 			if (initcall_debug)
 				dev_info(dev, "shutdown\n");
diff --git a/include/linux/device.h b/include/linux/device.h
index 9ef518af5515..f240baac2001 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -378,6 +378,7 @@ int subsys_virtual_register(struct bus_type *subsys,
  * @suspend:	Used to put the device to sleep mode, usually to a low power
  *		state.
  * @resume:	Used to bring the device from the sleep mode.
+ * @shutdown:	Called at shut-down time to quiesce the device.
  * @ns_type:	Callbacks so sysfs can detemine namespaces.
  * @namespace:	Namespace of the device belongs to this class.
  * @pm:		The default device power management operations of this class.
@@ -407,6 +408,7 @@ struct class {
 
 	int (*suspend)(struct device *dev, pm_message_t state);
 	int (*resume)(struct device *dev);
+	int (*shutdown)(struct device *dev);
 
 	const struct kobj_ns_type_operations *ns_type;
 	const void *(*namespace)(struct device *dev);
-- 
2.13.0.rc2.291.g57267f2277-goog

[toc] | [next] | [standalone]


#1641925

FromJosh Zimmerman <joshz@google.com>
Date2017-05-15 19:40 +0200
Message-ID<tHs8q-2IK-7@gated-at.bofh.it>
In reply to#1641923
(Continuing thread from patch v1)
> > On Sat, May 13, 2017 at 12:43:11PM +0000, Winkler, Tomas wrote:
> > > > The TPM class has some common shutdown code that must be executed
> > > > for all drivers. This adds some needed functionality for that
> > >
> > > The issue with this is, that on some platforms the only storage can be
> > > eMMC and TPM is using it,. It has to be ensured that the storage
> > > device won't go down before TPM2_shutdown is called.  And there is no
> > > direct device hierarchy to ensure an orderly shutdown.
> >
> > Something will have to use the new device links stuff to define that
> > dependency, but that seems unrelated to this patch?
>
>
> Yep, it's not directly related to this specific patch, this is more relevant particularly to TPM2_shutdown.

Jason, do you want me to do that in my patch on the tpmdd-devel list?
If so, mind giving me a documentation pointer or two? I'm not familiar
with this area.

Thanks,
Josh

[toc] | [prev] | [next] | [standalone]


#1641930

FromJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Date2017-05-15 19:50 +0200
Message-ID<tHsi6-2M0-7@gated-at.bofh.it>
In reply to#1641925
On Mon, May 15, 2017 at 10:39:08AM -0700, Josh Zimmerman wrote:
> (Continuing thread from patch v1)
> > > On Sat, May 13, 2017 at 12:43:11PM +0000, Winkler, Tomas wrote:
> > > > > The TPM class has some common shutdown code that must be executed
> > > > > for all drivers. This adds some needed functionality for that
> > > >
> > > > The issue with this is, that on some platforms the only storage can be
> > > > eMMC and TPM is using it,. It has to be ensured that the storage
> > > > device won't go down before TPM2_shutdown is called.  And there is no
> > > > direct device hierarchy to ensure an orderly shutdown.
> > >
> > > Something will have to use the new device links stuff to define that
> > > dependency, but that seems unrelated to this patch?
> >
> >
> > Yep, it's not directly related to this specific patch, this is more relevant particularly to TPM2_shutdown.
> 
> Jason, do you want me to do that in my patch on the tpmdd-devel list?
> If so, mind giving me a documentation pointer or two? I'm not familiar
> with this area.

No.. Ordering power management events is something someone with
knowledge of the specific emmc platform is going to have to tackle..
It isn't really a core problem, platform specific code will have to
setup the needed device links to order power management properly..

Jason

[toc] | [prev] | [next] | [standalone]


#1642049

From"Winkler, Tomas" <tomas.winkler@intel.com>
Date2017-05-15 22:50 +0200
Message-ID<tHv6h-4wd-15@gated-at.bofh.it>
In reply to#1641930

> -----Original Message-----
> From: Jason Gunthorpe [mailto:jgunthorpe@obsidianresearch.com]
> Sent: Monday, May 15, 2017 20:46
> To: Josh Zimmerman <joshz@google.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; linux-
> kernel@vger.kernel.org; Winkler, Tomas <tomas.winkler@intel.com>; Jarkko
> Sakkinen <jarkko.sakkinen@linux.intel.com>; tpmdd-
> devel@lists.sourceforge.net
> Subject: Re: [PATCH v3] Add "shutdown" to "struct class".
> 
> On Mon, May 15, 2017 at 10:39:08AM -0700, Josh Zimmerman wrote:
> > (Continuing thread from patch v1)
> > > > On Sat, May 13, 2017 at 12:43:11PM +0000, Winkler, Tomas wrote:
> > > > > > The TPM class has some common shutdown code that must be
> > > > > > executed for all drivers. This adds some needed functionality
> > > > > > for that
> > > > >
> > > > > The issue with this is, that on some platforms the only storage
> > > > > can be eMMC and TPM is using it,. It has to be ensured that the
> > > > > storage device won't go down before TPM2_shutdown is called.
> > > > > And there is no direct device hierarchy to ensure an orderly
> shutdown.
> > > >
> > > > Something will have to use the new device links stuff to define
> > > > that dependency, but that seems unrelated to this patch?
> > >
> > >
> > > Yep, it's not directly related to this specific patch, this is more relevant
> particularly to TPM2_shutdown.
> >
> > Jason, do you want me to do that in my patch on the tpmdd-devel list?
> > If so, mind giving me a documentation pointer or two? I'm not familiar
> > with this area.
> 
> No.. Ordering power management events is something someone with
> knowledge of the specific emmc platform is going to have to tackle..
> It isn't really a core problem, platform specific code will have to setup the
> needed device links to order power management properly..

eMMC is just an example, that can be other storage device (ufs, nvme) and some type of abstraction of underlying storage
dependency would be required. I just wanted to put it on the table, not sure it has to be solved in this round.
Tomas




> 
> Jason

[toc] | [prev] | [next] | [standalone]


#1644682

FromJosh Zimmerman <joshz@google.com>
Date2017-05-18 17:30 +0200
Message-ID<tIvxh-4z7-39@gated-at.bofh.it>
In reply to#1642049
Are there any more changes any of you would like to see in this patch?

Thanks!
Josh


On Mon, May 15, 2017 at 1:49 PM, Winkler, Tomas <tomas.winkler@intel.com> wrote:
>
>
>> -----Original Message-----
>> From: Jason Gunthorpe [mailto:jgunthorpe@obsidianresearch.com]
>> Sent: Monday, May 15, 2017 20:46
>> To: Josh Zimmerman <joshz@google.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; linux-
>> kernel@vger.kernel.org; Winkler, Tomas <tomas.winkler@intel.com>; Jarkko
>> Sakkinen <jarkko.sakkinen@linux.intel.com>; tpmdd-
>> devel@lists.sourceforge.net
>> Subject: Re: [PATCH v3] Add "shutdown" to "struct class".
>>
>> On Mon, May 15, 2017 at 10:39:08AM -0700, Josh Zimmerman wrote:
>> > (Continuing thread from patch v1)
>> > > > On Sat, May 13, 2017 at 12:43:11PM +0000, Winkler, Tomas wrote:
>> > > > > > The TPM class has some common shutdown code that must be
>> > > > > > executed for all drivers. This adds some needed functionality
>> > > > > > for that
>> > > > >
>> > > > > The issue with this is, that on some platforms the only storage
>> > > > > can be eMMC and TPM is using it,. It has to be ensured that the
>> > > > > storage device won't go down before TPM2_shutdown is called.
>> > > > > And there is no direct device hierarchy to ensure an orderly
>> shutdown.
>> > > >
>> > > > Something will have to use the new device links stuff to define
>> > > > that dependency, but that seems unrelated to this patch?
>> > >
>> > >
>> > > Yep, it's not directly related to this specific patch, this is more relevant
>> particularly to TPM2_shutdown.
>> >
>> > Jason, do you want me to do that in my patch on the tpmdd-devel list?
>> > If so, mind giving me a documentation pointer or two? I'm not familiar
>> > with this area.
>>
>> No.. Ordering power management events is something someone with
>> knowledge of the specific emmc platform is going to have to tackle..
>> It isn't really a core problem, platform specific code will have to setup the
>> needed device links to order power management properly..
>
> eMMC is just an example, that can be other storage device (ufs, nvme) and some type of abstraction of underlying storage
> dependency would be required. I just wanted to put it on the table, not sure it has to be solved in this round.
> Tomas
>
>
>
>
>>
>> Jason

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web