Page MenuHomeFreeBSD

D59673.id186708.diff
No OneTemporary

D59673.id186708.diff

diff --git a/sys/dev/amdsmu/amdsmu.h b/sys/dev/amdsmu/amdsmu.h
--- a/sys/dev/amdsmu/amdsmu.h
+++ b/sys/dev/amdsmu/amdsmu.h
@@ -123,6 +123,7 @@
struct eventhandler_entry *eh_suspend;
struct eventhandler_entry *eh_resume;
+ struct eventhandler_entry *eh_diagnose;
struct resource *res;
bus_space_tag_t bus_tag;
diff --git a/sys/dev/amdsmu/amdsmu.c b/sys/dev/amdsmu/amdsmu.c
--- a/sys/dev/amdsmu/amdsmu.c
+++ b/sys/dev/amdsmu/amdsmu.c
@@ -317,6 +317,51 @@
amdsmu_fetch_idlemask(dev);
}
+static void
+amdsmu_diagnose(device_t dev, enum power_stype stype)
+{
+ struct amdsmu_softc *sc = device_get_softc(dev);
+ struct amdsmu_metrics *m = &sc->metrics;
+ bool any_blocking = false;
+
+ if (stype != POWER_STYPE_SUSPEND_TO_IDLE)
+ return;
+ if (m->s0i3_last_entry_status != 0)
+ return;
+
+ device_printf(dev,
+ "failed to enter S0i3 during last suspend; "
+ "battery drain will be excessive\n");
+
+ if (sc->product->amdsmu_deviceid != PCI_DEVICEID_AMD_PHOENIX_ROOT) {
+ device_printf(dev, "only limited diagnostic information "
+ "available for %x:%x; check dev.amdsmu.0 sysctl tree\n",
+ sc->product->amdsmu_vendorid,
+ sc->product->amdsmu_deviceid);
+ return;
+ }
+
+ for (size_t i = 0; i < sc->product->ip_block_count; i++) {
+ /*
+ * An IP block only truly blocked S0i3 entry if it was active
+ * for the entire time spent in sw_drips.
+ */
+ if (m->ip_block_last_active_time[i] < m->time_last_in_sw_drips)
+ continue;
+ if (!any_blocking) {
+ device_printf(dev,
+ "IP blocks that blocked S0i3 entry:\n");
+ any_blocking = true;
+ }
+ device_printf(dev, " %s (active for %ju us)\n",
+ sc->product->ip_blocks_names[i],
+ (uintmax_t)m->ip_block_last_active_time[i]);
+ }
+
+ if (!any_blocking)
+ device_printf(dev, "no IP block info available\n");
+}
+
static int
amdsmu_attach(device_t dev)
{
@@ -461,6 +506,8 @@
amdsmu_suspend, dev, EVENTHANDLER_PRI_LAST);
sc->eh_resume = EVENTHANDLER_REGISTER(acpi_pre_dev_resume,
amdsmu_resume, dev, EVENTHANDLER_PRI_FIRST);
+ sc->eh_diagnose = EVENTHANDLER_REGISTER(power_resume,
+ amdsmu_diagnose, dev, EVENTHANDLER_PRI_ANY);
#endif
return (0);
@@ -482,6 +529,7 @@
#if defined(DEV_ACPI)
EVENTHANDLER_DEREGISTER(acpi_post_dev_suspend, sc->eh_suspend);
EVENTHANDLER_DEREGISTER(acpi_pre_dev_resume, sc->eh_resume);
+ EVENTHANDLER_DEREGISTER(power_resume, sc->eh_diagnose);
#endif
bus_space_unmap(sc->bus_tag, sc->smu_space, SMU_MEM_SIZE);

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 28, 8:39 PM (3 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38977226
Default Alt Text
D59673.id186708.diff (2 KB)

Event Timeline