Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 081BCCD98C5 for ; Mon, 15 Jun 2026 10:22:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A475910E33C; Mon, 15 Jun 2026 10:22:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="UfB4rFyi"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0583510E33C for ; Mon, 15 Jun 2026 10:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781518913; x=1813054913; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=mT+KkqnQ+YbUjEIczeiUoWac8M+seJTrZe0OsYUH0oU=; b=UfB4rFyiw4EeBPciBcyik01FyRNnUz7mWhxt/25WTdb1mp5Alx+RLrh4 Rp+YDemQraNEmbaeS60abFvlz1WtPuoPwYYhkzNkc9cAua/wNGn1P6sII OYA+NHsc3Dc+sqzynUDHK8QtXkSTC3bjtyY/cRmhfzNCjScnjnVYsjjxl ztUYRxDBXiqqVj9DO4xX7omJfrqxbDEUhIABIUnmBt47HW1WXLYgfFikM N/ylQnXUlHcz4d/ov9e7JQ0BmqByKKeSx3GtGX1CkBkr2BUsnmtQZLrH0 B0dChBFp/jPbZuX0n7uhvjogVewGoSyBQuY6Fvu6Nij4w/wKXEnpx9NV9 Q==; X-CSE-ConnectionGUID: /JfH8TiHQIug2X/EWjJc4A== X-CSE-MsgGUID: FJUUtobvSN+Bfhe99CHEpw== X-IronPort-AV: E=McAfee;i="6800,10657,11817"; a="82318791" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="82318791" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 03:21:52 -0700 X-CSE-ConnectionGUID: InTukJi7RImxLcHIf929pw== X-CSE-MsgGUID: xurbd73AQjGNwcky1m+MMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="252388953" Received: from dev-417.igk.intel.com ([10.91.214.181]) by orviesa005.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 03:21:51 -0700 Date: Mon, 15 Jun 2026 12:21:49 +0200 (CEST) From: =?ISO-8859-2?Q?Micha=B3_Grzelak?= To: Jani Nikula cc: =?ISO-8859-2?Q?Micha=B3_Grzelak?= , igt-dev@lists.freedesktop.org, Suraj Kandpal , =?ISO-8859-15?Q?Ville_Syrj=E4l=E4?= Subject: Re: [PATCH i-g-t v3 04/10] lib/intel_device_info: add a helper to guess the PCI ID for a codename In-Reply-To: <79496f3655e5309fc4f22b940a4115a06c0f8dc7@intel.com> Message-ID: <1a575f0b-9333-2736-aa18-53f77e496192@intel.com> References: <20260615093137.681050-1-michal.grzelak@intel.com> <20260615093137.681050-5-michal.grzelak@intel.com> <79496f3655e5309fc4f22b940a4115a06c0f8dc7@intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1756260169-1781518912=:605841" X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1756260169-1781518912=:605841 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Mon, 15 Jun 2026, Jani Nikula wrote: > On Mon, 15 Jun 2026, Michał Grzelak wrote: >> From: Jani Nikula >> >> From: Jani Nikula >> > > Where did the dupe From: come from? > My fat fingers unfortunately. > Anyway, would be more helpful to get the original patches merged than > include them here, especially since there were review comments on them. > >> The struct intel_device_info contains the codenames for the >> corresponding PCI device IDs. Add a reverse lookup to get a PCI ID for a >> codename. >> >> It's a bit fuzzy, though. The codenames aren't always spelled the same, >> there are suffixes sometimes omitted, and you can only pick one of the >> matching PCI IDs. Name the helper intel_guess_device_id() to emphasize >> the point, and try increasing fuzziness in the matching to find an >> appropriate struct intel_device_info. >> >> There's nothing exact about this, and it should not be considered as >> such. But it will be useful in VBT parsing. >> >> Cc: Michał Grzelak >> Cc: Ville Syrjälä >> Signed-off-by: Jani Nikula > > You *must* add your own Signed-off-by when sending someone else's > patches. See [1] for what Signed-off-by means. > Same for missing Signed-off-by:. Will respond to the patches providing the tag. BR, Michał > BR, > Jani. > > > [1] https://developercertificate.org/ > > >> --- >> lib/intel_chipset.h | 1 + >> lib/intel_device_info.c | 75 +++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 76 insertions(+) >> >> diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h >> index 3fcc5b18d6..98a2a81fcf 100644 >> --- a/lib/intel_chipset.h >> +++ b/lib/intel_chipset.h >> @@ -103,6 +103,7 @@ struct intel_device_info { >> }; >> >> const struct intel_device_info *intel_get_device_info(uint16_t devid) __attribute__((pure)); >> +uint16_t intel_guess_device_id(const char *codenameish) __attribute__((pure)); >> >> const struct intel_cmds_info *intel_get_cmds_info(uint16_t devid) __attribute__((pure)); >> unsigned intel_gen(uint16_t devid) __attribute__((pure)); >> diff --git a/lib/intel_device_info.c b/lib/intel_device_info.c >> index da0b9f3988..3b53732650 100644 >> --- a/lib/intel_device_info.c >> +++ b/lib/intel_device_info.c >> @@ -3,6 +3,7 @@ >> #include "i915_pciids_local.h" >> >> #include /* ffs() */ >> +#include >> >> static const struct intel_device_info intel_generic_info = { >> .graphics_ver = 0, >> @@ -746,6 +747,80 @@ out: >> return cache; >> } >> >> +static bool char_eq(char c1, char c2) >> +{ >> + c1 = isalnum(c1) ? tolower(c1) : '-'; >> + c2 = isalnum(c2) ? tolower(c2) : '-'; >> + >> + return c1 == c2; >> +} >> + >> +/* >> + * Return true if the codenames s1 and s2 match, with fuzziness. >> + * >> + * Case insensitive matching, ignoring differences in non-alnum characters. With >> + * non-zero fuzziness, accept matches up to the first non-alnum character. >> + */ >> +static bool codename_match(const char *s1, const char *s2, int fuzziness) >> +{ >> + while (*s1 && *s2 && char_eq(*s1, *s2)) { >> + s1++; >> + s2++; >> + } >> + >> + /* full match */ >> + if (!*s1 && !*s2) >> + return true; >> + >> + /* sub-string match up to a non-alnum char */ >> + if (fuzziness >=1) { >> + if (!*s1 && !isalnum(*s2)) >> + return true; >> + if (!*s2 && !isalnum(*s1)) >> + return true; >> + } >> + >> + return false; >> +} >> + >> +static uint16_t lookup_device_id(const char *codename, int fuzziness) >> +{ >> + int i; >> + >> + for (i = 0; intel_device_match[i].device_id != PCI_MATCH_ANY; i++) { >> + const struct intel_device_info *info = (void *)intel_device_match[i].match_data; >> + >> + if (codename_match(info->codename, codename, fuzziness)) >> + return intel_device_match[i].device_id; >> + } >> + >> + return 0; >> +} >> + >> +/** >> + * intel_guess_device_id: >> + * @codenameish: something resembling a codename >> + * >> + * Based on something resembling a codename, try to fuzzy find the first PCI >> + * device ID matching the codename. >> + * >> + * Returns: >> + * PCI device ID fuzzy matching the @codenameish, or 0 if no match was found. >> + */ >> +uint16_t intel_guess_device_id(const char *codenameish) >> +{ >> + uint16_t devid; >> + int fuzziness; >> + >> + for (fuzziness = 0; fuzziness < 2; fuzziness++) { >> + devid = lookup_device_id(codenameish, fuzziness); >> + if (devid) >> + return devid; >> + } >> + >> + return 0; >> +} >> + >> /** >> * intel_get_cmds_info: >> * @devid: pci device id > > -- > Jani Nikula, Intel > --8323329-1756260169-1781518912=:605841--