From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EEB4606A322 for ; Thu, 3 Dec 2026 16:58:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GrAncU6v Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2FD38112A68; Thu, 3 Dec 2026 16:58:11 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 72C4A112A68 for ; Thu, 3 Dec 2026 16:58:05 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 0B67E406A9; Thu, 3 Dec 2026 16:58:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1AA31F00899; Thu, 3 Dec 2026 16:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796317084; bh=IwlvniK8DcdNYQghSNRNLqeMJsJtMcmG0HOTTOiBJX0=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=GrAncU6vk03ykAUkvPrEieTS/0rcqJuVLCi4udcw74a+OQgCbf6gRDl1hlA6juciD r5CebbfMY7fRrzvOH6ieqVIph/GAXjMEUKe2Fw3x+DKcvDoxhZlFns05bXHsdnOoLh DXHPQzVtdgwSaCo9Il4M8uIqrhc1DDvli4PPdRJuen35GXP8uIIRCC+A/T6Crcoxry 7hC36Vgq5Ch0s5oA4p/0Dkd/1Xq2Xgo/hcnqaKnBoSNFUzvxBZcRLVeehjV6Sf89/F t9CkpTgUGjonoEsXXByDHvrRzMlOX4ivUH6zDMS5vz8knDhIQyh6dWGAHkYR1xUW3v 4NPPYCEmTCZcQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/xe/xe_late_bind_fw: Correct fan count parsing To: "Karthik Poosa" , intel-xe@lists.freedesktop.org In-Reply-To: <20261203163646.2672136-1-karthik.poosa@intel.com> References: <20261203163646.2672136-1-karthik.poosa@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 16:58:04 +0000 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-xe" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/xe: inconsistent FSC_READ_NUM_FANS bitmask vs count parsing on Battlemage -- commit 133e36e73163f5120eca6f3253d97ab200fe4b2e Author: Karthik Poosa drm/xe/xe_late_bind_fw: Correct fan count parsing This commit updates xe_late_bind_fw_num_fans() to count the set bits return= ed by the FSC_READ_NUM_FANS pcode mailbox command with hweight32(), and zeroes *num_fans on read failure. > diff --git a/drivers/gpu/drm/xe/xe_late_bind_fw.c b/drivers/gpu/drm/xe/xe= _late_bind_fw.c > index ad39383a7e41f..13516b3a1be34 100644 > --- a/drivers/gpu/drm/xe/xe_late_bind_fw.c > +++ b/drivers/gpu/drm/xe/xe_late_bind_fw.c > @@ -226,9 +226,17 @@ static int xe_late_bind_fw_num_fans(struct xe_late_b= ind *late_bind, u32 *num_fan > { > struct xe_device *xe =3D late_bind_to_xe(late_bind); > struct xe_tile *root_tile =3D xe_device_get_root_tile(xe); > + int ret =3D 0; > =20 > - return xe_pcode_read(root_tile, > - PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), num_fans, N= ULL); > + ret =3D xe_pcode_read(root_tile, > + PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), num_fans, NU= LL); > + if (ret) { > + *num_fans =3D 0; > + return ret; > + } > + *num_fans =3D hweight32(*num_fans); > + > + return 0; > } [Severity: Medium] Does xe_hwmon_fan_is_visible() also need to parse FSC_READ_NUM_FANS as a bitmask, or does Battlemage pcode still return a count? bmg_desc in drivers/gpu/drm/xe/xe_pci.c enables both has_fan_control and late_bind_mask =3D BIT(XE_LB_FW_FAN_CONTROL), so both functions issue PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0) on the same hardware, while xe_hwmon_fan_is_visible() still treats the reply as an integer count: drivers/gpu/drm/xe/xe_hwmon.c:xe_hwmon_fan_is_visible() { ... if (xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_NUM_FANS, &uval)) return 0; return channel < uval ? 0444 : 0; ... } If FSC_READ_NUM_FANS returns a bitmask on Battlemage, a 2-fan card returning 0x3 satisfies channel < 3 and exposes a bogus fan3_input sysfs attribute th= at reads BMG_FAN_3_SPEED for a nonexistent fan. If Battlemage returns a count instead, unconditionally calling hweight32() here miscounts 2 fans as 1. Either xe_hwmon_fan_is_visible() (and the XE_DG2 override in xe_hwmon_pcode_read_fan_control()) should parse FSC_READ_NUM_FANS as a bitmask, or the hweight32() conversion should be restricted to platforms wh= ere pcode returns a bitmask. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203163646.2672= 136-1-karthik.poosa@intel.com?part=3D1