All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: disable pm for typec class devices
@ 2023-02-07  6:42 Linyu Yuan
  2023-02-07  7:34 ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: Linyu Yuan @ 2023-02-07  6:42 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, Jack Pham, Wesley Cheng, Pratham Pratap, Linyu Yuan

as there is no pm operation, call device_set_pm_not_required() to disable
all typec class devices.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/typec/class.c   | 5 +++++
 drivers/usb/typec/mux.c     | 2 ++
 drivers/usb/typec/pd.c      | 3 +++
 drivers/usb/typec/retimer.c | 1 +
 4 files changed, 11 insertions(+)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index ed3d070..b75ec6d 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -548,6 +548,7 @@ typec_register_altmode(struct device *parent,
 	alt->adev.dev.groups = alt->groups;
 	alt->adev.dev.type = &typec_altmode_dev_type;
 	dev_set_name(&alt->adev.dev, "%s.%u", dev_name(parent), id);
+	device_set_pm_not_required(&alt->adev.dev);
 
 	/* Link partners and plugs with the ports */
 	if (!is_port)
@@ -880,6 +881,7 @@ struct typec_partner *typec_register_partner(struct typec_port *port,
 	partner->dev.parent = &port->dev;
 	partner->dev.type = &typec_partner_dev_type;
 	dev_set_name(&partner->dev, "%s-partner", dev_name(&port->dev));
+	device_set_pm_not_required(&partner->dev);
 
 	ret = device_register(&partner->dev);
 	if (ret) {
@@ -1032,6 +1034,7 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable,
 	plug->dev.parent = &cable->dev;
 	plug->dev.type = &typec_plug_dev_type;
 	dev_set_name(&plug->dev, "%s-%s", dev_name(cable->dev.parent), name);
+	device_set_pm_not_required(&plug->dev);
 
 	ret = device_register(&plug->dev);
 	if (ret) {
@@ -1197,6 +1200,7 @@ struct typec_cable *typec_register_cable(struct typec_port *port,
 	cable->dev.parent = &port->dev;
 	cable->dev.type = &typec_cable_dev_type;
 	dev_set_name(&cable->dev, "%s-cable", dev_name(&port->dev));
+	device_set_pm_not_required(&cable->dev);
 
 	ret = device_register(&cable->dev);
 	if (ret) {
@@ -2260,6 +2264,7 @@ struct typec_port *typec_register_port(struct device *parent,
 	port->dev.fwnode = cap->fwnode;
 	port->dev.type = &typec_port_dev_type;
 	dev_set_name(&port->dev, "port%d", id);
+	device_set_pm_not_required(&port->dev);
 	dev_set_drvdata(&port->dev, cap->driver_data);
 
 	port->cap = kmemdup(cap, sizeof(*cap), GFP_KERNEL);
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index c7177dd..55b5417 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -183,6 +183,7 @@ typec_switch_register(struct device *parent,
 	sw_dev->dev.class = &typec_mux_class;
 	sw_dev->dev.type = &typec_switch_dev_type;
 	sw_dev->dev.driver_data = desc->drvdata;
+	device_set_pm_not_required(&sw_dev->dev);
 	ret = dev_set_name(&sw_dev->dev, "%s-switch", desc->name ? desc->name : dev_name(parent));
 	if (ret) {
 		put_device(&sw_dev->dev);
@@ -470,6 +471,7 @@ typec_mux_register(struct device *parent, const struct typec_mux_desc *desc)
 	mux_dev->dev.class = &typec_mux_class;
 	mux_dev->dev.type = &typec_mux_dev_type;
 	mux_dev->dev.driver_data = desc->drvdata;
+	device_set_pm_not_required(&mux_dev->dev);
 	ret = dev_set_name(&mux_dev->dev, "%s-mux", desc->name ? desc->name : dev_name(parent));
 	if (ret) {
 		put_device(&mux_dev->dev);
diff --git a/drivers/usb/typec/pd.c b/drivers/usb/typec/pd.c
index dc72005..252ef51 100644
--- a/drivers/usb/typec/pd.c
+++ b/drivers/usb/typec/pd.c
@@ -428,6 +428,7 @@ static int add_pdo(struct usb_power_delivery_capabilities *cap, u32 pdo, int pos
 	p->dev.parent = &cap->dev;
 	p->dev.type = type;
 	dev_set_name(&p->dev, "%u:%s", position + 1, name);
+	device_set_pm_not_required(&p->dev);
 
 	ret = device_register(&p->dev);
 	if (ret) {
@@ -490,6 +491,7 @@ usb_power_delivery_register_capabilities(struct usb_power_delivery *pd,
 	cap->dev.parent = &pd->dev;
 	cap->dev.type = &pd_capabilities_type;
 	dev_set_name(&cap->dev, "%s", cap_name[cap->role]);
+	device_set_pm_not_required(&cap->dev);
 
 	ret = device_register(&cap->dev);
 	if (ret) {
@@ -626,6 +628,7 @@ usb_power_delivery_register(struct device *parent, struct usb_power_delivery_des
 	pd->dev.type = &pd_type;
 	pd->dev.class = &pd_class;
 	dev_set_name(&pd->dev, "pd%d", pd->id);
+	device_set_pm_not_required(&pd->dev);
 
 	ret = device_register(&pd->dev);
 	if (ret) {
diff --git a/drivers/usb/typec/retimer.c b/drivers/usb/typec/retimer.c
index 0481e82..99105c9 100644
--- a/drivers/usb/typec/retimer.c
+++ b/drivers/usb/typec/retimer.c
@@ -122,6 +122,7 @@ typec_retimer_register(struct device *parent, const struct typec_retimer_desc *d
 	retimer->dev.class = &retimer_class;
 	retimer->dev.type = &typec_retimer_dev_type;
 	retimer->dev.driver_data = desc->drvdata;
+	device_set_pm_not_required(&retimer->dev);
 	dev_set_name(&retimer->dev, "%s-retimer",
 		     desc->name ? desc->name : dev_name(parent));
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: typec: disable pm for typec class devices
  2023-02-07  6:42 [PATCH] usb: typec: disable pm for typec class devices Linyu Yuan
@ 2023-02-07  7:34 ` Heikki Krogerus
  2023-02-07  8:07   ` Linyu Yuan
  0 siblings, 1 reply; 4+ messages in thread
From: Heikki Krogerus @ 2023-02-07  7:34 UTC (permalink / raw)
  To: Linyu Yuan
  Cc: Greg Kroah-Hartman, linux-usb, Jack Pham, Wesley Cheng, Pratham Pratap

On Tue, Feb 07, 2023 at 02:42:02PM +0800, Linyu Yuan wrote:
> as there is no pm operation, call device_set_pm_not_required() to disable
> all typec class devices.
> 
> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
>  drivers/usb/typec/class.c   | 5 +++++
>  drivers/usb/typec/mux.c     | 2 ++
>  drivers/usb/typec/pd.c      | 3 +++
>  drivers/usb/typec/retimer.c | 1 +
>  4 files changed, 11 insertions(+)

Now this is just boilerplate.

Why not propose this to be done in core for every new device that
doesn't have a bus, and that doesn't have the pm ops assigned in the
device type?


> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index ed3d070..b75ec6d 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -548,6 +548,7 @@ typec_register_altmode(struct device *parent,
>  	alt->adev.dev.groups = alt->groups;
>  	alt->adev.dev.type = &typec_altmode_dev_type;
>  	dev_set_name(&alt->adev.dev, "%s.%u", dev_name(parent), id);
> +	device_set_pm_not_required(&alt->adev.dev);

Note that for alt modes you can't do this. They can be bind to
drivers - there is a bus for them.

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: typec: disable pm for typec class devices
  2023-02-07  7:34 ` Heikki Krogerus
@ 2023-02-07  8:07   ` Linyu Yuan
  2023-02-07  9:03     ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: Linyu Yuan @ 2023-02-07  8:07 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Greg Kroah-Hartman, linux-usb, Jack Pham, Wesley Cheng, Pratham Pratap


On 2/7/2023 3:34 PM, Heikki Krogerus wrote:
> On Tue, Feb 07, 2023 at 02:42:02PM +0800, Linyu Yuan wrote:
>> as there is no pm operation, call device_set_pm_not_required() to disable
>> all typec class devices.
>>
>> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>> ---
>>   drivers/usb/typec/class.c   | 5 +++++
>>   drivers/usb/typec/mux.c     | 2 ++
>>   drivers/usb/typec/pd.c      | 3 +++
>>   drivers/usb/typec/retimer.c | 1 +
>>   4 files changed, 11 insertions(+)
> Now this is just boilerplate.
>
> Why not propose this to be done in core for every new device that
> doesn't have a bus, and that doesn't have the pm ops assigned in the
> device type?


thanks, will try.


>
>> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
>> index ed3d070..b75ec6d 100644
>> --- a/drivers/usb/typec/class.c
>> +++ b/drivers/usb/typec/class.c
>> @@ -548,6 +548,7 @@ typec_register_altmode(struct device *parent,
>>   	alt->adev.dev.groups = alt->groups;
>>   	alt->adev.dev.type = &typec_altmode_dev_type;
>>   	dev_set_name(&alt->adev.dev, "%s.%u", dev_name(parent), id);
>> +	device_set_pm_not_required(&alt->adev.dev);
> Note that for alt modes you can't do this. They can be bind to
> drivers - there is a bus for them.


but even in the bus, there is power management,

struct bus_type typec_bus = {
     .name = "typec",
     .dev_groups = typec_groups,
     .match = typec_match,
     .uevent = typec_uevent,
     .probe = typec_probe,
     .remove = typec_remove,
};


we can disable it, right ?


>
> thanks,
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: typec: disable pm for typec class devices
  2023-02-07  8:07   ` Linyu Yuan
@ 2023-02-07  9:03     ` Heikki Krogerus
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2023-02-07  9:03 UTC (permalink / raw)
  To: Linyu Yuan
  Cc: Greg Kroah-Hartman, linux-usb, Jack Pham, Wesley Cheng, Pratham Pratap

On Tue, Feb 07, 2023 at 04:07:17PM +0800, Linyu Yuan wrote:
> > Note that for alt modes you can't do this. They can be bind to
> > drivers - there is a bus for them.
> 
> but even in the bus, there is power management,
> 
> struct bus_type typec_bus = {
>     .name = "typec",
>     .dev_groups = typec_groups,
>     .match = typec_match,
>     .uevent = typec_uevent,
>     .probe = typec_probe,
>     .remove = typec_remove,
> };
> 
> we can disable it, right ?

No. It does not matter if the bus does not have the PM ops, a driver
can still supply the PM ops for the device.

Check how it's handled in drivers/base/power/main.c. Basically, if the
bus, pm domain, device type, or the class don't supply the PM ops,
the drivers own PM ops are then just used directly.

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-07  9:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07  6:42 [PATCH] usb: typec: disable pm for typec class devices Linyu Yuan
2023-02-07  7:34 ` Heikki Krogerus
2023-02-07  8:07   ` Linyu Yuan
2023-02-07  9:03     ` Heikki Krogerus

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.