From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 911DD3321DC for ; Tue, 23 Dec 2025 17:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766512742; cv=none; b=PwBTr89AhXgsjBS+yoEothH2MZCEfjBT8N+loWxbGHZp4ir7FUx8RwLEB89mTtUMHDk+noByM/fszM57e9JgNLqhTXbVvPv+B7yOnGCFbuLZtn84sdEvMudHqCrWpZCJ1rrWJ6OnbODAT5pqPufhlMNuRa0uH5b4l0hwbyMD2qA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766512742; c=relaxed/simple; bh=NSLbG7k16GHwh64UuDTkXVvGJQLbrCn9gOsXTPfAXUQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=B1qBxWAYzWM2wpnJEuQwGYEtCs0yksnbYW9bj52pMI68oDxPgYjTAWXvT+0ootuyE/gJv2oU+3QxJHfFhthYloNj3W2f4S8tXhCGKHVaQDoG5ariThZPL8vaYWGDTphewSfjtyiABHJo5KDemp29zSwDFN1kJT+pqOjCql02vyg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NEY0eYEI; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NEY0eYEI" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-34c5f0222b0so4449096a91.3 for ; Tue, 23 Dec 2025 09:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766512739; x=1767117539; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Zr5Vb0BogJKiOUbdvmBcbYwly4N5xAVsR+G95NUYqwU=; b=NEY0eYEI/SdIPPFFDSMAs5Rn4V8vKyo+nHgM5mV8RvZKe7G+s/dvTTBKWW5Q7Tg6/M 9Am8uXwgVpekgEWkC5Wt6n47TGliuWTnQMfUAz87kMVGUMH3l1vmv/ufAt/0hDkhp20E LwxqQIIfxPEgbKY7Yt4c64z7pv+J/QbPniWt4fnb5f6tkiIXEkLtJOMT7J1WvtY3vmLj 0QoFIL3dNJkr4zhPV4gXzdwKev0kGkGHZmqQxwcxC2h+vfJoY14JwffvU81VRquLgSrz 4RX76FxWc1t13ZrRcGJgWeJM4UjLePdmf6DmPaQv74fc0xDb1yAWggNrJ0kAcLZA0oZH ipUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766512739; x=1767117539; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Zr5Vb0BogJKiOUbdvmBcbYwly4N5xAVsR+G95NUYqwU=; b=ZZsT9V4yAOWVF2JLSTcLBx52DjPD1cSGC6BqGMKTrLrpUOAlkO3l9ZDQp1aIFg7j1Y wvP8N/wER9lptPfai4uzW0d+MeZqM5aXQJJ4rLVDO8l3AxiAvmzQWT08VUqyp7lhRNHZ 6xAeMWdoAosEXQai8Pe1TFVDpV6uFr1iFhNeRx8gqni8svxTJ7OJ2QTIMYa6bwJZzRUk CrjGYpcQ6B1vu1nUsAd44gf6G2viTl1Fs+Vqi8/YeYw7PX7pIq5mpNQ8Yok2aEDduXAw pl90/wllw+noGpINJHNBxvOh5V0rSESKGuXbprTveDnJ8/TAr+aNVdR9DWIQmZ8gPPYs wmKg== X-Forwarded-Encrypted: i=1; AJvYcCUNF572MI523aJnS2qMvOw715Crhn1lpiuuSGUuG+VGElA8s/fk7EJHVtvh3WN/I6imvMYgpSdjjWNnsio=@vger.kernel.org X-Gm-Message-State: AOJu0YxLoxAGQvXye1JyklmOi3PxLJ+ycOcuTtIwCLOItT5VDukA/3Ra EOhK2/KLwzzaKTUO8Dm7NyFjim8s4/zpOhtqVLvbin4YRxbcuq6j+21CplTeFA== X-Gm-Gg: AY/fxX7KXuZkUhP/Yt2tZjKCs/wEnuRdIMhYHxtDboGKbkzY5UJl9hz2oSjOyO4gL9f YGXGiuP9dEp68n/zdcZJOSTsGOn687Eq+QNPAibxCavCPctGP615yjkDdWfIDDqoafHnCLkIVEE hgjHXov1dhBq27LKpGWiOnsFyFJwTC2XL4Qa67qwkjxUFu6vghh6MXSADRZXCfRmlcEYie3anB3 Fe0T5IfN7C5F87d5qPpz76VulcOsJlokcpJEjjlC5GA0kWHABniMcnfbQ8XzjAiqZloh3EBXOZ3 Sq+ff165BvsL6qpj2sS9LuE05fo4SE1Hos+/kXm14VAI/Utaa3CWUEP9rYHL0dl6yjXtR0POqsG 3Yh7mor8+GfzajBO9j7ZP4olJm5bVCEVpsZ7jUevmVrlkYvCWJlux90P/EqxJFCsU+7Tgg1EmV5 fX0Bjy+s1CyZ3tFfQ2hNBchJxsV6jMxXIi1L4c8x5BZ6oMEzt+8HrTSFgATg== X-Google-Smtp-Source: AGHT+IFhqQKduDJCfsD5RaFoKWHJcnglvJKlFNKC8PLYsYszv7n7wlJteXwixcj77TLrniWu3mrpwQ== X-Received: by 2002:a17:90b:2248:b0:340:7b2e:64cc with SMTP id 98e67ed59e1d1-34e921353d3mr13517616a91.15.1766512738505; Tue, 23 Dec 2025 09:58:58 -0800 (PST) Received: from ?IPV6:2405:201:3006:188a:d6f5:9bc4:b71e:1f14? ([2405:201:3006:188a:d6f5:9bc4:b71e:1f14]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34e921b165bsm13399870a91.6.2025.12.23.09.58.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Dec 2025 09:58:57 -0800 (PST) Message-ID: <07640446-b277-418e-95ab-6ee7ac75a66c@gmail.com> Date: Tue, 23 Dec 2025 17:58:52 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/2] platform/x86: thinkpad_acpi: Add support to detect hardware damage detection capability. To: =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, LKML , njoshi1@lenovo.com, Mark Pearson References: <20251217065523.48399-1-nitjoshi@gmail.com> <5ba8fe79-ff4f-2dc1-f80d-8e3a32a29efa@linux.intel.com> Content-Language: en-US From: Nitin Joshi In-Reply-To: <5ba8fe79-ff4f-2dc1-f80d-8e3a32a29efa@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/23/25 12:14, Ilpo Järvinen wrote: > On Wed, 17 Dec 2025, Nitin Joshi wrote: > >> Thinkpads are adding the ability to detect and report hardware damage >> status. Add new sysfs interface to identify whether hardware damage >> is detected or not. >> >> Initial support is available for the USB-C replaceable connector. >> >> Reviewed-by: Mark Pearson >> Signed-off-by: Nitin Joshi >> --- >> Changes since v1: >> -Split patch between hwdd_status and hwdd_detail >> -Incorporated review comments >> Changes since v2: >> -Control visibility of the sysfs attribute based upon ucdd_supported >> Changes since v3: >> -Fix documentation build warning >> Changes since v4: >> -Removed extra line >> --- >> .../admin-guide/laptops/thinkpad-acpi.rst | 21 ++++ >> drivers/platform/x86/lenovo/thinkpad_acpi.c | 105 ++++++++++++++++++ >> 2 files changed, 126 insertions(+) >> >> diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst b/Documentation/admin-guide/laptops/thinkpad-acpi.rst >> index 4ab0fef7d440..2db05f718b11 100644 >> --- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst >> +++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst >> @@ -54,6 +54,7 @@ detailed description): >> - Setting keyboard language >> - WWAN Antenna type >> - Auxmac >> + - Hardware damage detection capability >> >> A compatibility table by model and feature is maintained on the web >> site, http://ibm-acpi.sf.net/. I appreciate any success or failure >> @@ -1576,6 +1577,26 @@ percentage level, above which charging will stop. >> The exact semantics of the attributes may be found in >> Documentation/ABI/testing/sysfs-class-power. >> >> +Hardware damage detection capability >> +------------------------------------ >> + >> +sysfs attributes: hwdd_status >> + >> +Thinkpads are adding the ability to detect and report hardware damage. >> +Add new sysfs interface to identify the damaged device status. >> +Initial support is available for the USB-C replaceable connector. >> + >> +The command to check device damaged status is:: >> + >> + cat /sys/devices/platform/thinkpad_acpi/hwdd_status >> + >> +This value displays status of device damaged >> +- 0 = Not Damaged >> +- 1 = Damaged >> + >> +The property is read-only. If feature is not supported then sysfs >> +attribute is not created. >> + >> Multiple Commands, Module Parameters >> ------------------------------------ >> >> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c >> index cc19fe520ea9..cb1f6dae9334 100644 >> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c >> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c >> @@ -11080,6 +11080,106 @@ static const struct attribute_group auxmac_attr_group = { >> .attrs = auxmac_attributes, >> }; >> >> +/************************************************************************* >> + * HWDD subdriver, for the Lenovo Hardware Damage Detection feature. >> + */ >> + >> +#define HWDD_GET_DMG_USBC 0x80000001 >> +#define HWDD_GET_CAP 0 >> +#define HWDD_NOT_SUPPORTED BIT(31) >> +#define HWDD_SUPPORT_USBC BIT(0) >> + >> +#define PORT_STATUS GENMASK(7, 4) >> +#define NUM_PORTS 4 >> + >> +static bool hwdd_support_available; >> +static bool ucdd_supported; >> + >> +static int hwdd_command(int command, int *output) >> +{ >> + acpi_handle hwdd_handle; >> + >> + if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "HWDD", &hwdd_handle))) >> + return -ENODEV; >> + >> + if (!acpi_evalf(hwdd_handle, output, NULL, "dd", command)) >> + return -EIO; >> + >> + return 0; >> +} >> + >> +/* sysfs type-c damage detection capability */ >> +static ssize_t hwdd_status_show(struct device *dev, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + unsigned int damage_status, port_status; >> + int err, i; >> + >> + if (ucdd_supported) { >> + /* Get USB TYPE-C damage status */ >> + err = hwdd_command(HWDD_GET_DMG_USBC, &damage_status); >> + if (err) >> + return err; >> + >> + port_status = FIELD_GET(PORT_STATUS, damage_status); >> + for (i = 0; i < NUM_PORTS; i++) { >> + if (!(damage_status & BIT(i))) >> + continue; >> + if (port_status & BIT(i)) >> + return sysfs_emit(buf, "1\n"); >> + } >> + } else >> + return -ENODEV; > The usual approach is to first check not supported + return errno, then > you don't even need "else". The same comment to the other patch. Ack , I will modify it and send next revision. Thank you for review.