Bug 1791 - reference count for new created Package item
Summary: reference count for new created Package item
Status: CLOSED PATCH_ALREADY_AVAILABLE
Alias: None
Product: ACPI
Classification: Unclassified
Component: ACPICA-Core (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: Robert Moore
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-05 05:06 UTC by Luming Yu
Modified: 2006-09-28 13:22 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.4 2.6
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
a proposal (622 bytes, patch)
2004-01-05 05:15 UTC, Luming Yu
Details | Diff
Revised simpler patch -- works (559 bytes, patch)
2004-01-07 22:56 UTC, Nate Lawson
Details | Diff

Description Luming Yu 2004-01-05 05:06:39 UTC
Below test case shows the issue:

Name (BT0P, Package (0x04) {})
...

Method (GBST, 4, NotSerialized)
{
Store (0x123, Index (Arg3, 0x00))
...
}

Method (SBST, 0, NotSerialized)
{
XOr ( Derefof (Index (BT0I, 0x00)),0x01,Local0)
Return ( GBST (0x00, HB0S, Local0, BT0P))
}
Method (_BIF, 0, NotSerialized)
{
..
Store(SBST(), Debug)
Store ("_BIF: Index(BT0P, 0x00)", Debug)
..
}

Debug result:
....
exoparg1-0807 [42] ex_opcode_1A_0T_1R    : NULL package element obj c12d8bc8
 psparse-1120: *** Error: Method execution failed 
[\_SB_.PCI0.ISA_.EC__.BAT0._BT
Comment 1 Luming Yu 2004-01-05 05:08:37 UTC
Sorry, method _BIF should be:

 Method (_BIF, 0, NotSerialized)
 {
Store(SBST(), Debug)
Store (derefof(Index (BT0P, 0x00)), Local0)
}
Comment 2 Luming Yu 2004-01-05 05:15:04 UTC
Created attachment 1796 [details]
a proposal 

The problem is that if create package element with statement:
Store (0xXXX, Index(ArgX, 0xXXX)), we should increment reference
counter to the package element to prevent it could be removed as 
an operand in walk_state.
Comment 3 Luming Yu 2004-01-06 05:20:52 UTC
Patch for solving root of null pointer problem is avaliable at bug 1799
Comment 4 Nate Lawson 2004-01-06 14:13:16 UTC
I'm a little concerned about all the gyrations about reference counts related to
the Store opcode.  There have been quite a few problems in this area.  I don't
understand how these problems could occur if we just followed the ACPI spec:

1. If "Store(1, Object)", follow conversion rules then copy to Destination.
2. If "Store(1, Arg0)", copy to Destination or DerefOf(Destination) if
Destination is a reference.
3. If "Store(1, Local0)", copy to Destination without any conversion.

Perhaps we should throw out these attempts to do reference counting (shared
objects) and always copy according to the above rules.  The only reason to avoid
copying is performance and I don't think copying would hurt real world ACPI
performance.
Comment 5 Nate Lawson 2004-01-07 22:56:03 UTC
The proposed patch works and _BST evaluation once again works although I
modified it slightly to make it simpler.  I'm attaching that revised version.
Comment 6 Nate Lawson 2004-01-07 22:56:39 UTC
Created attachment 1812 [details]
Revised simpler patch -- works
Comment 7 Robert Moore 2004-01-13 13:43:15 UTC
The reference counting mechanism solves several issues, not just related to 
Store().

Note You need to log in before you can comment on or make changes to this bug.