From patchwork Fri Jun 16 06:57:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Quan X-Patchwork-Id: 108890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1145869vqr; Fri, 16 Jun 2023 00:23:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ627bt4oCYr0f6+kyGWbR/1czZ2NCkU40GHZ650nCxDIGLDbeWiXEfj88fS/vXZAYn6zqaf X-Received: by 2002:a05:620a:d8c:b0:75b:23a0:d9dc with SMTP id q12-20020a05620a0d8c00b0075b23a0d9dcmr1166296qkl.50.1686900217964; Fri, 16 Jun 2023 00:23:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686900217; cv=pass; d=google.com; s=arc-20160816; b=BVB1u2jULXlC8fa+2ytdrfnF+MyCU+WsRdxh/Vx5JuaIq6irq5EDOdCkMJEUMWqK2B rAV8BxDKnKLi0+rcp6qRKl71vYtLo9KmVjfI5r/zjb8xSNKJrLVguRe1AE/q2GeKO5L2 hGXksQ4JMd8k8Q+UfJqUKHC0281eOdz9gzHVZZkBNKs06lYo2e0+hsmLs5h//fSCNFVc ToqpdmneP671h7j8CmP0nyuKCpdDoCpdNA1d8+zqtppUVdDtjqXoP0ZqaU3wJV5SULsw fXQv14LfGwhRm0ghxLwb4VUcNMwkbaquWeVZb2mT4ViWPA5nrclGAnHAk2GtGa9qV3Hk uXYg== 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=w2vAmDKr5lEouUGHRYcDaTacr7hNBq+6N/BBGVsYBsE=; b=biNt0VyvpDHv601CDxGnrcM+ymAsxPrwd1Y2UKA27lvu5Y3YA9RsJxY0enue0zip4O jRceztWf/PzCOEy6IxGoHz8qsJWYCGwR1GxSiHohcp5tzeVJHKLv0NJJjmMXAO4NKQr0 2P2ctWWHOD+KJ31oUDYuOmXldhiibFTR/Kv/poynK5pWv5/pNWygwmyF5GVPPSimcmLR gdn+pgGm7nZwJ+u05bNzGfNpefOoxdaUcT7AbhYAwEZ5ykPwKdlSKV0y7nObEozQYG4j FGiaqGFGOLVlUKErx/7jH/0Ns4Pt6tXkqC9lOXKf1z3iTLeFrY8OKYdHUkHVq2gxCMQ3 SAZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=NB0ExcST; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a625e06000000b0063b7c4435c0si14586532pfb.54.2023.06.16.00.23.23; Fri, 16 Jun 2023 00:23:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=NB0ExcST; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S244058AbjFPHBC (ORCPT + 99 others); Fri, 16 Jun 2023 03:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244119AbjFPG7w (ORCPT ); Fri, 16 Jun 2023 02:59:52 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2048.outbound.protection.outlook.com [40.107.95.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 533ED3589; Thu, 15 Jun 2023 23:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kM0ton+zF8dFNeDKRhZY6EU2ltMFCtYrpAN7/9K2fHgW7kbzhJ0Bi2HxvRQ7Lnyneoa3YWxJztoMwD0ZzOwaVl5qg7qtPv3SZiQFViHzHiv032bwmp25m1pRIhlf+z51mAaF+I6wdKQwi5yhIrHdMrxookinzFykK46GxARmqmEKTHFAPyoXDgARPjtjhD3L10DVo3npeOkJzup5sPhxTg6Ar2YTqdPsQB+IUkFPn2kJG0ZDbov6sFG5uPU1mue1D3NuMn+4c0cm+ssLMDGIWL4V2BxHDtyp58g2oN8pVKya8FNW4KTFK83gBNCydHwLBWA7vIPkEoJPPimrNCBahg== 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=w2vAmDKr5lEouUGHRYcDaTacr7hNBq+6N/BBGVsYBsE=; b=Wa3YCEjeP0ag2CXeueV1N/zTVycSgHzotUPxbwW8dwTBwVg/Iu5VXYm8114zJoww8eXInFPwxMdUN74/o1HSEPhnlk7IoXi6yhDW33FnsPNtwCcpAMZdkTRAFKsI1vnlOeNYkTpNiSRGzeqYh1HogOQt2LmYlm+VcjEAx1LpsjD/KYhP/cXiQkXInb3ctS4SqhwmMA28y6fL+Zeb770qQ7slRMHJZGYFeKTSxwgG+QhhunUjJH9934M7g83CcgVwR33s6IzCuqoSOvKudcxnAHoNd9V9eFV5TfzKoZzCAbZNGw1ZKcYv3kFAfEYtbE/GOT9kCHQpJBqALMXDoNo7fA== 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=w2vAmDKr5lEouUGHRYcDaTacr7hNBq+6N/BBGVsYBsE=; b=NB0ExcSTxAnPmCqhfJPBrzhz6ncpCcNoheRhcFKillw417ikbCRbuBvCYqubvRfksC+T6DKqih7XebMGvsLc7k3OFVMgW0l4+fM3X1b53KdmggyCJZ4NlVWklL9KeoY7VJIGXZm+O3TpXBjYHCoXqdk746ohG3Hfw8ebVyD+aLo= Received: from BN9P223CA0019.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::24) by CY8PR12MB8361.namprd12.prod.outlook.com (2603:10b6:930:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27; Fri, 16 Jun 2023 06:59:23 +0000 Received: from BN8NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10b:cafe::88) by BN9P223CA0019.outlook.office365.com (2603:10b6:408:10b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27 via Frontend Transport; Fri, 16 Jun 2023 06:59:22 +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 BN8NAM11FT003.mail.protection.outlook.com (10.13.177.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 06:59:22 +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; Fri, 16 Jun 2023 01:59:16 -0500 From: Evan Quan To: , , , , , , , , , , , , , , , , CC: , , , , , Evan Quan Subject: [PATCH V3 5/7] drm/amd/pm: add flood detection for wbrf events Date: Fri, 16 Jun 2023 14:57:55 +0800 Message-ID: <20230616065757.1054422-6-evan.quan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616065757.1054422-1-evan.quan@amd.com> References: <20230616065757.1054422-1-evan.quan@amd.com> MIME-Version: 1.0 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: BN8NAM11FT003:EE_|CY8PR12MB8361:EE_ X-MS-Office365-Filtering-Correlation-Id: c4befece-993d-4af1-2633-08db6e3736ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ld13y2Xr9KvvTE0ZNHxyQtYyE1E6mEcd9zMXbNueFL5Iu3C+YUU/7EEZ4zPqp/LzCUvgnVzDfgruJ4z/ofZ/fqrGg3XDfjMo6sNnBljmsB02SMxQAiib/xeIBSGyqJrvpbFA21EkGJftyuPkYwsljEWRc8g3izerLRMXb2iwKwDFE65UIKDkPIofwJ/VHTnn1wKLy9/Skh1ffwLGzGms8EyoAhykHZihXfMHQse8aETIpK5Cl3GTBvhwE7JiNfOlQdBjFbEs4l8zO4fw70mnzAIATgqLPInpaDKyVRw6/rKyZM7IfO4CxIcal8GkW193x5f4DQ7TK+6SbCxSOkkQhnp6V/4yCjZABhsnzz5gm+wFzIJ9cZf5SSzxDzpnhRmIInTJtFbXy0VwS4WU8C9vNhSHMnb3eWKHOUpAvnqwO3SrdDR5TTFnCHNIDnMJtDd45kg5af0L100fwD/q1qkC6ui0tYsABDdKu7II0yl+vpbN/cyYTd89LdrjQVyNp5bHL9sngjFsfhBbCTHPKkZTWL1gl6eYFCDQUzRGWXNGTSTe1TZ6KzJy3kVh6snTm4rG+SVpYWpSca1sc+AROVgEDp7P1cRjUYiGNlNe6Rq0tuHNqGsAYAn8RfIF1x869niIq5WTTesSAzl8YwVdReBY0pvUG3mtwF88bxN5hkCWPzo4lRf4HNqoXCSNwB/4CxmXqS7rMXyRyNia6Nf7TbSeStAMSTu9KF9WamglKrd46UMtAGBABDE5lo5iI49dFwPxFLryF5at4268ThBy7KBYmy9qKm1p36UXCKbIZCq5E1A= 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)(346002)(136003)(396003)(39860400002)(376002)(451199021)(36840700001)(40470700004)(46966006)(5660300002)(478600001)(54906003)(8936002)(40480700001)(41300700001)(316002)(8676002)(7696005)(1076003)(110136005)(7416002)(16526019)(44832011)(186003)(4326008)(6636002)(70586007)(70206006)(6666004)(26005)(2616005)(47076005)(83380400001)(40460700003)(36860700001)(336012)(426003)(2906002)(81166007)(921005)(356005)(82740400003)(82310400005)(86362001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 06:59:22.6487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4befece-993d-4af1-2633-08db6e3736ef 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: BN8NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8361 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_NONE,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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768843083013819211?= X-GMAIL-MSGID: =?utf-8?q?1768843083013819211?= To protect PMFW from being overloaded. Signed-off-by: Evan Quan Reviewed-by: Mario Limonciello --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 28 ++++++++++++++++--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 89f876cc60e6..2619e310ef54 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1272,6 +1272,22 @@ static void smu_wbrf_event_handler(struct amdgpu_device *adev) { struct smu_context *smu = adev->powerplay.pp_handle; + schedule_delayed_work(&smu->wbrf_delayed_work, + msecs_to_jiffies(SMU_WBRF_EVENT_HANDLING_PACE)); +} + +/** + * 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); } @@ -1311,6 +1327,9 @@ static int smu_wbrf_init(struct smu_context *smu) if (!smu->wbrf_supported) return 0; + INIT_DELAYED_WORK(&smu->wbrf_delayed_work, + smu_wbrf_delayed_work_handler); + ret = amdgpu_acpi_register_wbrf_notify_handler(adev, smu_wbrf_event_handler); if (ret) @@ -1321,11 +1340,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; } /** @@ -1343,6 +1361,8 @@ static void smu_wbrf_fini(struct smu_context *smu) return; amdgpu_acpi_unregister_wbrf_notify_handler(adev); + + 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 ff0af3da0be2..aa63cc43d41c 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h @@ -478,6 +478,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; @@ -576,6 +582,7 @@ struct smu_context /* data structures for wbrf feature support */ bool wbrf_supported; + struct delayed_work wbrf_delayed_work; }; struct i2c_adapter;