Skip to content

Commit f9a1639

Browse files
binbinwu1wenlingz
authored andcommitted
dm: passthru: fix hardcoded nhlt table length
NHLT table contains the settings some audio drivers need. An ACPI method is used to get NHLT table address & length. In current DM code, the NHLT talbe length in the ACPI method is hardcoded, which will cause troubles when the length of the table changed. This patch replaces the hardcoded NHLT table length according to the table length read from SOS. Tracked-On: #1461 Signed-off-by: Binbin Wu <binbin.wu@intel.com> Acked-by: Yin Fengwei <fengwei.yin@intel.com>
1 parent 1d725c8 commit f9a1639

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

devicemodel/hw/pci/passthrough.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
*/
7070
#define AUDIO_NHLT_HACK 1
7171

72+
extern uint64_t audio_nhlt_len;
73+
7274
/* TODO: Add support for IO BAR of PTDev */
7375
static int iofd = -1;
7476

@@ -1555,9 +1557,10 @@ write_dsdt_hdas(struct pci_vdev *dev)
15551557
" MaxNotFixed, NonCacheable, ReadOnly,");
15561558
dsdt_line(" 0x0000000000000000, // Granularity");
15571559
dsdt_line(" 0x00000000000F2800, // Range Minimum");
1558-
dsdt_line(" 0x00000000000F2FDE, // Range Maximum");
1560+
dsdt_line(" 0x%08X, // Range Maximum",
1561+
0xF2800 + audio_nhlt_len -1);
15591562
dsdt_line(" 0x0000000000000000, // Translation Offset");
1560-
dsdt_line(" 0x00000000000007DF, // Length");
1563+
dsdt_line(" 0x%08X, // Length", audio_nhlt_len);
15611564
dsdt_line(" ,, _Y06, AddressRangeACPI, TypeStatic)");
15621565
dsdt_line(" })");
15631566
dsdt_line(" Name (_S0W, 0x03) // _S0W: S0 Device Wake State");

devicemodel/hw/platform/acpi/acpi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
#define ASL_SUFFIX ".aml"
8787
#define ASL_COMPILER "/usr/sbin/iasl"
8888

89+
uint64_t audio_nhlt_len = 0;
90+
8991
static int basl_keep_temps;
9092
static int basl_verbose_iasl;
9193
static int basl_ncpu;
@@ -595,8 +597,10 @@ basl_fwrite_nhlt(FILE *fp, struct vmctx *ctx)
595597
return -1;
596598
}
597599

600+
601+
audio_nhlt_len = lseek(fd, 0, SEEK_END);
598602
/* check if file size exceeds reserved room */
599-
if (lseek(fd, 0, SEEK_END) > DSDT_OFFSET - NHLT_OFFSET) {
603+
if (audio_nhlt_len > DSDT_OFFSET - NHLT_OFFSET) {
600604
fprintf(stderr, "Host NHLT exceeds reserved room!\n");
601605
close(fd);
602606
return -1;

0 commit comments

Comments
 (0)