Skip to content

Commit c9ca8de

Browse files
superm1gregkh
authored andcommitted
usb: typec: ucsi: Use GET_CAPABILITY attributes data to set power supply scope
On some OEM systems, adding a W7900 dGPU triggers RAS errors and hangs at a black screen on startup. This issue occurs only if `ucsi_acpi` has loaded before `amdgpu` has loaded. The reason for this failure is that `amdgpu` uses power_supply_is_system_supplied() to determine if running on AC or DC power at startup. If this value is reported incorrectly the dGPU will also be programmed incorrectly and trigger errors. power_supply_is_system_supplied() reports the wrong value because UCSI power supplies provided as part of the system don't properly report the scope as "DEVICE" scope (not powering the system). In order to fix this issue check the capabilities reported from the UCSI power supply to ensure that it supports charging a battery and that it can be powered by AC. Mark the scope accordingly. Cc: [email protected] Fixes: a7fbfd4 ("usb: typec: ucsi: Mark dGPUs as DEVICE scope") Link: https://www.intel.com/content/www/us/en/products/docs/io/universal-serial-bus/usb-type-c-ucsi-spec.html p28 Reviewed-by: Sebastian Reichel <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Acked-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dddb91c commit c9ca8de

File tree

1 file changed

+9
-0
lines changed
  • drivers/usb/typec/ucsi

1 file changed

+9
-0
lines changed

drivers/usb/typec/ucsi/psy.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ static int ucsi_psy_get_scope(struct ucsi_connector *con,
3737
struct device *dev = con->ucsi->dev;
3838

3939
device_property_read_u8(dev, "scope", &scope);
40+
if (scope == POWER_SUPPLY_SCOPE_UNKNOWN) {
41+
u32 mask = UCSI_CAP_ATTR_POWER_AC_SUPPLY |
42+
UCSI_CAP_ATTR_BATTERY_CHARGING;
43+
44+
if (con->ucsi->cap.attributes & mask)
45+
scope = POWER_SUPPLY_SCOPE_SYSTEM;
46+
else
47+
scope = POWER_SUPPLY_SCOPE_DEVICE;
48+
}
4049
val->intval = scope;
4150
return 0;
4251
}

0 commit comments

Comments
 (0)