Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp716154lqt; Tue, 19 Mar 2024 01:12:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrACfG8ZMrI/dpKS51njx4JJ7r7jmQUiNY7RLeFHxZXuEZl/bYETD8B79qtYvn9WsbTaZjrVdTCQfGgmj4KMKWqY98Iy9eaUklStDkHQ== X-Google-Smtp-Source: AGHT+IFW3hkbfIG+3AMZdBvj6zvG5+FaG0uYxiN7hJAMc3uKQBoarDWErAnqILAnmweleVMsa5vB X-Received: by 2002:a17:90a:ea8e:b0:29e:c3d:c3fc with SMTP id h14-20020a17090aea8e00b0029e0c3dc3fcmr7385440pjz.18.1710835951640; Tue, 19 Mar 2024 01:12:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710835951; cv=pass; d=google.com; s=arc-20160816; b=iEdFrOVgnmp4fumC5d6rJz+HN0nO1530QKWVyga+sj7fwwYjBSuugHVfr1pvGxzxP5 AKw3HyoPlgtw8xkxJSX4s7WvgQuVoaBj6XAACB2A9my0YJRBKMdToyAejXFUCR7cxUcR neglOQX5Zax2v4ptsHkVvjqD9EipJg9DUVJ0501+qVpAiEYewei4YLcGkoIkGCrxKJDu xI5tZOFSq3NMgvFwKYbDQiMTb3Ku/IMZU4t/7rDQICfO21LW0CjyNj1+anPJeOBBmwpb LyEJjwsb7+thSjjRplWTVVb3UBkWV7JEWhvydNxOMPN4714JGLZcLjgnqM5uGRvMKxm/ wSjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=FeoUHC85Ps4zY7htFYA2dvH9r6BuZyxO9FkaU+4JaL4=; fh=TquNsOiV+zNY1csTpltVB6A9QFW5SbuNs6JlqcKCQkw=; b=Beut57zoMuBrd6xvP4JVuZz6dkifG7O2ilWDS96tbFBdhUmiBQrdF1Tlk4kdkLW2pH wJOITlR2PcN2D6vEqxFgvVXhlA3/i8Ysmb9aUnM2Vlf8IgusAw9BrUKTzHecdiMMjVy0 en+1/Fsy/Su1hj1iKYlYSXCYJxRJfJlY2nT+9iXZgOpVEVw22xK5VnO69Cr1EsDUbJoz 0LWHbqyiQJ5/m2p0AQ0SWWCd79FAbcHlOL+ccT31oqNKV/CN/plz2Iap6hwrczOhJ63U lLzIarzGj+ZomtPFR79MbSirnDWikfjbo9LyO59yMdbMoUuWq4Lr27xGWbM1UOuQnLIy q64w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D0L2tUTH; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-wireless+bounces-4884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m11-20020a17090aab0b00b0029c7a551127si9617911pjq.99.2024.03.19.01.12.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 01:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D0L2tUTH; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-wireless+bounces-4884-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3951B282EEE for ; Tue, 19 Mar 2024 08:12:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80F507BAEC; Tue, 19 Mar 2024 08:10:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="D0L2tUTH" X-Original-To: linux-wireless@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A5FC65195 for ; Tue, 19 Mar 2024 08:10:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710835851; cv=none; b=uhvBisZIU0+CC6U6/iri9EclNpemqRQiNstUIwSlgf3ICfYH0l5ulhJVToEZSlEVmu5D57ZGkWdhaYgBMgac0rEDqXFs8VcCxTL+VmnTRpC2xhjM5IhvLmreMo9HlUcPMNddloPF0+kmT2d3oIrwO6I4XqBcQQCueWPUNOl0wRk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710835851; c=relaxed/simple; bh=KslKTG/WplijRbeUGf95VZRhYfbVmHi8g8kTc03aHR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IYfNKgdYIgznKZ2SgboaZ4iYccVaB48eYPMBercoYQOCKPtIX7L8U9ijdjtZFhAmNi8MEfK9sI8pByyyv5RiscRIlV1zStJ8eWX7qfZH20a7EeAmJpHvObUbU06ZqNOjWV5reRMWUKwHHWwGcSeMclR8bsvkZMIoP/q3mFC9bto= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=D0L2tUTH; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710835850; x=1742371850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KslKTG/WplijRbeUGf95VZRhYfbVmHi8g8kTc03aHR0=; b=D0L2tUTH2RbGIc3YbWL30uOS3k52R7X+W25qO0AQf58KtWDfqamyiV03 0Je6oluPYLGvd0Fddb4HbrZmJzjD5Fl4UZLtt7IQ6+OYdA9mPA1MIYQz4 UpwKoQqHlM+vwFIwn4HG58USG/EtQogsz1nR0Lrg1iwois2Bbx9r18wbD Ba9dUb9N9PVMJ+zKDc5VkyqUgiGBDc1Q0/IR9KsPhuMn6X+sRxGieEgDC /KEalnhMp98H8s9iYqT2xhd11NczfWHdx118Ekqcj+IOCdpvg2Em40wJy i90e5lqubkvHAnOaiogOVUUuueu5qgIUE7s4Cv0OnxoBhYtyZgnhI5OCp w==; X-IronPort-AV: E=McAfee;i="6600,9927,11017"; a="5810534" X-IronPort-AV: E=Sophos;i="6.07,136,1708416000"; d="scan'208";a="5810534" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2024 01:10:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,136,1708416000"; d="scan'208";a="18447590" Received: from unknown (HELO WEIS0040.iil.intel.com) ([10.12.217.108]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2024 01:10:48 -0700 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 04/15] wifi: iwlwifi: add a kunit test for PCI table duplicates Date: Tue, 19 Mar 2024 10:10:16 +0200 Message-Id: <20240319100755.826b859abd62.I8140d7e9ae52ac50c6830818f8f95ccd0d94b3d3@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240319081027.3853611-1-miriam.rachel.korenblit@intel.com> References: <20240319081027.3853611-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited Content-Transfer-Encoding: 8bit From: Johannes Berg We shouldn't have entries in the table that match the same device; it's possible to have a specific entry followed by a less specific entry (i.e. NNNN followed by ANY), but not entries that are dead, where an earlier entry matches the same as a later one. Add a test similar to the existing devinfo test to catch this situation. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- .../net/wireless/intel/iwlwifi/iwl-config.h | 2 ++ drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 3 ++- .../wireless/intel/iwlwifi/tests/devinfo.c | 26 ++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h index 6aa4f7f9c708..f1e7b15458c1 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "iwl-csr.h" #include "iwl-drv.h" @@ -484,6 +485,7 @@ const struct iwl_dev_info * iwl_pci_find_dev_info(u16 device, u16 subsystem_device, u16 mac_type, u8 mac_step, u16 rf_type, u8 cdb, u8 jacket, u8 rf_id, u8 no_160, u8 cores, u8 rf_step); +extern const struct pci_device_id iwl_hw_card_ids[]; #endif /* diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c index 916d417886e8..4cf811afdfa5 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c @@ -33,7 +33,7 @@ extern int _invalid_type; .driver_data = _ASSIGN_CFG(cfg) /* Hardware specific file defines the PCI IDs table for that hardware module */ -static const struct pci_device_id iwl_hw_card_ids[] = { +VISIBLE_IF_IWLWIFI_KUNIT const struct pci_device_id iwl_hw_card_ids[] = { #if IS_ENABLED(CONFIG_IWLDVM) {IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */ {IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */ @@ -516,6 +516,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = { {0} }; MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); +EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_hw_card_ids); #define _IWL_DEV_INFO(_device, _subdevice, _mac_type, _mac_step, _rf_type, \ _rf_id, _rf_step, _no_160, _cores, _cdb, _cfg, _name) \ diff --git a/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c b/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c index 7aa47fce6e2d..7361b6d0cdb8 100644 --- a/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c +++ b/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c @@ -2,9 +2,10 @@ /* * KUnit tests for the iwlwifi device info table * - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation */ #include +#include #include "iwl-drv.h" #include "iwl-config.h" @@ -41,8 +42,31 @@ static void devinfo_table_order(struct kunit *test) } } +static void devinfo_pci_ids(struct kunit *test) +{ + struct pci_dev *dev; + + dev = kunit_kmalloc(test, sizeof(*dev), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, dev); + + for (int i = 0; iwl_hw_card_ids[i].vendor; i++) { + const struct pci_device_id *s, *t; + + s = &iwl_hw_card_ids[i]; + dev->vendor = s->vendor; + dev->device = s->device; + dev->subsystem_vendor = s->subvendor; + dev->subsystem_device = s->subdevice; + dev->class = s->class; + + t = pci_match_id(iwl_hw_card_ids, dev); + KUNIT_EXPECT_PTR_EQ(test, t, s); + } +} + static struct kunit_case devinfo_test_cases[] = { KUNIT_CASE(devinfo_table_order), + KUNIT_CASE(devinfo_pci_ids), {} }; -- 2.34.1