Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7909069rwp; Wed, 19 Jul 2023 02:06:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlFiAaN+mOxGMvYZN6ws2bAQOp7O/GqMAkqQPaaflwBE0s6lJQxRdGKVnK+BhPfy6E1Wm9tY X-Received: by 2002:a17:903:1c5:b0:1b9:d2fc:ba9f with SMTP id e5-20020a17090301c500b001b9d2fcba9fmr17833942plh.11.1689757607956; Wed, 19 Jul 2023 02:06:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689757607; cv=pass; d=google.com; s=arc-20160816; b=OVt/hyljGQ2gQaLGW8VMvwXJOq9mGQUzaMlC1luyXYJR2mcRQfeCOTOR3wdP1kI45j zh10jl8AkaPCh56sDVDblvkZUHEAJ4q8jo3+ItDcUKKs+zoNxRVRFTp0sYN1gmHRCT4v o5Ve14g/CoMvR72SwVMiHwCULu5nTaWdEIH2pB6BDZ95vRhwqmqr8cGEP1pEXhccmyUE +3CeQMZCzh7LVmuSYDHw50OMEqWqrVzC9kjUo/J9BkFRc88rrIsEZXbo56sspMahSjzw D9h4yGNwDnFCtyaRU8M0BYknojF2dRTN8PJIiAv0hZWFBQSRlRVv4Gp7Jo/Gpj8RAWTM El3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JOfMtK9uPCRjoqE44RI9oSOYI5o7ys3RsMEi8r5i9TA=; fh=WpfgbTJceSODJ2RxjBwoHNUpZn2apRLDTiiS5YGrd/M=; b=s36PHkUVhhiWLHisEPhZbFaYaAgM+0E5gzrJymVANUwGXt269GUfif2W1M0l+yV+qH ptzvEqDjLW0NwKF7HMIW6OEO9vrsKbbd208UIcmiRcyNmUQ/l+Luo1Q9/SGeofeDvj49 a86+IwC/zVL3Jn3AGAJ9raTcqiOsXqhyxqpyb4nxPb+rCjDWaX+o+/8Hslx6VcW1QB6j J7eSNEI2EuhFtD9rd75yxOtJvfP8VZehRrRvcYnbV6JVgwouCiJGEaohs7gW0ZV+HRb1 VFlNiDUqIWewRfGLVXIgSMERA0CcGWFv0wNHOUvxHSpJScP5V2l01JVnK6Q26GmdSdTT EmQg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=vHMVpagK; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a170902ebd200b001b9c3498526si3175268plg.433.2023.07.19.02.06.40; Wed, 19 Jul 2023 02:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=vHMVpagK; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbjGSJES (ORCPT + 58 others); Wed, 19 Jul 2023 05:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbjGSJDv (ORCPT ); Wed, 19 Jul 2023 05:03:51 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061.outbound.protection.outlook.com [40.107.94.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80AA52710; Wed, 19 Jul 2023 02:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BsNppSfUEXlBIDImnKLZPD2f7Qb1F3JLlBaqOs+Y5Y57VLcwnHbWrtsUBEUXzycZ9JqTBZ3HoJNfkP87qPVckQ9Wf0dg/pl0qphc3bSt2JPwl+L/yDB2Vnw8CaGAYcPmfMlmuEYM2yBxMNotnAteUi44A6P8k2/4I6WA7xvcNbvgfMl7206C/jQWXDYpmtxKLqMlYk2yK7Mbo+nn3DVYWDXRPD3EZq154OCAysYUaT9Gvn+VmgTrDnWGIk78CotEOEczMoMpwybPayhNbEWh3ZH6wpjltazKWu1cQb/Ko9JrxA/mdBhqMKZhNw4zkV50z4uk2VCINH2bdk5IGoENrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JOfMtK9uPCRjoqE44RI9oSOYI5o7ys3RsMEi8r5i9TA=; b=PFTkRkXPtt4lKeQsK49/ca2L+pw3sPP0o5p2nKp1/J0kV035eUISUL99ZiPlMVQbDzGnIxa65utM2zhCHesxUSPLlvRvGfX2T0SaT/Vn3MsQc5iDQEQeZyVJ5VG+rLeIXGvalQHUCoHoTX9BlARaCqeY3aIVxC+f1BAEX+pbSG7V/2GwS24DoOtyoqdjB9EpIdT0zk4ZOeXycSGM8ZHfPgxT1yOlqPe/85fBrq4/lRDggQiB4OsXZ144uBPXwy3y6n0vucF08Wtxqnz/zYYtaTKobjIvSl5yf7hx5I591u1OppM0tOkcxOfBvdh5qN2hqC6LOnXRWprsREP4me+fbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JOfMtK9uPCRjoqE44RI9oSOYI5o7ys3RsMEi8r5i9TA=; b=vHMVpagKWhKwRpmteHCH1UUvOEtfnazSGydeM9OgIOu7zC4rBukjaqYiH3dkcNWMppoR0ktj/GZA71JYJeQKAJoFxII+dtINCcAMnGPPoHtjeD8uKMIC4faPsNcdfayDdTulusokCLEAaUKTtlftDTLfiC00lQazjsacxJQtEic= Received: from DS7PR03CA0119.namprd03.prod.outlook.com (2603:10b6:5:3b7::34) by SA3PR12MB7902.namprd12.prod.outlook.com (2603:10b6:806:305::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.23; Wed, 19 Jul 2023 09:03:15 +0000 Received: from DM6NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::78) by DS7PR03CA0119.outlook.office365.com (2603:10b6:5:3b7::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33 via Frontend Transport; Wed, 19 Jul 2023 09:03:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT070.mail.protection.outlook.com (10.13.173.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 09:03:15 +0000 Received: from equan-buildpc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 19 Jul 2023 04:02:46 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Evan Quan , Mario Limonciello Subject: [PATCH V7 7/9] drm/amd/pm: add flood detection for wbrf events Date: Wed, 19 Jul 2023 17:00:18 +0800 Message-ID: <20230719090020.2716892-8-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230719090020.2716892-1-evan.quan@amd.com> References: <20230719090020.2716892-1-evan.quan@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT070:EE_|SA3PR12MB7902:EE_ X-MS-Office365-Filtering-Correlation-Id: e8ebafaf-e0f6-4641-1e22-08db8836fd02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sbnSgiCSceM9TOu5GnroUfcVyI/jKspmP7ZTuUChA9gNfOrJlopg/abXB+C9QajbNtH5cM9h6Yl3ZWSOhN/mit9vE7I0RQpjob+t5pBJSxO6mXRo0n/elEziEidliT3AT3klnrN04jpbtQLUe+bUkPnF8UG3SStyD8Vzaql6Dq29Ghbn8nQWQ9gHEVJul14ktGKEWPELrLOZ1rK8UoTKJ7FY0oHC2uWVUTsVx65WlE8HU4KlDmlR9pB8evL/djfEy/c8D4zpB1fHleo1ScznR7rUN7cwY5V3HO8vacExVLneMxova0mcjp+JcweQm6WrHkFmqzCJ8Ls686cVcll9n7ZrXfKPX967NQa4S43OrktcHzZhdwMfA8BE6mv8wM5tOGeAxRJzzLEkrpHig9wksVP+F6FVyan8ufXm5MyKZfUxb3KfuXs4tmrM+ud1AqrwhevJ1xFQ/RYX1drdh5XRWKHjVI2FdzQOFPyCLIFqpGcGIwp6+2fvCa1/2qiazwjj7wC0tigwt/MYDUEHHyglF+jqxdKNQT9T80fj6Hg9dG8fnJTGCySbakV7K8Sb2quqBzBzFyWOZ58sZt/dILEOpzK2INsH3aRIM0FP73IooxpZ/qxTMuO/OaKpTjVadgRrtxOZFSC3zax8qngf62nx3KMvyBsaRFeNQIheFbmAxSjyJW2XyPFUixj2ZIyYmJTLOXtj8KnYG3Gxwd2gd98yd91+XKrmuxdJ7U0zcaaTEqTPgcq4urQ/6qdWFGSiD9/hlTvIK8RoLFtkAdKFU8wzJfq6p7T37WHaw1VO7ZwLbQPKJtrsUJc30pgYdh9AU5/sV9gAmvPNLHDCXJfMPfAXag== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(82310400008)(451199021)(40470700004)(36840700001)(46966006)(2906002)(44832011)(7416002)(8936002)(8676002)(4326008)(316002)(41300700001)(5660300002)(26005)(336012)(1076003)(36756003)(7696005)(186003)(70586007)(70206006)(478600001)(6666004)(110136005)(16526019)(40460700003)(54906003)(47076005)(83380400001)(2616005)(426003)(36860700001)(81166007)(356005)(40480700001)(921005)(86362001)(82740400003)(36900700001)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 09:03:15.6661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8ebafaf-e0f6-4641-1e22-08db8836fd02 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7902 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org To protect PMFW from being overloaded. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 31 +++++++++++++++---- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 83d428e890df..aa7faeafc86b 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1278,7 +1278,8 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, switch (action) { case WBRF_CHANGED: - smu_wbrf_handle_exclusion_ranges(smu); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); break; default: return NOTIFY_DONE; @@ -1287,6 +1288,21 @@ static int smu_wbrf_event_handler(struct notifier_block *nb, return NOTIFY_OK; } +/** + * smu_wbrf_delayed_work_handler - callback on delayed work timer expired + * + * @work: struct work_struct pointer + * + * Flood is over and driver will consume the latest exclusion ranges. + */ +static void smu_wbrf_delayed_work_handler(struct work_struct *work) +{ + struct smu_context *smu = + container_of(work, struct smu_context, wbrf_delayed_work.work); + + smu_wbrf_handle_exclusion_ranges(smu); +} + /** * smu_wbrf_support_check - check wbrf support * @@ -1317,12 +1333,14 @@ static void smu_wbrf_support_check(struct smu_context *smu) */ static int smu_wbrf_init(struct smu_context *smu) { - struct amdgpu_device *adev = smu->adev; int ret; if (!smu->wbrf_supported) return 0; + INIT_DELAYED_WORK(&smu->wbrf_delayed_work, + smu_wbrf_delayed_work_handler); + smu->wbrf_notifier.notifier_call = smu_wbrf_event_handler; ret = wbrf_register_notifier(&smu->wbrf_notifier); if (ret) @@ -1333,11 +1351,10 @@ static int smu_wbrf_init(struct smu_context *smu) * before our driver loaded. To make sure our driver * is awared of those exclusion ranges. */ - ret = smu_wbrf_handle_exclusion_ranges(smu); - if (ret) - dev_err(adev->dev, "Failed to handle wbrf exclusion ranges\n"); + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); - return ret; + return 0; } /** @@ -1353,6 +1370,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; wbrf_unregister_notifier(&smu->wbrf_notifier); + + cancel_delayed_work_sync(&smu->wbrf_delayed_work); } static int smu_smc_hw_setup(struct smu_context *smu) diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h index 5b2343cfc69b..5df28d4a8c30 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -480,6 +480,12 @@ struct stb_context { #define WORKLOAD_POLICY_MAX 7 +/* + * Configure wbrf event handling pace as there can be only one + * event processed every SMU_WBRF_EVENT_HANDLING_PACE ms. + */ +#define SMU_WBRF_EVENT_HANDLING_PACE 10 + struct smu_context { struct amdgpu_device *adev; @@ -579,6 +585,7 @@ struct smu_context /* data structures for wbrf feature support */ bool wbrf_supported; struct notifier_block wbrf_notifier; + struct delayed_work wbrf_delayed_work; }; struct i2c_adapter; -- 2.34.1