public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Starikovskiy <astarikovskiy@suse.de>
To: "Zhao, Yakui" <yakui.zhao@intel.com>
Cc: LenBrown <lenb@kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"Brown, Len" <len.brown@intel.com>,
	"Li, Shaohua" <shaohua.li@intel.com>,
	"Zhang, Rui" <rui.zhang@intel.com>,
	"Lin, Ming M" <ming.m.lin@intel.com>
Subject: Re: The fatal  logic error in EC write transaction(EC transaction is done in interrupt context)
Date: Sat, 08 Nov 2008 18:33:57 +0300	[thread overview]
Message-ID: <4915B165.8020207@suse.de> (raw)
In-Reply-To: <9F0C1DB20AFA954FA1DA05309350433D40C7CC84@pdsmsx503.ccr.corp.intel.com>

Hi Yakui,

Just don't know how I would have lived without your valuable analisys...
Do you remember that ec_transaction starts by waiting for IBF to become 0?
Thus not any new transaction should begin before previous write or burst-disable command completes.
So, fatal logic error exists only in your head.

Now, let me explain why it is better to wait for last IBF=0 event at beginning of transaction, rather than at the end of previous one.
Look at the flow chart from different angle -- as fast transaction patch does it:
EC sends interrupt to OS then it is ready for us to proceed. It will send us interrupt marking IBF=0 transition if it expects us to write byte and it will send us interrupt marking OBF=1 transition if it expects us to read byte. It does not ever send us IBF=1 or OBF=0 interrupts just because there is nothing we could of should do in such a case.
After we completed write sequence, we don't need to wait for last IBF=0 transition, as we don't know if we will have anything else to write -- it might be last transaction for quite a while. But next transaction knows that it should not start before IBF is cleared, thus it waits 
for it (and expects possible interrupt).

Regards,
Alex.
 
Zhao, Yakui wrote:
> Hi, Alexey
>      After checking the EC working flowchart I find a fatal logic error that exists in EC write transaction. The issue happens on most laptops. The following is the detailed explanation about this issue:
>      According to the ACPI the EC write transaction is divided into the following three phases: (Seen in the section 12.6.2 of ACPI 3.0b)
>      a. Byte #1: Host Writes the EC command to EC CMD I/O PORT. Interrupt is triggered after EC reads the command byte 
>      b. Byte #2: Host writes the address index to EC data I/O port. Interrupt is triggered after EC reads the address index byte
>      c. Byte #3: Host writes the Data to EC data I/O port. Interrupt is triggered after EC reads the data byte
>    
>    When the function of acpi_ec_transaction_unlocked is called for EC write transaction, the wlen variable is initialized as 2 and the rlen variable is initialized as zero. Then EC transaction follows the below three steps.
>      1. OS writes the EC command to EC CMD I/O port
>      2. EC GPE interrupt is triggered and then the address index is written into EC data I/O port. (The wlen is decreased to 1.This is executed in EC GPE handler)
>      3. EC GPE interrupt is triggered again and then the data is written into the EC data I/O port. The wlen is decreased to 0.(This is also executed in EC GPE handler). As the wlen is decreased to zero, it means that the EC transaction is finished(True is returned by the function of ec_transaction_done). 
>       >status = acpi_ec_read_status(ec);
>       >gpe_transaction(ec, status);
>       > if (ec_transaction_done(ec) && (status & ACPI_EC_FLAG_IBF) == 0)
>                 wake_up(&ec->wait); 
>      In this step the status variable only indicates that EC controller already reads the address index written by OS(It can’t indicate that EC controller already reads the data byte written by Host). As the IBF flag is zero, the waiting process is waked up and EC mutex lock is released. In such case it means that OS can begin another EC transaction. 
>      But in fact in such case EC transaction is not really finished. After the EC data is written into EC Data I/O port, no flag indicates whether EC transaction is finished. Only when the IBF bit becomes zero again, we can say that EC transaction is really finished. If OS begins another EC transaction before previous EC transaction is really finished, we can't imagine what will happen.
>   IMO Based on the above analysis there exists the fatal logic error in the EC write transaction after the patch from Alexey is shipped. Although now no one reports this issue, it is still an unstable factor. After all it is the fatal logic error. 
>    
>    At the same time there exists the similar logic error when OS begins an EC transaction to disable the EC burst mode.
>      
>   Welcome the comments.
>      
>   Best regards
>        Yakui
> 
>     
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2008-11-08 15:34 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-07  4:39 ACPI patches for 2.6.28-rc3 Len Brown
2008-11-07  4:39 ` [PATCH 01/21] i7300_idle: Kconfig, show menu only on x86_64 Len Brown
2008-11-07  4:39   ` [PATCH 02/21] ACPI: EC: revert msleep patch Len Brown
2008-11-07  4:39   ` [PATCH 03/21] sony-laptop: Ignore missing _DIS method on pic device Len Brown
2008-11-07  4:39   ` [PATCH 04/21] ACPI: fix de-reference bug in power resource driver Len Brown
2008-11-07  4:39   ` [PATCH 05/21] ACPI: fan: Delete the strict check in power transition Len Brown
2008-11-07  4:39   ` [PATCH 06/21] ACPI: bugfix reporting of event handler status Len Brown
2008-11-07  4:39   ` [PATCH 07/21] ACPI EC: Fix regression due to use of uninitialized variable Len Brown
2008-11-07  6:13     ` Zhao Yakui
2008-11-07 19:45       ` Len Brown
2008-11-08 14:04         ` The fatal logic error in EC write transaction(EC transaction is done in interrupt context) Zhao, Yakui
2008-11-08 15:33           ` Alexey Starikovskiy [this message]
2008-11-08 15:58             ` Zhao, Yakui
2008-11-08 16:47               ` Alexey Starikovskiy
2008-11-08 18:42                 ` [PATCH] ACPI: EC: wait for last write gpe Alexey Starikovskiy
2008-11-09 12:45                   ` Zhao Yakui
2008-11-09 13:11                 ` The fatal logic error in EC write transaction(EC transaction is done in interrupt context) Zhao Yakui
2008-11-09 15:27                   ` Spreading FUD [was: The fatal logic error in EC write transaction(EC transaction is done in interrupt context)] Alexey Starikovskiy
2008-11-10  1:01                     ` Zhao Yakui
2008-11-10 18:48                       ` Alexey Starikovskiy
2008-11-07  4:39   ` [PATCH 08/21] intel_menlow: don't set max_state a negative value Len Brown
2008-11-07  4:39   ` [PATCH 09/21] ACPI: remove comments about debug layer/level to use Len Brown
2008-11-07  4:39   ` [PATCH 10/21] ACPI: SBS: remove useless acpi_cm_sbs_init() initcall Len Brown
2008-11-07  4:39   ` [PATCH 11/21] ACPI: remove CONFIG_ACPI_POWER Len Brown
2008-11-07  4:39   ` [PATCH 12/21] ACPI: remove CONFIG_ACPI_EC Len Brown
2008-11-07  4:39   ` [PATCH 13/21] intel_menlow: Add comment documenting legal GTHS values Len Brown
2008-11-07  4:39   ` [PATCH 14/21] intel_menlow: MAINTAINERS Len Brown
2008-11-07  4:39   ` [PATCH 15/21] Revert "ACPI: Ingore the RESET_REG_SUP bit when using ACPI reset mechanism" Len Brown
2008-11-07  4:39   ` [PATCH 16/21] PNP: add Bjorn Helgaas as PNP co-maintainer Len Brown
2008-11-07  4:39   ` [PATCH 17/21] ACPI: struct device - replace bus_id with dev_name(), dev_set_name() Len Brown
2008-11-07  4:39   ` [PATCH 18/21] fujitsu-laptop: fix section mismatch warning Len Brown
2008-11-07  4:39   ` [PATCH 19/21] ACPI: use macro to replace hard number Len Brown
2008-11-07  4:39   ` [PATCH 20/21] ACPI: avoid empty file name in sysfs Len Brown
2008-11-07  4:39   ` [PATCH 21/21] ACPI: EC: make kernel messages more useful when GPE storm is detected Len Brown
2008-11-07  9:18     ` Alan Jenkins
2008-11-07 13:54       ` Rafael J. Wysocki
2008-11-07 18:49         ` [stable] " Greg KH
2008-11-07 22:15           ` Rafael J. Wysocki
2008-11-11 21:23             ` Greg KH
2008-11-12 23:34               ` Rafael J. Wysocki
2008-11-13 21:46                 ` Greg KH
2008-11-07 17:41 ` ACPI patches for 2.6.28-rc3 Andrey Borzenkov
2008-11-08  2:48   ` Len Brown

Reply instructions:

You may reply publicly 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=4915B165.8020207@suse.de \
    --to=astarikovskiy@suse.de \
    --cc=len.brown@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=rui.zhang@intel.com \
    --cc=shaohua.li@intel.com \
    --cc=yakui.zhao@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox