Skip to content
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

core/opregion: Avoid needless loads for fields marked Preserve #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion core/opregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,17 @@ void lai_write_field_internal(uint8_t *source, lai_nsnode_t *field) {

uint64_t value;
if (write_flag == FIELD_PRESERVE) {
if (field->type == LAI_NAMESPACE_FIELD || field->type == LAI_NAMESPACE_BANKFIELD) {
if (access_size == access_bits) {
// Don't needlessly read from the field if we're going to replace all of the bits.
// This is more in line with ACPICA's behavior, and the additional reads could've
// potentially confused hardware.

// If we're accessing the whole word, we can't start anywhere else.
LAI_ENSURE(bit_offset == 0);

value = 0;
} else if (field->type == LAI_NAMESPACE_FIELD
|| field->type == LAI_NAMESPACE_BANKFIELD) {
value = lai_perform_read(field->fld_region_node, access_size, offset);
} else if (field->type == LAI_NAMESPACE_INDEXFIELD) {
value = lai_perform_indexfield_read(field, access_size, offset);
Expand Down
Loading