Re: [PATCH v1 1/2] platform: arm64: huawei-gaokun-ec: Reject short I2C transfers
From: Pengyu Luo
Date: Sat Nov 28 2026 - 02:49:23 EST
On Thu, Nov 26, 2026 at 3:06 PM Lee Youngjoon <getfeus@xxxxxxxxx> wrote:
>
> 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@xxxxxxxxx>
> ---
> 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;
> }
>
>
Reviewed-by: Pengyu Luo <mitltlatltl@xxxxxxxxx>
BTW. You don't need to quote the first message, i.e. the cover letter.
Best wishes,
Pengyu
>
> On Thu, 26 Nov 2026 02:06:16 -0500, Lee Youngjoon <getfeus@xxxxxxxxx> wrote:
> > Hi,
> >
> > These two independent fixes address the host side of the Huawei MateBook
> > E Go EC protocol. A short I2C transfer can be reported as success, and
> > the normal no-port-update case evaluates a negative shift before sending
> > its acknowledgement. Both issues are present in the pdx86 fixes tree.
> >
> > For patch 1, a host-side test fed the actual request helper adapter
> > returns of 0, 1, -EREMOTEIO and 2. The first two now return -EIO.
> > A complete transfer still returns the EC status byte, including a
> > nonzero status. For patch 2, UBSan reproduced the negative shift on
> > the base commit. With the fix, -1 sends a zero mask; ports 0 through 7
> > set their respective bits, and out-of-range indices return -EINVAL
> > without a transfer. Both patches were built individually and together
> > as an arm64 Image and EC module.
> >
> > For reviewers interested in firmware inputs, the PAN write can also be
> > checked with a fixed cable configuration on a Gaokun. In an earlier
> > instrumented run, the left charger was online and the right port empty.
> > After a normal left ACK, D3 still reported update mask 01 and port
> > records 05/00 and 02/00. A test-only driver hook rechecked D3 and pending
> > work, then issued one empty PAN ACK while both ports were left untouched.
> > The I2C trace captured the following exchange:
> >
> > host -> EC 03 d2 01 00
> > EC -> host 00 44
> > D3 payload 02 01 05 00 02 00 40 (before, after, +2 s, +5 s)
> >
> > This observation documents the existing empty ACK encoding. The EC
> > accepted the command and the update mask stayed set. The series preserves
> > that input and makes no change to firmware recovery or hotplug policy.
> > The host-side cases above can be exercised without a board by stubbing
> > i2c_transfer() and recording the request bytes and return code.
> >
> > OpenAI Codex assisted with source inspection, the fixes, regression
> > tests and drafting this series.
> >
> > Thanks,
> > Lee Youngjoon
> >
> > 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 | 11 ++++++++---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> >
> > base-commit: d4000e7b99e06e92f21a3c92098a0476d316e9d6