* [PATCH v2 0/2] platform: arm64: huawei-gaokun-ec: Fix short transfers and PAN ACK masks
@ 2026-11-28 9:06 YoungJoon Lee
2026-11-28 9:06 ` [PATCH v2 1/2] platform: arm64: huawei-gaokun-ec: Reject short I2C transfers YoungJoon Lee
2026-11-28 9:06 ` [PATCH v2 2/2] platform: arm64: huawei-gaokun-ec: Validate the PAN ACK bit index YoungJoon Lee
0 siblings, 2 replies; 3+ messages in thread
From: YoungJoon Lee @ 2026-11-28 9:06 UTC (permalink / raw)
To: mitltlatltl, hansg, ilpo.jarvinen
Cc: bryan.odonoghue, platform-driver-x86, linux-kernel
These two fixes address short I2C transfers and PAN ACK mask
construction in the Huawei MateBook E Go EC driver.
Changes in v2:
- Patch 1 is unchanged.
- Patch 2 validates against the two physical connectors, as suggested
by Pengyu Luo. The no-port-update sentinel still sends a zero mask.
An I2C stub and UBSan verified the empty ACK, both valid masks,
rejection of invalid indices without an I2C transfer, and short
transfer handling. The series builds as an arm64 Image and EC module.
OpenAI Codex assisted with source inspection, regression testing and
drafting.
Lee Youngjoon (2):
platform: arm64: huawei-gaokun-ec: Reject short I2C transfers
platform: arm64: huawei-gaokun-ec: Validate the PAN ACK bit index
drivers/platform/arm64/huawei-gaokun-ec.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
base-commit: d4000e7b99e06e92f21a3c92098a0476d316e9d6
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] platform: arm64: huawei-gaokun-ec: Reject short I2C transfers
2026-11-28 9:06 [PATCH v2 0/2] platform: arm64: huawei-gaokun-ec: Fix short transfers and PAN ACK masks YoungJoon Lee
@ 2026-11-28 9:06 ` YoungJoon Lee
2026-11-28 9:06 ` [PATCH v2 2/2] platform: arm64: huawei-gaokun-ec: Validate the PAN ACK bit index YoungJoon Lee
1 sibling, 0 replies; 3+ messages in thread
From: YoungJoon Lee @ 2026-11-28 9:06 UTC (permalink / raw)
To: mitltlatltl, hansg, ilpo.jarvinen
Cc: bryan.odonoghue, platform-driver-x86, linux-kernel
gaokun_ec_request() issues a write followed by a read. If
i2c_transfer() completes zero messages, the helper logs a transfer
error but returns zero to its caller. If it completes just the write,
the helper returns one without having received a firmware status byte.
Return -EIO for a non-negative short count. Preserve the adapter's
negative errno, the EC status on a complete transfer, and the delay
before releasing the transaction lock.
Fixes: 7636f090d02e ("platform: arm64: add Huawei Matebook E Go EC driver")
Signed-off-by: Lee Youngjoon <getfeus@gmail.com>
---
drivers/platform/arm64/huawei-gaokun-ec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/platform/arm64/huawei-gaokun-ec.c
b/drivers/platform/arm64/huawei-gaokun-ec.c
index ac21f732d..abf05e7ec 100644
--- a/drivers/platform/arm64/huawei-gaokun-ec.c
+++ b/drivers/platform/arm64/huawei-gaokun-ec.c
@@ -145,6 +145,8 @@ static int gaokun_ec_request(struct gaokun_ec *ec,
const u8 *req,
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret != ARRAY_SIZE(msgs)) {
dev_err(&client->dev, "I2C transfer error %d\n", ret);
+ if (ret >= 0)
+ ret = -EIO;
goto out_after_break;
}
--
2.53.0
On Sat, 28 Nov 2026 04:06:44 -0500, YoungJoon Lee <getfeus@gmail.com> wrote:
> These two fixes address short I2C transfers and PAN ACK mask
> construction in the Huawei MateBook E Go EC driver.
>
> Changes in v2:
> - Patch 1 is unchanged.
> - Patch 2 validates against the two physical connectors, as suggested
> by Pengyu Luo. The no-port-update sentinel still sends a zero mask.
>
> An I2C stub and UBSan verified the empty ACK, both valid masks,
> rejection of invalid indices without an I2C transfer, and short
> transfer handling. The series builds as an arm64 Image and EC module.
>
> OpenAI Codex assisted with source inspection, regression testing and
> drafting.
>
> Lee Youngjoon (2):
> platform: arm64: huawei-gaokun-ec: Reject short I2C transfers
> platform: arm64: huawei-gaokun-ec: Validate the PAN ACK bit index
>
> drivers/platform/arm64/huawei-gaokun-ec.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
>
> base-commit: d4000e7b99e06e92f21a3c92098a0476d316e9d6
> --
> 2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] platform: arm64: huawei-gaokun-ec: Validate the PAN ACK bit index
2026-11-28 9:06 [PATCH v2 0/2] platform: arm64: huawei-gaokun-ec: Fix short transfers and PAN ACK masks YoungJoon Lee
2026-11-28 9:06 ` [PATCH v2 1/2] platform: arm64: huawei-gaokun-ec: Reject short I2C transfers YoungJoon Lee
@ 2026-11-28 9:06 ` YoungJoon Lee
1 sibling, 0 replies; 3+ messages in thread
From: YoungJoon Lee @ 2026-11-28 9:06 UTC (permalink / raw)
To: mitltlatltl, hansg, ilpo.jarvinen
Cc: bryan.odonoghue, platform-driver-x86, linux-kernel
The UCSI driver passes GAOKUN_UCSI_NO_PORT_UPDATE (-1) when the EC
reports no port update. gaokun_ec_ucsi_pan_ack() shifts by port_id
before checking the sentinel, so this normal path evaluates a negative
shift even though it subsequently sends a zero mask.
Initialize the one-byte mask to zero. For an actual port, accept only
indices 0 and 1, corresponding to the two connectors on the MateBook
E Go. This preserves the empty ACK and rejects invalid port indices
before contacting the EC.
Fixes: 7636f090d02e ("platform: arm64: add Huawei Matebook E Go EC driver")
Link: https://lore.kernel.org/r/20260607214621.9586A1F00893@smtp.kernel.org
Signed-off-by: Lee Youngjoon <getfeus@gmail.com>
---
drivers/platform/arm64/huawei-gaokun-ec.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/arm64/huawei-gaokun-ec.c
b/drivers/platform/arm64/huawei-gaokun-ec.c
index abf05e7ec..bfcf7563e 100644
--- a/drivers/platform/arm64/huawei-gaokun-ec.c
+++ b/drivers/platform/arm64/huawei-gaokun-ec.c
@@ -56,6 +56,7 @@ enum gaokun_ec_ucsi_cmd {
UCSI_DATA_READ,
};
+#define GAOKUN_UCSI_NUM_PORTS 2
#define UCSI_REG_SIZE 7
/*
@@ -458,10 +459,13 @@ EXPORT_SYMBOL_GPL(gaokun_ec_ucsi_get_reg);
int gaokun_ec_ucsi_pan_ack(struct gaokun_ec *ec, int port_id)
{
u8 ec_req[] = MKREQ(0x03, UCSI_REG_WRITE, 1);
- u8 data = 1 << port_id;
+ u8 data = 0;
- if (port_id == GAOKUN_UCSI_NO_PORT_UPDATE)
- data = 0;
+ if (port_id != GAOKUN_UCSI_NO_PORT_UPDATE) {
+ if (port_id < 0 || port_id >= GAOKUN_UCSI_NUM_PORTS)
+ return -EINVAL;
+ data = BIT(port_id);
+ }
refill_req_byte(ec_req, &data);
--
2.53.0
On Sat, 28 Nov 2026 04:06:44 -0500, YoungJoon Lee <getfeus@gmail.com> wrote:
> These two fixes address short I2C transfers and PAN ACK mask
> construction in the Huawei MateBook E Go EC driver.
>
> Changes in v2:
> - Patch 1 is unchanged.
> - Patch 2 validates against the two physical connectors, as suggested
> by Pengyu Luo. The no-port-update sentinel still sends a zero mask.
>
> An I2C stub and UBSan verified the empty ACK, both valid masks,
> rejection of invalid indices without an I2C transfer, and short
> transfer handling. The series builds as an arm64 Image and EC module.
>
> OpenAI Codex assisted with source inspection, regression testing and
> drafting.
>
> Lee Youngjoon (2):
> platform: arm64: huawei-gaokun-ec: Reject short I2C transfers
> platform: arm64: huawei-gaokun-ec: Validate the PAN ACK bit index
>
> drivers/platform/arm64/huawei-gaokun-ec.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
>
> base-commit: d4000e7b99e06e92f21a3c92098a0476d316e9d6
> --
> 2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-28 9:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 9:06 [PATCH v2 0/2] platform: arm64: huawei-gaokun-ec: Fix short transfers and PAN ACK masks YoungJoon Lee
2026-11-28 9:06 ` [PATCH v2 1/2] platform: arm64: huawei-gaokun-ec: Reject short I2C transfers YoungJoon Lee
2026-11-28 9:06 ` [PATCH v2 2/2] platform: arm64: huawei-gaokun-ec: Validate the PAN ACK bit index YoungJoon Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®