From: Evan Quan <evan.quan@amd.com>
To: <rafael@kernel.org>, <lenb@kernel.org>,
<alexander.deucher@amd.com>, <christian.koenig@amd.com>,
<Xinhui.Pan@amd.com>, <airlied@gmail.com>, <daniel@ffwll.ch>,
<evan.quan@amd.com>, <kvalo@kernel.org>, <nbd@nbd.name>,
<lorenzo@kernel.org>, <ryder.lee@mediatek.com>,
<shayne.chen@mediatek.com>, <sean.wang@mediatek.com>,
<matthias.bgg@gmail.com>,
<angelogioacchino.delregno@collabora.com>,
<Mario.Limonciello@amd.com>, <Lijo.Lazar@amd.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
<amd-gfx@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>,
<linux-wireless@vger.kernel.org>, <ath11k@lists.infradead.org>,
<ath12k@lists.infradead.org>
Subject: [PATCH 7/9] drm/amd/pm: add flood detection for wbrf events
Date: Tue, 30 May 2023 10:42:25 +0800 [thread overview]
Message-ID: <20230530024227.2139632-8-evan.quan@amd.com> (raw)
In-Reply-To: <20230530024227.2139632-1-evan.quan@amd.com>
To protect PMFW from being overloaded.
Signed-off-by: Evan Quan <evan.quan@amd.com>
--
v1->v2:
- utilize the delayed work(Lijo, Christian)
- split the new module parameter changes out(Christian, Alex)
v2->v3:
- simplify the flood detection further per latest design
v3->v4:
- drop unneeded wbrf_mutex(Lijo, Christian)
- use schedule_delayed_work() to avoid possible concurrent
access(Chrisitan)
---
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;
--
2.34.1
next prev parent reply other threads:[~2023-05-30 2:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 2:42 [PATCH 0/9] Support Wifi RFI interference mitigation feature Evan Quan
2023-05-30 2:42 ` [PATCH 1/9] drivers/acpi: Add support for Wifi band RF mitigations Evan Quan
2023-05-30 2:42 ` [PATCH 2/9] mt76: Add support to the Mediatek MT7921 for ACPI WBRF Evan Quan
2023-05-30 2:42 ` [PATCH 3/9] wifi: ath11k: Add support to the Qualcomm ath11k " Evan Quan
2023-05-30 2:42 ` [PATCH 4/9] wifi: ath12k: Add support to the Qualcomm ath12k " Evan Quan
2023-05-30 2:42 ` [PATCH 5/9] drm/amd/pm: update driver_if and ppsmc headers for coming wbrf feature Evan Quan
2023-05-30 2:42 ` [PATCH 6/9] drm/amd/pm: setup the framework to support Wifi RFI mitigation feature Evan Quan
2023-05-30 2:42 ` Evan Quan [this message]
2023-05-30 2:42 ` [PATCH 8/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.0 Evan Quan
2023-05-30 13:50 ` kernel test robot
2023-05-30 14:10 ` kernel test robot
2023-05-30 2:42 ` [PATCH 9/9] drm/amd/pm: enable Wifi RFI mitigation feature support for SMU13.0.7 Evan Quan
2023-05-30 19:43 ` kernel test robot
2023-05-30 6:22 ` [PATCH 0/9] Support Wifi RFI interference mitigation feature Felix Fietkau
2023-05-30 15:34 ` Limonciello, Mario
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230530024227.2139632-8-evan.quan@amd.com \
--to=evan.quan@amd.com \
--cc=Lijo.Lazar@amd.com \
--cc=Mario.Limonciello@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=ath11k@lists.infradead.org \
--cc=ath12k@lists.infradead.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kvalo@kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@nbd.name \
--cc=rafael@kernel.org \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox