1    /*
2     * Some or all of this work - Copyright (c) 2006 - 2021, Intel Corp.
3     * All rights reserved.
4     *
5     * Redistribution and use in source and binary forms, with or without modification,
6     * are permitted provided that the following conditions are met:
7     *
8     * Redistributions of source code must retain the above copyright notice,
9     * this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright notice,
11     * this list of conditions and the following disclaimer in the documentation
12     * and/or other materials provided with the distribution.
13     * Neither the name of Intel Corporation nor the names of its contributors
14     * may be used to endorse or promote products derived from this software
15     * without specific prior written permission.
16     *
17     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20     * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25     * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27     */
28    /*
29     * Bug 299:
30     *
31     * SUMMARY: Many outstanding allocations on abnormal termination of AcpiDsCallControlMethod
32     *
33     *
34     * [ACPI Debug]  String: [0x29] "========= ROOT METHODS SUMMARY (max 600):"
35     * [ACPI Debug]  String: [0x3E] ":STST:bug-demo:Demo of bug 299:m1e8:FAIL:Errors # 01 00 00 00:"
36     * [ACPI Debug]  String: [0x0E] "========= END."
37     * [ACPI Debug]  String: [0x5B] "TEST ACPICA: 64-bit : FAIL : Errors # 0x0000000000000001, Failed tests # 0x0000000000000001"
38     * Outstanding: 0x14 allocations after execution
39     * Execution of \MAIN returned object 00327E40 Buflen 10
40     *   [Integer] = 0000000000000001
41     * - q
42     * 0047DDE8 Len 0028   utcache-414 [Operand]      Integer R1
43     * 0047DE48 Len 0028   utcache-414 [Operand]      Integer R1
44     * 0047DEA8 Len 0028   utcache-414 [Operand]      Integer R1
45     * 0047DF08 Len 0028   utcache-414 [Operand]      Integer R1
46     * 0047DF68 Len 0028   utcache-414 [Operand]      Integer R1
47     * 0047DFC8 Len 0028   utcache-414 [Operand]      Integer R1
48     * 0047C988 Len 0028   utcache-414 [Operand]      Integer R1
49     * 0047C9E8 Len 0028   utcache-414 [Operand]      Integer R1
50     * 0047CA48 Len 0028   utcache-414 [Operand]      Integer R1
51     * 0047CAA8 Len 0028   utcache-414 [Operand]      Integer R1
52     * 0047CB08 Len 0028   utcache-414 [Operand]      Integer R1
53     * 0047CB68 Len 0028   utcache-414 [Operand]      Integer R1
54     * 0047C328 Len 0028   utcache-414 [Operand]      Integer R1
55     * 0047C848 Len 0028   utcache-414 [Operand]      Integer R1
56     * 0047B398 Len 0028   utcache-414 [Operand]      Integer R1
57     * 0047A128 Len 0028   utcache-414 [Operand]      Integer R1
58     * ACPI Error (uttrack-0719): 16(10) Outstanding allocations [20061215]
59     */
60    Method (M1E8, 0, NotSerialized)
61    {
62        Method (M306, 2, Serialized)
63        {
64            Name (I000, 0x00)
65            Name (I001, 0x00)
66            Name (I002, 0x34)
67            Name (I003, 0xABCD0003)
68            Name (I004, 0xABCD0004)
69            Method (M000, 1, Serialized)
70            {
71                If (Arg0)
72                {
73                    I004 = 0x00
74                }
75                Else
76                {
77                    I003 = 0x00
78                }
79
80                MM00 (0x07, I000, I001)
81            }
82
83            Method (M001, 1, Serialized, 1)
84            {
85                If (Arg0)
86                {
87                    I004 = 0x01
88                }
89                Else
90                {
91                    I003 = 0x01
92                }
93
94                MM00 (0x08, I000, I001)
95            }
96
97            Method (MM00, 3, NotSerialized)
98            {
99                Local0 = I002 /* \M1E8.M306.I002 */
100                I002++
101                If ((I002 > 0x36))
102                {
103                    Return (Zero)
104                }
105
106                If (Arg0)
107                {
108                    Local1 = Arg2
109                }
110                Else
111                {
112                    Local1 = Arg1
113                }
114
115                If ((Local1 == 0x00))
116                {
117                    M000 (Local0)
118                }
119                Else
120                {
121                    M001 (Local0)
122                }
123            }
124
125            I000 = Arg0
126            I001 = Arg1
127            MM00 (0x00, I000, I001)
128        }
129
130        CH03 (__METHOD__, 0x00, __LINE__, 0x00, 0x00)
131        M306 (0x09, 0x00)
132        M306 (0x09, 0x00)
133        M306 (0x09, 0x00)
134        M306 (0x09, 0x00)
135        M306 (0x09, 0x00)
136        M306 (0x09, 0x00)
137        M306 (0x09, 0x00)
138        M306 (0x09, 0x00)
139        M306 (0x09, 0x00)
140        M306 (0x09, 0x00)
141        M306 (0x09, 0x00)
142        M306 (0x09, 0x00)
143        M306 (0x09, 0x00)
144        M306 (0x09, 0x00)
145        M306 (0x09, 0x00)
146        M306 (0x09, 0x00)
147        CH04 (__METHOD__, 0x01, 0x40, 0x00, __LINE__, 0x00, 0x00) /* AE_AML_MUTEX_ORDER */
148        /*
149         * The problem is not automatically detected,
150         * so remove this error report after the problem has been resolved.
151         */
152        ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, 0x00, 0x00)
153    }
154