[TRACKING] Anyone else seeing USBCON PD Error spam in dmesg (User Request)

Ok so i’ve been getting these with various kernel combinations persistently and it appears to be related to the USB Controller and whatever probe reporting of state failing to get acknowledged. It’s triggered more by Plug/Unplug power events but i’ve seen it when sitting connected and resuming from hibernate/sleep.

Am wondering if this is just me or are other seeing this and what is it?

Happens on FC39 6.5 kernel 6.6 upstream vanilla and 6.7 Fedora rawhide.

Depending on what side/USB connector slot i plug/unplug I can vary the USBC000 to vary in enumeration.

Happy to post full logs.

3 Likes

I found this thread : [RESPONDED] AMD F39 USB-C hiccups with external display directly connected via USB-C - #8 by adrian.alanis

Which seems related, but I am not connecting anything other the supplied USB-C PD charger when this triggers.

Hi @jwp ,

Just trying to confirm, This particularly on AMD for you?

Yup AMD; I also would like to query what and how the cros_ec_lpc is used on the amd platform. It fails to pass checksum check with the ectool efi and doesn’t seem to load with the cros_ec_lpc driver.

Filing this now with the engineering team. Thanks

I’m just building a rawhide kernel with the non-accepted patchwork series now ;

Apparently this needs a v2 submission to get into mainline :

Patch series attached

From patchwork Thu Oct  5 16:06:59 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: "Dustin L. Howett" <dustin@howett.net>
X-Patchwork-Id: 13410302
Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com
 [209.85.219.41])
	(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 223E030D17
	for <chrome-platform@lists.linux.dev>; Thu,  5 Oct 2023 16:07:51 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=none (p=none dis=none) header.from=howett.net
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=howett.net
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=howett-net.20230601.gappssmtp.com
 header.i=@howett-net.20230601.gappssmtp.com header.b="U+3733Yr"
Received: by mail-qv1-f41.google.com with SMTP id
 6a1803df08f44-65af1037ca8so6022386d6.2
        for <chrome-platform@lists.linux.dev>;
 Thu, 05 Oct 2023 09:07:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=howett-net.20230601.gappssmtp.com; s=20230601; t=1696522071;
 x=1697126871; darn=lists.linux.dev;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=aIKhewsUzhXlGubPiW58tzOjf5y8/qBow8TkSh16ct0=;
        b=U+3733YrHwhV3S2LQUmguQ4zO3f/wlqBfxAVP17EJFLHnc1XPAwmnSo1LoawUUw/y9
         KT5qE76hiloISwNkrITXApoeKxf7FDbWo4NfXbE24S0wGCdoU/lKiosm2P3sQY1kI3mV
         cNo7rvAp8BBOo/7Q1KKSwQDyCAdzhcUFg/sl0QzNsbH9JJhzMnTbGqcuTHqj7AZi3G8j
         vRLuovYcy5+JbOv37OVDy4fwrtxh/LiPb7orkmw+Ga6xt/bhlfbgkc1Ta5rHpxw+8c3H
         NQVNWtHWejRTsdfiEbXvhwJoVlp3RcVonuoF9SnqCdyzDUWCsnWWmi/nDAwA6XBMHJJh
         1yEA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1696522071; x=1697126871;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=aIKhewsUzhXlGubPiW58tzOjf5y8/qBow8TkSh16ct0=;
        b=iUMYDDsV3XBkGv7v1Z4qACa1bF1SaoN4/T0ST4+M6NR03YKhLWA1TgbaDja1TYim37
         9o6ag/J/ClOn18cpuUF0Vph5BSZL99TfDkWyz73hweXNzlTfTHIIqHirxnx4dBm7XE+X
         tXS+1hxZl/zXMA0kx+TolOX13SLvN9etyn5BcMn1c02IIVd0CzGfnSFvuFVXL1fk1Ajz
         Sr//8DFCcKbLnEf9gVrO7EwMZbGYYLqxA2uImasy/bMQRt91ZJzkFBrkL/5wypamZMod
         lORbpdgBEcJkETitoDrn+5qfZY2aAZBMwjvMFMhFB6GbFtTrocz5A9EoEgjK2yz3enSV
         EGDg==
X-Gm-Message-State: AOJu0YxtjtYa0Z79TZZhCOKMCB1shhn7cs9mo5ZR52d39CdbMGv/oJVd
	R2ZFfs1+gUdorZxTYfzG2SAhD4ABe5P6D7oYk6B6cw==
X-Google-Smtp-Source: 
 AGHT+IENbbnztfC5zYQ3C6sRr7dhQcz2+L/+nXUmgWY3mQBnPpTTm/XHG1yMc2sAaxngc1mlll/gjA==
X-Received: by 2002:a05:6214:3209:b0:63d:2cc7:bef9 with SMTP id
 qj9-20020a056214320900b0063d2cc7bef9mr5264097qvb.37.1696522070956;
        Thu, 05 Oct 2023 09:07:50 -0700 (PDT)
Received: from tycho.delfino.n.howett.net
 (99-107-94-179.lightspeed.stlsmo.sbcglobal.net. [99.107.94.179])
        by smtp.googlemail.com with ESMTPSA id
 k3-20020a0cabc3000000b0063d5d173a51sm611422qvb.50.2023.10.05.09.07.50
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 05 Oct 2023 09:07:50 -0700 (PDT)
From: "Dustin L. Howett" <dustin@howett.net>
To: Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev,
	Kieran Levin <ktl@frame.work>,
	Mario Limonciello <Mario.Limonciello@amd.com>
Cc: "Dustin L. Howett" <dustin@howett.net>
Subject: [PATCH v1 1/4] cros_ec_lpc: introduce cros_ec_lpc,
 a priv struct for the lpc device
Date: Thu,  5 Oct 2023 11:06:59 -0500
Message-ID: <20231005160701.19987-3-dustin@howett.net>
X-Mailer: git-send-email 2.42.0
In-Reply-To: <20231005160701.19987-1-dustin@howett.net>
References: <20231005160701.19987-1-dustin@howett.net>
Precedence: bulk
X-Mailing-List: chrome-platform@lists.linux.dev
List-Id: <chrome-platform.lists.linux.dev>
List-Subscribe: <mailto:chrome-platform+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:chrome-platform+unsubscribe@lists.linux.dev>
MIME-Version: 1.0

cros_ec_lpc stores the MMIO port base for EC mapped memory.
cros_ec_lpc_readmem uses this port base instead of hardcoding
EC_LPC_ADDR_MEMMAP.

Signed-off-by: Dustin L. Howett <dustin@howett.net>
---
 drivers/platform/chrome/cros_ec_lpc.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 500a61b093e4..477e22e31757 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -34,6 +34,14 @@
 /* True if ACPI device is present */
 static bool cros_ec_lpc_acpi_device_found;
 
+/**
+ * struct cros_ec_lpc - LPC device-specific data
+ * @mmio_memory_base: The first I/O port addressing EC mapped memory.
+ */
+struct cros_ec_lpc {
+	u16 mmio_memory_base;
+};
+
 /**
  * struct lpc_driver_ops - LPC driver operations
  * @read: Copy length bytes from EC address offset into buffer dest. Returns
@@ -290,6 +298,7 @@ static int cros_ec_cmd_xfer_lpc(struct cros_ec_device *ec,
 static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
 			       unsigned int bytes, void *dest)
 {
+	struct cros_ec_lpc *ec_lpc = ec->priv;
 	int i = offset;
 	char *s = dest;
 	int cnt = 0;
@@ -299,13 +308,13 @@ static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
 
 	/* fixed length */
 	if (bytes) {
-		cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + offset, bytes, s);
+		cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + offset, bytes, s);
 		return bytes;
 	}
 
 	/* string */
 	for (; i < EC_MEMMAP_SIZE; i++, s++) {
-		cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + i, 1, s);
+		cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + i, 1, s);
 		cnt++;
 		if (!*s)
 			break;
@@ -353,9 +362,16 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	struct acpi_device *adev;
 	acpi_status status;
 	struct cros_ec_device *ec_dev;
+	struct cros_ec_lpc *ec_lpc;
 	u8 buf[2] = {};
 	int irq, ret;
 
+	ec_lpc = devm_kzalloc(dev, sizeof(*ec_lpc), GFP_KERNEL);
+	if (!ec_lpc)
+		return -ENOMEM;
+
+	ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
+
 	/*
 	 * The Framework Laptop (and possibly other non-ChromeOS devices)
 	 * only exposes the eight I/O ports that are required for the Microchip EC.
@@ -380,7 +396,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	cros_ec_lpc_ops.write = cros_ec_lpc_mec_write_bytes;
 	cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2, buf);
 	if (buf[0] != 'E' || buf[1] != 'C') {
-		if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE,
+		if (!devm_request_region(dev, ec_lpc->mmio_memory_base, EC_MEMMAP_SIZE,
 					 dev_name(dev))) {
 			dev_err(dev, "couldn't reserve memmap region\n");
 			return -EBUSY;
@@ -389,7 +405,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 		/* Re-assign read/write operations for the non MEC variant */
 		cros_ec_lpc_ops.read = cros_ec_lpc_read_bytes;
 		cros_ec_lpc_ops.write = cros_ec_lpc_write_bytes;
-		cros_ec_lpc_ops.read(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID, 2,
+		cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + EC_MEMMAP_ID, 2,
 				     buf);
 		if (buf[0] != 'E' || buf[1] != 'C') {
 			dev_err(dev, "EC ID not detected\n");
@@ -423,6 +439,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	ec_dev->din_size = sizeof(struct ec_host_response) +
 			   sizeof(struct ec_response_get_protocol_info);
 	ec_dev->dout_size = sizeof(struct ec_host_request);
+	ec_dev->priv = (void *)ec_lpc;
 
 	/*
 	 * Some boards do not have an IRQ allotted for cros_ec_lpc,

From patchwork Thu Oct  5 16:07:00 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: "Dustin L. Howett" <dustin@howett.net>
X-Patchwork-Id: 13410303
Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com
 [209.85.219.44])
	(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 B3B1D30D17
	for <chrome-platform@lists.linux.dev>; Thu,  5 Oct 2023 16:07:55 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=none (p=none dis=none) header.from=howett.net
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=howett.net
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=howett-net.20230601.gappssmtp.com
 header.i=@howett-net.20230601.gappssmtp.com header.b="lCOTfvFQ"
Received: by mail-qv1-f44.google.com with SMTP id
 6a1803df08f44-65b0dad1f98so6532086d6.0
        for <chrome-platform@lists.linux.dev>;
 Thu, 05 Oct 2023 09:07:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=howett-net.20230601.gappssmtp.com; s=20230601; t=1696522074;
 x=1697126874; darn=lists.linux.dev;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=ehTvxGrcWJf2GK4o99VJ+trJtzmEICjcGVrEWrEqVaY=;
        b=lCOTfvFQOt+tIvI8OEOiDdJQSmhR06z7pgR2WkZ5yTztx6dhanei3UWcLIld++Ozw4
         SeEX+Iz+6VVP/OM0MzR6PYX6PZr7gutm7/O/KKyixbMxpLDKX5D4fg82Z+sSvZSsnZNx
         ErozW+jCRKYIVHjDtfvjOkTUj6QUg+VGg1NDHEi8vkqn8Chmac7XJv2RFliaBUWin+lx
         KBfmeMscKuPE9BsKAyrHcZNlgr8z+EkZyQdPbw7on5ufDv1vEdGJ+B0NY6bYohpzBq8k
         1+M4/ezM1NgD3N+MkV6BfLF++y0bs/F5Ovn+lxHinVESVw/EV/kyGW+3a/VXQ4QqBZU7
         DyHA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1696522074; x=1697126874;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=ehTvxGrcWJf2GK4o99VJ+trJtzmEICjcGVrEWrEqVaY=;
        b=JLcA6ynWlv+LlvlT+T8Cy9IcxvC83Orr6XsEfqMpkjx/Vu5NLxjKgyNQ1usMz/DigR
         pq//s8yPtaNTTAQVliHx5z1R/CQm2KAn3zAm8cbCuHFrLO/9QLv26iVHQpITAjVXPPKs
         X46cuPDdJ+E1ZU8Cb2VelCLTxP6PM4M90NRxC7Hze9ThLxuMP1bvx80F4gwEe17IvuNU
         PKgqBSRh2eNDckKYmDSWb0PwCDKd/n+dY1aZz9dS686gNKB3vhtfhKPOj4tTxEdtUh3i
         jLkv0QuGcKr/JrX07k10Lmd8hEGxz9H1mxuuMQp4YuwkwBK1UmReLm1+3nwDe7iFPTAS
         bDzw==
X-Gm-Message-State: AOJu0YycbxPinPK1Or75h921ZS0+LForZFYEZ+2VZM+YSu57r1I7BBLt
	ClqJc9tjDtueh0HyW7yS7yUZZg==
X-Google-Smtp-Source: 
 AGHT+IHXnbsMFmV1xKigch6j93fZcdPPVsuNon2yqQpBMQzZpNCBWPEvX9o1ej3+mQyNPx2hLpRCJg==
X-Received: by 2002:a0c:b347:0:b0:65b:26d4:7fb6 with SMTP id
 a7-20020a0cb347000000b0065b26d47fb6mr4877067qvf.4.1696522074498;
        Thu, 05 Oct 2023 09:07:54 -0700 (PDT)
Received: from tycho.delfino.n.howett.net
 (99-107-94-179.lightspeed.stlsmo.sbcglobal.net. [99.107.94.179])
        by smtp.googlemail.com with ESMTPSA id
 k3-20020a0cabc3000000b0063d5d173a51sm611422qvb.50.2023.10.05.09.07.53
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 05 Oct 2023 09:07:54 -0700 (PDT)
From: "Dustin L. Howett" <dustin@howett.net>
To: Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev,
	Kieran Levin <ktl@frame.work>,
	Mario Limonciello <Mario.Limonciello@amd.com>
Cc: "Dustin L. Howett" <dustin@howett.net>
Subject: [PATCH v1 2/4] cros_ec_lpc: pass driver_data from DMI down to the
 device
Date: Thu,  5 Oct 2023 11:07:00 -0500
Message-ID: <20231005160701.19987-4-dustin@howett.net>
X-Mailer: git-send-email 2.42.0
In-Reply-To: <20231005160701.19987-1-dustin@howett.net>
References: <20231005160701.19987-1-dustin@howett.net>
Precedence: bulk
X-Mailing-List: chrome-platform@lists.linux.dev
List-Id: <chrome-platform.lists.linux.dev>
List-Subscribe: <mailto:chrome-platform+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:chrome-platform+unsubscribe@lists.linux.dev>
MIME-Version: 1.0

lpc_driver_data will be stored in drvdata until probe is complete, at
which point it will be replaced with an updated copy.

Signed-off-by: Dustin L. Howett <dustin@howett.net>
---
 drivers/platform/chrome/cros_ec_lpc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 477e22e31757..ef7943e6a01d 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -615,14 +615,17 @@ static int __init cros_ec_lpc_init(void)
 {
 	int ret;
 	acpi_status status;
+	const struct dmi_system_id *dmi_match;
 
 	status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
 				  &cros_ec_lpc_acpi_device_found, NULL);
 	if (ACPI_FAILURE(status))
 		pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
 
+	dmi_match = dmi_first_match(cros_ec_lpc_dmi_table);
+
 	if (!cros_ec_lpc_acpi_device_found &&
-	    !dmi_check_system(cros_ec_lpc_dmi_table)) {
+	    !dmi_match) {
 		pr_err(DRV_NAME ": unsupported system.\n");
 		return -ENODEV;
 	}
@@ -635,6 +638,9 @@ static int __init cros_ec_lpc_init(void)
 	}
 
 	if (!cros_ec_lpc_acpi_device_found) {
+		/* Pass the DMI match's driver data down to the platform device */
+		platform_set_drvdata(&cros_ec_lpc_device, dmi_match->driver_data);
+
 		/* Register the device, and it'll get hooked up automatically */
 		ret = platform_device_register(&cros_ec_lpc_device);
 		if (ret) {

From patchwork Thu Oct  5 16:07:01 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: "Dustin L. Howett" <dustin@howett.net>
X-Patchwork-Id: 13410304
Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com
 [209.85.210.45])
	(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 74DE134193
	for <chrome-platform@lists.linux.dev>; Thu,  5 Oct 2023 16:07:57 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=none (p=none dis=none) header.from=howett.net
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=howett.net
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=howett-net.20230601.gappssmtp.com
 header.i=@howett-net.20230601.gappssmtp.com header.b="v83MEWeA"
Received: by mail-ot1-f45.google.com with SMTP id
 46e09a7af769-6c4b9e09521so746949a34.3
        for <chrome-platform@lists.linux.dev>;
 Thu, 05 Oct 2023 09:07:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=howett-net.20230601.gappssmtp.com; s=20230601; t=1696522076;
 x=1697126876; darn=lists.linux.dev;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=DB/63q7co6BElMzwEVr8DBbzrAtv1Y7+8+dwDw13/rU=;
        b=v83MEWeAMwHCG0wStM+CUvM1xRO3zv/Bq29y2NgGHNs6AaxQo7eebD5+oDWiWVBFot
         8nPb7nh6SwRfbLc9b9f+VjcnbL4rni4vcmb3h4xd01TAHTYj8yo/41nIIZ6HMBmOKmwd
         lzVUVOKDXrPwSBS77ihS/5vzEmi1Oabhx2Jjj0ZNxY93bL6HJDjFfh1O3HKKke1aPL+f
         KXq/zH/MiYWLgNi0ZhLHUJvz3iNW5yz4z9j2POytSyOU056gMiyuAoOCtN8YvdbtP5n5
         Qlu/Dd8UiX9sV5y7xmduzBnlzr8S1MhrI/ToUpIPQRnxHLQjFvrtYpF0qBiU2BiohtWR
         6jOA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1696522076; x=1697126876;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=DB/63q7co6BElMzwEVr8DBbzrAtv1Y7+8+dwDw13/rU=;
        b=kN9G3HMbJKJDzTs3TMPudiLbHiPtLWvwNgF095ryG3b6yQyEM/zj/UFaxgWaByMQeS
         xvm9ZUUNuSqaO4A3i6eQ7Ysq3GCUIFIZnRUSELrvbx++gkXZgOtNSDSPQs0Vx6+bMNho
         WH4R9WF5nauFm7eBseg6Cp0NN3yMBz9YaBvUMeWa6WKPdUxCLjixsHoqT3/QBnUi3M96
         xz3inK6NfA6m8W2JfafyxamBJxWXI1xIMg68Sel1GcnArjeePtw2z+zOM4rsD2N+mEQx
         Qdxcn3cZsJz8rDTat3DOlZVM+5B1l1GvSjecwiVqClf5JzAKxBGl6loTWGq/pjp5vUdA
         FH8g==
X-Gm-Message-State: AOJu0Yxod0Tu4k6XgEMgJnhuJFYOCWI+TSs+Daz/TWenlLo70NQDsz3N
	ot0O7RaAX7rMgUhlT0MBr3kzWw==
X-Google-Smtp-Source: 
 AGHT+IF7BGzIpAcXRZ9L1lRMxSA0PcKYIKfM0MAZ2Fsnukx6tQuLwfpqxRdStuyFiP9QPC3HZRFT3A==
X-Received: by 2002:a9d:62d6:0:b0:6c4:c151:8ebe with SMTP id
 z22-20020a9d62d6000000b006c4c1518ebemr5819494otk.22.1696522076403;
        Thu, 05 Oct 2023 09:07:56 -0700 (PDT)
Received: from tycho.delfino.n.howett.net
 (99-107-94-179.lightspeed.stlsmo.sbcglobal.net. [99.107.94.179])
        by smtp.googlemail.com with ESMTPSA id
 k3-20020a0cabc3000000b0063d5d173a51sm611422qvb.50.2023.10.05.09.07.55
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 05 Oct 2023 09:07:55 -0700 (PDT)
From: "Dustin L. Howett" <dustin@howett.net>
To: Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev,
	Kieran Levin <ktl@frame.work>,
	Mario Limonciello <Mario.Limonciello@amd.com>
Cc: "Dustin L. Howett" <dustin@howett.net>
Subject: [PATCH v1 3/4] cros_ec_lpc: add a quirks system,
 and propagate quirks from DMI
Date: Thu,  5 Oct 2023 11:07:01 -0500
Message-ID: <20231005160701.19987-5-dustin@howett.net>
X-Mailer: git-send-email 2.42.0
In-Reply-To: <20231005160701.19987-1-dustin@howett.net>
References: <20231005160701.19987-1-dustin@howett.net>
Precedence: bulk
X-Mailing-List: chrome-platform@lists.linux.dev
List-Id: <chrome-platform.lists.linux.dev>
List-Subscribe: <mailto:chrome-platform+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:chrome-platform+unsubscribe@lists.linux.dev>
MIME-Version: 1.0

Some devices ship a ChromeOS EC in a non-standard configuration; quirks
allow cros_ec_lpc to account for these non-standard configurations.

It supports the following quirks:
- CROS_EC_LPC_QUIRK_REMAP_MEMORY: use a different port I/O base for
  MMIO to the EC's memory region
- CROS_EC_LPC_QUIRK_SHORT_HOSTCMD_RESERVATION: only attempt to reserve
  0xff (rather than 0x100) I/O ports for the host command region

Signed-off-by: Dustin L. Howett <dustin@howett.net>
---
 drivers/platform/chrome/cros_ec_lpc.c | 41 ++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index ef7943e6a01d..c06575625d2f 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -34,6 +34,27 @@
 /* True if ACPI device is present */
 static bool cros_ec_lpc_acpi_device_found;
 
+/* If this quirk is enabled, the driver will only reserve 0xFF I/O ports
+ * (rather than 0x100) for the host command mapped memory region.
+ */
+#define CROS_EC_LPC_QUIRK_SHORT_HOSTCMD_RESERVATION BIT(0)
+/* If this quirk is enabled, lpc_driver_data.quirk_mmio_memory_base will be used
+ * as the base port for EC mapped memory.
+ */
+#define CROS_EC_LPC_QUIRK_REMAP_MEMORY              BIT(1)
+
+/**
+ * struct lpc_driver_data - driver data attached to a DMI device ID to indicate
+ *                          hardware quirks.
+ * @quirks: a bitfield composed of quirks from CROS_EC_LPC_QUIRK_*
+ * @quirk_mmio_memory_base: The first I/O port addressing EC mapped memory (used
+ *                          when quirks (...REMAP_MEMORY) is set.
+ */
+struct lpc_driver_data {
+	u32 quirks;
+	u16 quirk_mmio_memory_base;
+};
+
 /**
  * struct cros_ec_lpc - LPC device-specific data
  * @mmio_memory_base: The first I/O port addressing EC mapped memory.
@@ -363,14 +384,32 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	acpi_status status;
 	struct cros_ec_device *ec_dev;
 	struct cros_ec_lpc *ec_lpc;
+	struct lpc_driver_data *driver_data;
+	int region1_size;
 	u8 buf[2] = {};
 	int irq, ret;
+	u32 quirks = 0;
 
 	ec_lpc = devm_kzalloc(dev, sizeof(*ec_lpc), GFP_KERNEL);
 	if (!ec_lpc)
 		return -ENOMEM;
 
 	ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP;
+	region1_size = EC_HOST_CMD_REGION_SIZE;
+
+	driver_data = platform_get_drvdata(pdev);
+	if (driver_data) {
+		quirks = driver_data->quirks;
+
+		if (quirks)
+			dev_warn(dev, "loaded with quirks %8.08x\n", quirks);
+
+		if (quirks & CROS_EC_LPC_QUIRK_REMAP_MEMORY)
+			ec_lpc->mmio_memory_base = driver_data->quirk_mmio_memory_base;
+
+		if (quirks & CROS_EC_LPC_QUIRK_SHORT_HOSTCMD_RESERVATION)
+			region1_size -= 1;
+	}
 
 	/*
 	 * The Framework Laptop (and possibly other non-ChromeOS devices)
@@ -420,7 +459,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 			return -EBUSY;
 		}
 		if (!devm_request_region(dev, EC_HOST_CMD_REGION1,
-					 EC_HOST_CMD_REGION_SIZE, dev_name(dev))) {
+					 region1_size, dev_name(dev))) {
 			dev_err(dev, "couldn't reserve region1\n");
 			return -EBUSY;
 		}

From patchwork Thu Oct  5 16:07:02 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: "Dustin L. Howett" <dustin@howett.net>
X-Patchwork-Id: 13410305
Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com
 [209.85.167.174])
	(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 D570A341A0
	for <chrome-platform@lists.linux.dev>; Thu,  5 Oct 2023 16:07:58 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
 dmarc=none (p=none dis=none) header.from=howett.net
Authentication-Results: smtp.subspace.kernel.org;
 spf=none smtp.mailfrom=howett.net
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=howett-net.20230601.gappssmtp.com
 header.i=@howett-net.20230601.gappssmtp.com header.b="BeWT67ks"
Received: by mail-oi1-f174.google.com with SMTP id
 5614622812f47-3af609c4dfeso750999b6e.1
        for <chrome-platform@lists.linux.dev>;
 Thu, 05 Oct 2023 09:07:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=howett-net.20230601.gappssmtp.com; s=20230601; t=1696522078;
 x=1697126878; darn=lists.linux.dev;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=fKbLM1rnC24y2SybHOTvD4S16XjSJ/8+LSwsuGXtOa4=;
        b=BeWT67ksS5pLD+ji40GmP1kj7AQNxaII6/u6AgPheJbZhHGL8AHAOAz8kcAbfRAXP2
         +rgVL06QJf5T/FcEZ+kc+N3oKls6Hn4zxP2WAghZrxJLZkP/ho19YZKGmfyKkRS/fUmT
         EqJD1P8bXsi4D1kcSQcXwR+AB1o8u/iqWZna/0SvCvu3/4b72WHCqbZahymWZzkmuYF5
         kS2gI5ZpVBPLZaJEU9mg1O69DLYB1KwVk6XmMQ3CMneUU+e94f4TfoY5dcKDcLDPxOvb
         iZO9nVdsEYuLwnXupo8KMzQLbbR3+W+oPRpXeFroRtm/zcEBxcCtsap9/A2nZeQi4fgM
         cNgQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1696522078; x=1697126878;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=fKbLM1rnC24y2SybHOTvD4S16XjSJ/8+LSwsuGXtOa4=;
        b=AgHZIpr+6owP0SseRZlQKXFK2bx+4XGP9/K/Q8JqbHjDHh023P/pd5KzlVHZlAR6IA
         TnhmF6iamNM6WEc3cBOliKJFanx0zEu4bjkpKslBOq8GoOUWzvpGCr/aNwqFrXWPFyAx
         YEgKsxYLG65Lp4JsjCeDeFNS2DgzxCYD0s3BP2jjRmxFaIqs5YQ2nnbTUb3pFyB88QHF
         WyBEa2+/NWjsAfRbmXXBZcK6ajRS7saulOdt78d4gO1bZCtJcKblQU8fbW0LqFWUHxDJ
         HnTS8sgyV5fL9FQfgWNlYDtgB+A4oQnyYov5SMM7jskkMw/WKAyUrDJToPD5pTDyUWxO
         cu6A==
X-Gm-Message-State: AOJu0Yw/nn1MbpKLCPEFO4kp5xqbWcr1rBOXBwAt9A/1o1PCj7xReoG/
	4KDkfI+xBlhaAY8LSV/oHelolg==
X-Google-Smtp-Source: 
 AGHT+IEeLkzw0C8OpIY4CAQLonFaWJ2iYDTxeVtdkqB8NZHvSHTijtq3YcbUsYv1TaXqQtEYiS6+MQ==
X-Received: by 2002:a05:6808:d52:b0:3a8:74bf:8977 with SMTP id
 w18-20020a0568080d5200b003a874bf8977mr6821402oik.56.1696522077896;
        Thu, 05 Oct 2023 09:07:57 -0700 (PDT)
Received: from tycho.delfino.n.howett.net
 (99-107-94-179.lightspeed.stlsmo.sbcglobal.net. [99.107.94.179])
        by smtp.googlemail.com with ESMTPSA id
 k3-20020a0cabc3000000b0063d5d173a51sm611422qvb.50.2023.10.05.09.07.57
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 05 Oct 2023 09:07:57 -0700 (PDT)
From: "Dustin L. Howett" <dustin@howett.net>
To: Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev,
	Kieran Levin <ktl@frame.work>,
	Mario Limonciello <Mario.Limonciello@amd.com>
Cc: "Dustin L. Howett" <dustin@howett.net>
Subject: [PATCH v1 4/4] cros_ec_lpc: add quirks for the Framework Laptop
Date: Thu,  5 Oct 2023 11:07:02 -0500
Message-ID: <20231005160701.19987-6-dustin@howett.net>
X-Mailer: git-send-email 2.42.0
In-Reply-To: <20231005160701.19987-1-dustin@howett.net>
References: <20231005160701.19987-1-dustin@howett.net>
Precedence: bulk
X-Mailing-List: chrome-platform@lists.linux.dev
List-Id: <chrome-platform.lists.linux.dev>
List-Subscribe: <mailto:chrome-platform+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:chrome-platform+unsubscribe@lists.linux.dev>
MIME-Version: 1.0

The original Framework Laptop contains a Microchip EC, but the newer
ones have switched to an NPCX EC which uses the standard linear MMIO
protocol for host commands and EC memory.

However, those newer Framework Laptops diverge from the standard
ChromeOS EC in two important ways:

1. The ACPI table for PNP0C09 only claims I/O ports 0x800 to 0x8FE
   instead of the traditional 0x8FF
2. The MMIO region for EC memory begins at port 0xE00 rather than the
   traditional 0x900.

cros_ec_lpc's quirks system addresses both of these issues.

Signed-off-by: Dustin L. Howett <dustin@howett.net>
---
 drivers/platform/chrome/cros_ec_lpc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index c06575625d2f..66285c66ff22 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -537,6 +537,13 @@ static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids);
 
+static const struct lpc_driver_data framework_laptop_lpc_driver_data __initconst = {
+	.quirks =
+		CROS_EC_LPC_QUIRK_REMAP_MEMORY |
+		CROS_EC_LPC_QUIRK_SHORT_HOSTCMD_RESERVATION,
+	.quirk_mmio_memory_base = 0xE00,
+};
+
 static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
 	{
 		/*
@@ -596,6 +603,7 @@ static const struct dmi_system_id cros_ec_lpc_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "Framework"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "Laptop"),
 		},
+		.driver_data = (void *)&framework_laptop_lpc_driver_data,
 	},
 	{ /* sentinel */ }
 };

type or paste code here
1 Like

The ucsi_acpi errors are still there in 6.7-rc1 which included a bunch of power-supply fixups for a large range of things. There seems to be some discussions about a usci draft 2.0 reference in chatter. I am wondering if there are some features on the PD controller in the AMD that will need to implement things that are likely going to require a rewrite of this subsystem.

1 Like

Chiming in with another report. FW13 AMD USB-C ports throw the same error for me when power is connected. Running 6.6.3-arch1-1. I haven’t yet noticed an issue with functionality, but I have only had the laptop for a week now. @jwp 's last comments went over my head, but if there are recent developments or any tests I can contribute, I’d appreciate any guidance. Thanks!

└─❯ journalctl -b --priority=3
2023-12-06T13:10:47-0800 framework kernel: cros_ec_lpcs cros_ec_lpcs.0: EC ID not detected
2023-12-06T13:10:50-0800 framework bluetoothd[989]: src/device.c:set_wake_allowed_complete() Set device flags return status: Invalid Parameters
2023-12-06T13:10:50-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-5)
2023-12-06T13:10:50-0800 framework kernel: ucsi_acpi USBC000:00: possible UCSI driver bug 1
2023-12-06T13:10:50-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-22)
2023-12-06T13:13:48-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-5)
2023-12-06T13:13:53-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-110)
2023-12-06T13:13:53-0800 framework kernel: ucsi_acpi USBC000:00: possible UCSI driver bug 1
2023-12-06T13:13:53-0800 framework kernel: ucsi_acpi USBC000:00: UCSI_GET_PDOS failed (-22)
2023-12-06T13:13:58-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
2023-12-06T13:27:09-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: failed to set a report to device: -121
2023-12-06T13:31:14-0800 framework kernel: i2c_designware AMDI0010:00: i2c_dw_handle_tx_abort: lost arbitration
2023-12-06T13:35:30-0800 framework kernel: i2c_designware AMDI0010:00: i2c_dw_handle_tx_abort: lost arbitration
2023-12-06T13:39:01-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T13:43:47-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T13:53:54-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T13:54:06-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T13:57:52-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T14:00:28-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T14:38:22-0800 framework kernel: [drm:mes_v11_0_submit_pkt_and_poll_completion.constprop.0 [amdgpu]] *ERROR* MES failed to response >
2023-12-06T14:38:22-0800 framework kernel: [drm:amdgpu_mes_reg_write_reg_wait [amdgpu]] *ERROR* failed to reg_write_reg_wait
2023-12-06T14:38:27-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
2023-12-06T14:38:33-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
2023-12-06T14:41:15-0800 framework kernel: i2c_designware AMDI0010:00: i2c_dw_handle_tx_abort: lost arbitration
2023-12-06T14:41:51-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T14:42:21-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T14:45:50-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
2023-12-06T14:46:31-0800 framework kernel: i2c_designware AMDI0010:00: i2c_dw_handle_tx_abort: lost arbitration
2023-12-06T14:47:08-0800 framework kernel: i2c_hid_acpi i2c-FRMW0005:00: i2c_hid_get_input: incomplete report (7/65535)
2023-12-06T14:48:27-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
2023-12-06T14:48:45-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
2023-12-06T14:49:41-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-5)
2023-12-06T14:49:41-0800 framework kernel: ucsi_acpi USBC000:00: unknown error 0
2023-12-06T14:49:41-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-5)
2023-12-06T14:49:46-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
2023-12-06T14:49:57-0800 framework kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)

Hello,

I also want to report my experience.
I’m not really sure if it exactly fits the topic as I don’t understand the cause.
But it seems similar enough.

I have a Framework 13 AMD7040. Firmware version is 03.03.
I’ve installed Arch Linux and it is still quite minimal (don’t have a desktop environment).
It is using Linux 6.7.1=arch1-1 x86_64.

I get the following errors at boot using the modules:

left    right
USB-C   USB-C
USB-A   DP (DisplayPort)
-- Boot 990b38cd244f40fe889b9a374c2ef71b --
Jan 23 21:16:22 fesq kernel: cros_ec_lpcs cros_ec_lpcs.0: EC ID not detected
Jan 23 21:16:23 fesq kernel: ucsi_acpi USBC000:00: UCSI_GET_PDOS failed (-5)
Jan 23 21:16:25 fesq kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-5)
Jan 23 21:16:25 fesq kernel: ucsi_acpi USBC000:00: possible UCSI driver bug 1
Jan 23 21:16:25 fesq kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: GET_CONNECTOR_STATUS failed (-22)
Jan 23 21:28:39 fesq kernel: ucsi_acpi USBC000:00: GET_CONNECTOR_STATUS failed (-110)
Jan 23 21:28:44 fesq kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
Jan 23 21:28:50 fesq kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)
Jan 23 21:28:55 fesq kernel: ucsi_acpi USBC000:00: ucsi_handle_connector_change: ACK failed (-110)

If I boot without any modules it is only:

-- Boot 9595b7a696164b06a5dc68c81f7216e1 --
Jan 27 10:35:04 fesq kernel: cros_ec_lpcs cros_ec_lpcs.0: EC ID not detected

As far as I understand from other answers I can’t do anything about it. It is not a problem of misconfiguration or that I’m missing something. Is this correct?

The Arch Wiki for Framework 13 states N/A for PCI/USB ID with modules USB-C and A. Is this connected?

This is correct.

Those messages indicate that the kernel is having trouble talking directly to the USB C port controllers. The Framework Laptop has had some minor issues with UCSI for a long time.

Linux won’t be able to determine things like power direction, PD mode, and active or available alternate modes.

However, in normal use this functionality will not be required. The system will handle these features without the kernel’s involvement.

Thank you very much for your explanation.

I did some more tests and it seems to be the DP (DisplayPort) module which causes these messages.