diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "pci.h" DEFINE_MUTEX(pci_slot_mutex); @@ -1331,7 +1332,7 @@ bool need_restore; pci_power_t state; u16 pmcsr; - int ret; + int ret, platform_ret, config_ret; /* * When setting power state to D0, platform_pci_set_power_state() @@ -1343,7 +1344,7 @@ * In all cases, the device is either Configuration-Ready or * inaccessible upon return. */ - platform_pci_set_power_state(dev, PCI_D0); + platform_ret = platform_pci_set_power_state(dev, PCI_D0); if (!dev->pm_cap) { state = platform_pci_get_power_state(dev); @@ -1360,7 +1361,9 @@ return -EIO; } - pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); + config_ret = pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); + trace_pci_power_up_pmcsr(pci_name(dev), dev->current_state, platform_ret, + config_ret, pmcsr); if (PCI_POSSIBLE_ERROR(pmcsr)) { pci_err(dev, "Unable to change power state from %s to D0, device inaccessible\n", pci_power_name(dev->current_state)); diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c --- a/drivers/platform/x86/amd/pmc/pmc.c +++ b/drivers/platform/x86/amd/pmc/pmc.c @@ -31,6 +31,7 @@ #include #include +#include #include "pmc.h" @@ -775,7 +776,9 @@ } } + trace_amd_pmc_s2idle_hint(pdev->cpu_info->os_hint, arg, true, 0); rc = amd_pmc_send_cmd(pdev, arg, NULL, pdev->cpu_info->os_hint, false); + trace_amd_pmc_s2idle_hint(pdev->cpu_info->os_hint, arg, false, rc); if (rc) { dev_err(pdev->dev, "suspend failed: %d\n", rc); return; @@ -819,7 +822,9 @@ struct amd_pmc_dev *pdev = &pmc; int rc; + trace_amd_pmc_s2idle_hint(pdev->cpu_info->os_hint, 0, true, 0); rc = amd_pmc_send_cmd(pdev, 0, NULL, pdev->cpu_info->os_hint, false); + trace_amd_pmc_s2idle_hint(pdev->cpu_info->os_hint, 0, false, rc); if (rc) dev_err(pdev->dev, "resume failed: %d\n", rc); diff --git a/include/trace/events/power.h b/include/trace/events/power.h --- a/include/trace/events/power.h +++ b/include/trace/events/power.h @@ -286,6 +286,59 @@ (__entry->start)?"begin":"end") ); +TRACE_EVENT(amd_pmc_s2idle_hint, + + TP_PROTO(u8 message, u32 argument, bool start, int ret), + + TP_ARGS(message, argument, start, ret), + + TP_STRUCT__entry( + __field(u8, message) + __field(u32, argument) + __field(bool, start) + __field(int, ret) + ), + + TP_fast_assign( + __entry->message = message; + __entry->argument = argument; + __entry->start = start; + __entry->ret = ret; + ), + + TP_printk("message=0x%02x argument=0x%08x %s ret=%d", + __entry->message, __entry->argument, + __entry->start ? "begin" : "end", __entry->ret) +); + +TRACE_EVENT(pci_power_up_pmcsr, + + TP_PROTO(const char *device, int state, int platform_ret, + int config_ret, u16 pmcsr), + + TP_ARGS(device, state, platform_ret, config_ret, pmcsr), + + TP_STRUCT__entry( + __string(device, device) + __field(int, state) + __field(int, platform_ret) + __field(int, config_ret) + __field(u16, pmcsr) + ), + + TP_fast_assign( + __assign_str(device); + __entry->state = state; + __entry->platform_ret = platform_ret; + __entry->config_ret = config_ret; + __entry->pmcsr = pmcsr; + ), + + TP_printk("%s state=%d platform_ret=%d config_ret=%d pmcsr=0x%04x", + __get_str(device), __entry->state, __entry->platform_ret, + __entry->config_ret, __entry->pmcsr) +); + DECLARE_EVENT_CLASS(wakeup_source, TP_PROTO(const char *name, unsigned int state), diff --git a/kernel/trace/power-traces.c b/kernel/trace/power-traces.c --- a/kernel/trace/power-traces.c +++ b/kernel/trace/power-traces.c @@ -15,6 +15,7 @@ #include EXPORT_TRACEPOINT_SYMBOL_GPL(suspend_resume); +EXPORT_TRACEPOINT_SYMBOL_GPL(amd_pmc_s2idle_hint); EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle); EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_frequency);