Skip to content

Commit 3f720b2

Browse files
Shyam Sundar S Kij-intel
authored andcommitted
platform/x86/amd/pmc: Add dump_custom_stb module parameter
There have been instances when the default size (1M) of the STB is not sufficient to get the complete traces of the failure. In such scenarios we can use a module_param to enable full trace that shall contain more debugging data. This is not a regular case and hence not enabling this capability by default. With this change, there will be two cases on how the driver fetches the stb data: 1) A special case (proposed now) - which is required only for certain platforms. Here, a new module param will be supplied to the driver that will have a special PMFW supporting enhanced dram sizes for getting the stb data. Without the special PMFW support, just setting the module param will not help to get the enhanced stb data. To adapt to this change, we will have a new amd_pmc_stb_handle_efr() to handle enhanced firmware reporting mechanism. Note that, since num_samples based r/w pointer offset calculation is not required for enhanced firmware reporting we will have this mailbox command sent only in case of regular STB cases. 2) Current code branch which fetches the stb data based on the parameters like the num_samples, fsize and the r/w pointer. Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Co-developed-by: Harsh Jain <[email protected]> Signed-off-by: Harsh Jain <[email protected]> Signed-off-by: Sanket Goswami <[email protected]> Signed-off-by: Shyam Sundar S K <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ij: Renamed flex_arr -> stb_data_arr] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent b136225 commit 3f720b2

File tree

1 file changed

+32
-0
lines changed
  • drivers/platform/x86/amd/pmc

1 file changed

+32
-0
lines changed

drivers/platform/x86/amd/pmc/pmc.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
/* STB Spill to DRAM Parameters */
5555
#define S2D_TELEMETRY_BYTES_MAX 0x100000U
56+
#define S2D_RSVD_RAM_SPACE 0x100000
5657
#define S2D_TELEMETRY_DRAMBYTES_MAX 0x1000000
5758

5859
/* STB Spill to DRAM Message Definition */
@@ -165,6 +166,10 @@ static bool disable_workarounds;
165166
module_param(disable_workarounds, bool, 0644);
166167
MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bugs");
167168

169+
static bool dump_custom_stb;
170+
module_param(dump_custom_stb, bool, 0644);
171+
MODULE_PARM_DESC(dump_custom_stb, "Enable to dump full STB buffer");
172+
168173
static struct amd_pmc_dev pmc;
169174
static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret);
170175
static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf);
@@ -241,6 +246,25 @@ static const struct file_operations amd_pmc_stb_debugfs_fops = {
241246
.release = amd_pmc_stb_debugfs_release,
242247
};
243248

249+
/* Enhanced STB Firmware Reporting Mechanism */
250+
static int amd_pmc_stb_handle_efr(struct file *filp)
251+
{
252+
struct amd_pmc_dev *dev = filp->f_inode->i_private;
253+
struct amd_pmc_stb_v2_data *stb_data_arr;
254+
u32 fsize;
255+
256+
fsize = dev->dram_size - S2D_RSVD_RAM_SPACE;
257+
stb_data_arr = kmalloc(struct_size(stb_data_arr, data, fsize), GFP_KERNEL);
258+
if (!stb_data_arr)
259+
return -ENOMEM;
260+
261+
stb_data_arr->size = fsize;
262+
memcpy_fromio(stb_data_arr->data, dev->stb_virt_addr, fsize);
263+
filp->private_data = stb_data_arr;
264+
265+
return 0;
266+
}
267+
244268
static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
245269
{
246270
struct amd_pmc_dev *dev = filp->f_inode->i_private;
@@ -260,6 +284,14 @@ static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
260284
if (ret)
261285
dev_dbg_once(dev->dev, "S2D force flush not supported: %d\n", ret);
262286

287+
/*
288+
* We have a custom stb size and the PMFW is supposed to give
289+
* the enhanced dram size. Note that we land here only for the
290+
* platforms that support enhanced dram size reporting.
291+
*/
292+
if (dump_custom_stb)
293+
return amd_pmc_stb_handle_efr(filp);
294+
263295
/* Get the num_samples to calculate the last push location */
264296
ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, dev->s2d_msg_id, true);
265297
/* Clear msg_port for other SMU operation */

0 commit comments

Comments
 (0)