Skip to content

Cherry-pick GMA fixes #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/drivers/intel/gma/opregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static inline bool uses_relative_vbt_addr(opregion_header_t *header)
* values correctly for the opregion.
*/
static void opregion_add_ext_vbt(igd_opregion_t *opregion, uint8_t *ext_vbt,
optionrom_vbt_t *vbt)
optionrom_vbt_t *vbt, size_t ext_vbt_size)
{
opregion_header_t *header = &opregion->header;
/* Copy VBT into extended VBT region (at offset 8 KiB) */
Expand All @@ -301,7 +301,7 @@ static void opregion_add_ext_vbt(igd_opregion_t *opregion, uint8_t *ext_vbt,
else
opregion->mailbox3.rvda = (uintptr_t)ext_vbt;

opregion->mailbox3.rvds = vbt->hdr_vbt_size;
opregion->mailbox3.rvds = ext_vbt_size;
}

/* Initialize IGD OpRegion, called from ACPI code and OS drivers */
Expand All @@ -311,6 +311,7 @@ enum cb_err intel_gma_init_igd_opregion(void)
struct region_device rdev;
optionrom_vbt_t *vbt = NULL;
size_t opregion_size = sizeof(igd_opregion_t);
size_t ext_vbt_size;

if (acpi_is_wakeup_s3())
return intel_gma_restore_opregion();
Expand All @@ -331,7 +332,9 @@ enum cb_err intel_gma_init_igd_opregion(void)
}

/* Add the space for the extended VBT header even if it's not used */
opregion_size += vbt->hdr_vbt_size;
/* Align the VBT to nearest 512 byte boundary */
ext_vbt_size = ALIGN_UP(vbt->hdr_vbt_size, 512);
opregion_size += ext_vbt_size;

opregion = cbmem_add(CBMEM_ID_IGD_OPREGION, opregion_size);
if (!opregion) {
Expand All @@ -353,7 +356,7 @@ enum cb_err intel_gma_init_igd_opregion(void)
if (is_ext_vbt_required(opregion, vbt)) {
/* Place extended VBT just after opregion */
uint8_t *ext_vbt = (uint8_t *)opregion + sizeof(*opregion);
opregion_add_ext_vbt(opregion, ext_vbt, vbt);
opregion_add_ext_vbt(opregion, ext_vbt, vbt, ext_vbt_size);
} else {
/* Raw VBT size which can fit in gvd1 */
memcpy(opregion->vbt.gvd1, vbt, vbt->hdr_vbt_size);
Expand All @@ -364,8 +367,8 @@ enum cb_err intel_gma_init_igd_opregion(void)
/* 8kb */
opregion->header.size = sizeof(igd_opregion_t) / 1024;

// FIXME We just assume we're mobile for now
opregion->header.mailboxes = MAILBOXES_MOBILE;
// Supported mailboxes
opregion->header.mailboxes = IGD_MAILBOXES;

// TODO Initialize Mailbox 1
opregion->mailbox1.clid = 1;
Expand Down
4 changes: 1 addition & 3 deletions src/drivers/intel/gma/opregion.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ typedef struct {
#define IGD_MBOX4 (1 << 3)
#define IGD_MBOX5 (1 << 4)

#define MAILBOXES_MOBILE (IGD_MBOX1 | IGD_MBOX2 | IGD_MBOX3 | \
IGD_MBOX4 | IGD_MBOX5)
#define MAILBOXES_DESKTOP (IGD_MBOX2 | IGD_MBOX4)
#define IGD_MAILBOXES (IGD_MBOX1 | IGD_MBOX3 | IGD_MBOX4 | IGD_MBOX5)

#define SBIOS_VERSION_SIZE 32

Expand Down