Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3023454rdg; Tue, 17 Oct 2023 02:04:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEi+vcnHQnCDTNogwDnzXxA8E/eLosXJ4Zmzl03WrCSt0Nlmkivx8QDI5wxrnpZqBDy8pFl X-Received: by 2002:a17:902:d4c4:b0:1c9:f6df:8a88 with SMTP id o4-20020a170902d4c400b001c9f6df8a88mr1885247plg.26.1697533441339; Tue, 17 Oct 2023 02:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697533441; cv=none; d=google.com; s=arc-20160816; b=xCNcF038SIh6vVyv6dwJhZWqIKNowXNjZVOGMl+1bzObd0YFpxvFfsH8Uwak4wgKTI /Kbnz671D2DMI3nI3L90FUyvRN9wqyvYo/nsQdrvQZvZN2HJHKKke4EmCElttwxuOwUM LiXamNhw1yCX6f5vpzW71N/8D3lJ45aciuzLIeedGD8bK/mvvUm900y5lY+hkzK6sSkR UeWrBKPxJ3PHPkua8EaOnLwfWmL2mDbh/9imFnPTXu0/tF4s3eGViH/mr6zZjFYDP2di xDOXhNw6NVA8yXliKapMzPXbVhqXPgZruwEbJ/HqRgmtv8D3Pwr5+nGzE4IHA1qhc7Z/ V/jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=mmP59HA00YEhNoMgfc0NucQQOWKY+JIc1wYPKiMttYE=; fh=vNLEY746teB6uKOp12IiCI0hWpF0wnMOnihrIc5DNdQ=; b=hILmaFfnZScckQENSPcYrFss0Mm+5dty23OYuoXs79h496FWt5z5ExzWI6MNFeYv3/ N3UBP2caweyKOgnSf1DESzAtuHalf8iR0sggzRVjTLVSRjg4vfTiwHs9nESdobBf+lB/ CAx2eTfQX1Naot15p35gSBAoUFacJQLRQWUW71FqTpYnLtILZaN7lvH4zVZhrIaoO39O 4FGJ9oim1fZE3NUT2L/Utw5UNV69bz9PsUNjftkOb59tsfXHz7/3V9U73Eg7kwunkAD9 BY4eGJ3iwlQm5eLHJS8VeWPIp4zLolBM0BM+OiGvNuqiOJiENlwhWTQ43bL62r5ZyLg4 i3pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BE0Z6mbQ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s15-20020a170902ea0f00b001c0c79b3869si1483679plg.578.2023.10.17.02.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BE0Z6mbQ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 088A9803E59B; Tue, 17 Oct 2023 02:03:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234758AbjJQJD4 (ORCPT + 52 others); Tue, 17 Oct 2023 05:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234741AbjJQJDy (ORCPT ); Tue, 17 Oct 2023 05:03:54 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 512CB8E; Tue, 17 Oct 2023 02:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697533433; x=1729069433; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=bYg38E3e/vhXYWresPVnGgaNf/gc0H4id9aMD0AqQJM=; b=BE0Z6mbQZgghka3Nc7awanwJ454pIFIkdt5M+Hqxg1mAz6CQ6q2ftXoe dnM15I/m+wVN3vkQioFEiF0hF6f5QGa1AkTuJD6YKTzB0OG9mlJRjSjNT /EH1DUK5wWAkifNyny4k2N+LVyc4awEHhZhIMfi+ELsB6iyexlTO9M6Sv KGI4e42stoq3vNGV97CchE4oYemWRXS/If/P23iBat4oFrPDr8NmMiSh5 D7b/z+Vev/aj/fsh8VljE+5jNCCvvZXFSoDyLIkWOyjnP22sWZNfG6lLT 1Ks743IBEuk+8lltt2E0fzY4KH1zgDzfobB0QaiO/vA1WvVojB3GwCMuc A==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="376106189" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="376106189" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 02:03:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="785409867" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="785409867" Received: from spandruv-mobl.amr.corp.intel.com ([10.252.44.24]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 02:03:47 -0700 Date: Tue, 17 Oct 2023 12:03:45 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Ma Jun cc: amd-gfx@lists.freedesktop.org, lenb@kernel.org, johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, alexander.deucher@amd.com, Lijo.Lazar@amd.com, mario.limonciello@amd.com, majun@amd.com, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, Evan Quan Subject: Re: [PATCH v12 9/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 In-Reply-To: <20231017025358.1773598-10-Jun.Ma2@amd.com> Message-ID: <9ab5375c-d911-ab3-5522-e0e1dd33f043@linux.intel.com> References: <20231017025358.1773598-1-Jun.Ma2@amd.com> <20231017025358.1773598-10-Jun.Ma2@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 17 Oct 2023 02:03:57 -0700 (PDT) On Tue, 17 Oct 2023, Ma Jun wrote: > From: Evan Quan > > Fulfill the SMU13.0.7 support for Wifi RFI mitigation feature. > > Signed-off-by: Evan Quan > Reviewed-by: Mario Limonciello > Signed-off-by: Ma Jun > -- > v10->v11: > - downgrade the prompt level on message failure(Lijo) > --- > .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 59 +++++++++++++++++++ > 1 file changed, 59 insertions(+) > > diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c > index 62f2886ab4df..c5736fb3cf6d 100644 > --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c > +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c > @@ -126,6 +126,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] = > MSG_MAP(AllowGpo, PPSMC_MSG_SetGpoAllow, 0), > MSG_MAP(GetPptLimit, PPSMC_MSG_GetPptLimit, 0), > MSG_MAP(NotifyPowerSource, PPSMC_MSG_NotifyPowerSource, 0), > + MSG_MAP(EnableUCLKShadow, PPSMC_MSG_EnableUCLKShadow, 0), > }; > > static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = { > @@ -207,6 +208,7 @@ static struct cmn2asic_mapping smu_v13_0_7_table_map[SMU_TABLE_COUNT] = { > TAB_MAP(ACTIVITY_MONITOR_COEFF), > [SMU_TABLE_COMBO_PPTABLE] = {1, TABLE_COMBO_PPTABLE}, > TAB_MAP(OVERDRIVE), > + TAB_MAP(WIFIBAND), > }; > > static struct cmn2asic_mapping smu_v13_0_7_pwr_src_map[SMU_POWER_SOURCE_COUNT] = { > @@ -503,6 +505,9 @@ static int smu_v13_0_7_tables_init(struct smu_context *smu) > AMDGPU_GEM_DOMAIN_VRAM); > SMU_TABLE_INIT(tables, SMU_TABLE_COMBO_PPTABLE, MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE, > PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM); > + SMU_TABLE_INIT(tables, SMU_TABLE_WIFIBAND, > + sizeof(WifiBandEntryTable_t), PAGE_SIZE, > + AMDGPU_GEM_DOMAIN_VRAM); > > smu_table->metrics_table = kzalloc(sizeof(SmuMetricsExternal_t), GFP_KERNEL); > if (!smu_table->metrics_table) > @@ -2179,6 +2184,57 @@ static int smu_v13_0_7_set_df_cstate(struct smu_context *smu, > NULL); > } > > +static bool smu_v13_0_7_wbrf_support_check(struct smu_context *smu) > +{ > + return smu->smc_fw_version > 0x00524600; > +} > + > +static int smu_v13_0_7_set_wbrf_exclusion_ranges(struct smu_context *smu, > + struct freq_band_range *exclusion_ranges) > +{ > + WifiBandEntryTable_t wifi_bands; > + int valid_entries = 0; > + int ret, i; > + > + memset(&wifi_bands, 0, sizeof(wifi_bands)); > + for (i = 0; i < ARRAY_SIZE(wifi_bands.WifiBandEntry); i++) { > + if (!exclusion_ranges[i].start && > + !exclusion_ranges[i].end) After having seen this construct nth time, I think you should have a static inline function for this check with a proper name. > + break; > + > + /* PMFW expects the inputs to be in Mhz unit */ > + wifi_bands.WifiBandEntry[valid_entries].LowFreq = > + DIV_ROUND_DOWN_ULL(exclusion_ranges[i].start, HZ_IN_MHZ); > + wifi_bands.WifiBandEntry[valid_entries++].HighFreq = > + DIV_ROUND_UP_ULL(exclusion_ranges[i].end, HZ_IN_MHZ); > + } > + wifi_bands.WifiBandEntryNum = valid_entries; > + > + /* > + * Per confirm with PMFW team, WifiBandEntryNum = 0 is a valid setting. > + * Considering the scenarios below: > + * - At first the wifi device adds an exclusion range e.g. (2400,2500) to > + * BIOS and our driver gets notified. We will set WifiBandEntryNum = 1 > + * and pass the WifiBandEntry (2400, 2500) to PMFW. > + * > + * - Later the wifi device removes the wifiband list added above and > + * our driver gets notified again. At this time, driver will set > + * WifiBandEntryNum = 0 and pass an empty WifiBandEntry list to PMFW. > + * - PMFW may still need to do some uclk shadow update(e.g. switching > + * from shadow clock back to primary clock) on receiving this. > + */ > + > + ret = smu_cmn_update_table(smu, > + SMU_TABLE_WIFIBAND, > + 0, > + (void *)(&wifi_bands), > + true); > + if (ret) > + dev_warn(smu->adev->dev, "Failed to set wifiband!"); > + > + return ret; > +} Is this whole function duplicate of the one in the other file? Don't duplicate code like this but create reusable functions properly. -- i. > + > static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { > .get_allowed_feature_mask = smu_v13_0_7_get_allowed_feature_mask, > .set_default_dpm_table = smu_v13_0_7_set_default_dpm_table, > @@ -2247,6 +2303,9 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { > .set_mp1_state = smu_v13_0_7_set_mp1_state, > .set_df_cstate = smu_v13_0_7_set_df_cstate, > .gpo_control = smu_v13_0_gpo_control, > + .is_asic_wbrf_supported = smu_v13_0_7_wbrf_support_check, > + .enable_uclk_shadow = smu_v13_0_enable_uclk_shadow, > + .set_wbrf_exclusion_ranges = smu_v13_0_7_set_wbrf_exclusion_ranges, > }; > > void smu_v13_0_7_set_ppt_funcs(struct smu_context *smu) >