Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
From: Maximilian Luz <luzmaximilian@gmail.com>
To: "Kaneda, Erik" <erik.kaneda@intel.com>,
	"Moore, Robert" <robert.moore@intel.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>
Cc: "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"devel@acpica.org" <devel@acpica.org>
Subject: Re: PROBLEM: Calling ObjectType on buffer field reports type integer
Date: Wed, 4 Dec 2019 20:33:53 +0100
Message-ID: <6fc2767d-4f48-dc7f-1bc1-6d0a2014b8f4@gmail.com> (raw)
In-Reply-To: <DM6PR11MB3612787F2B1143C658168A26F0420@DM6PR11MB3612.namprd11.prod.outlook.com>

On 12/3/19 11:21 PM, Kaneda, Erik wrote:
> Hi Maximilian,
> 
> Please try the patch below:

Hi,

I've tested this on 5.4.1 and the current upstream master now.
Unfortunately it doesn't seem to fix the issue.

Specifically, it seems like the flag doesn't get set here
(printk-debugging indicates that the code in the if never runs):

>   /******************************************************************************
> diff -Nurp linux.before_name/drivers/acpi/acpica/dsutils.c linux.after_name/drivers/acpi/acpica/dsutils.c
> --- linux.before_name/drivers/acpi/acpica/dsutils.c	2019-12-03 13:36:21.782578718 -0800
> +++ linux.after_name/drivers/acpi/acpica/dsutils.c	2019-12-03 13:36:17.765579110 -0800
> @@ -470,6 +470,9 @@ acpi_ds_create_operand(struct acpi_walk_
>   			    ACPI_CAST_PTR(union acpi_operand_object,
>   					  walk_state->deferred_node);
>   			status = AE_OK;
> +			if (walk_state->opcode == AML_CREATE_FIELD_OP) {
> +				obj_desc->buffer_field.is_create_field = TRUE;
> +			}
>   		} else {	/* All other opcodes */
> 
>   			/*

That of course means that the if condition here is still not fulfilled,
so the problem is not fixed.

> diff -Nurp linux.before_name/drivers/acpi/acpica/exfield.c linux.after_name/drivers/acpi/acpica/exfield.c
> --- linux.before_name/drivers/acpi/acpica/exfield.c	2019-12-03 13:36:21.791578717 -0800
> +++ linux.after_name/drivers/acpi/acpica/exfield.c	2019-12-03 13:36:18.257579062 -0800
> @@ -153,12 +154,17 @@ acpi_ex_read_data_from_field(struct acpi
>   	 * the use of arithmetic operators on the returned value if the
>   	 * field size is equal or smaller than an Integer.
>   	 *
> +	 * However, all buffer fields created by create_field operator needs to
> +	 * remain as a buffer to match other AML interpreter implementations.
> +	 *
>   	 * Note: Field.length is in bits.
>   	 */
>   	buffer_length =
>   	    (acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length);
>   
> -	if (buffer_length > acpi_gbl_integer_byte_width) {
> +	if (buffer_length > acpi_gbl_integer_byte_width ||
> +	    (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD &&
> +	     obj_desc->buffer_field.is_create_field)) {
>   
>   		/* Field is too large for an Integer, create a Buffer instead */
> 

If I'm not mistaken I've proposed a patch here that is conceptually
quite similar (but may have some flaws or cause other issues, as I'm not
really familiar with the ACPICA code-base). My idea was to modify
acpi_ds_init_buffer_field (dsopcode.c) instead of
acpi_ds_create_operand. As said, I'm not sure however if this may have
any other consequences that I'm unaware of.

Also I've avoided creating an is_create_field flag by changing the field
access from AML_FIELD_ACCESS_BYTE to AML_FIELD_ACCESS_BUFFER (which
doesn't seem to be used anywhere else) and checking that, but the
general idea of extending the if condition in
acpi_ex_read_data_from_field is the same.

Link to the patch:
https://github.com/qzed/linux-surfacegen5-acpi/blob/2014964bac52f138109443de3e92dc2c6cff5e83/patches/5.3/0001-ACPI-Fix-buffer-integer-type-mismatch.patch

Thanks,
Maximilian

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3ef42aa1-196d-f3db-0e5d-2fd84c198242@gmail.com>
     [not found] ` <CF6A88132359CE47947DB4C6E1709ED53C592D47@ORSMSX122.amr.corp.intel.com>
     [not found]   ` <CF6A88132359CE47947DB4C6E1709ED53C59405C@ORSMSX122.amr.corp.intel.com>
     [not found]     ` <fe4bcc1c-5c15-caa6-ce01-a5df962ff008@gmail.com>
     [not found]       ` <CF6A88132359CE47947DB4C6E1709ED53C5942CA@ORSMSX122.amr.corp.intel.com>
     [not found]         ` <51e156ec-c2ed-84be-13c0-99a213e1d4b7@gmail.com>
     [not found]           ` <CF6A88132359CE47947DB4C6E1709ED53C595C50@ORSMSX122.amr.corp.intel.com>
2019-07-20 20:45             ` Maximilian Luz
2019-07-22 23:01               ` Schmauss, Erik
2019-07-23 11:38                 ` Maximilian Luz
2019-11-10 21:29                 ` Maximilian Luz
2019-11-22 17:11                   ` Moore, Robert
2019-11-22 22:07                     ` Moore, Robert
2019-11-22 23:00                       ` Maximilian Luz
2019-11-22 23:29                       ` Schmauss, Erik
2019-11-23  0:33                         ` Maximilian Luz
2019-11-27  0:25                           ` Schmauss, Erik
2019-12-03 22:21                             ` Kaneda, Erik
2019-12-04 19:33                               ` Maximilian Luz [this message]
2019-12-05 23:57                                 ` Kaneda, Erik
2019-12-06 13:48                                   ` Maximilian Luz

Reply instructions:

You may reply publically 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=6fc2767d-4f48-dc7f-1bc1-6d0a2014b8f4@gmail.com \
    --to=luzmaximilian@gmail.com \
    --cc=devel@acpica.org \
    --cc=erik.kaneda@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.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

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git