@@ -704,12 +704,12 @@ static void start_transaction(struct acpi_ec *ec)
704
704
705
705
static int ec_guard (struct acpi_ec * ec )
706
706
{
707
- unsigned long guard = usecs_to_jiffies (ec_polling_guard );
707
+ unsigned long guard = usecs_to_jiffies (ec -> polling_guard );
708
708
unsigned long timeout = ec -> timestamp + guard ;
709
709
710
710
/* Ensure guarding period before polling EC status */
711
711
do {
712
- if (ec_busy_polling ) {
712
+ if (ec -> busy_polling ) {
713
713
/* Perform busy polling */
714
714
if (ec_transaction_completed (ec ))
715
715
return 0 ;
@@ -973,6 +973,28 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending)
973
973
spin_unlock_irqrestore (& ec -> lock , flags );
974
974
}
975
975
976
+ static void acpi_ec_enter_noirq (struct acpi_ec * ec )
977
+ {
978
+ unsigned long flags ;
979
+
980
+ spin_lock_irqsave (& ec -> lock , flags );
981
+ ec -> busy_polling = true;
982
+ ec -> polling_guard = 0 ;
983
+ ec_log_drv ("interrupt blocked" );
984
+ spin_unlock_irqrestore (& ec -> lock , flags );
985
+ }
986
+
987
+ static void acpi_ec_leave_noirq (struct acpi_ec * ec )
988
+ {
989
+ unsigned long flags ;
990
+
991
+ spin_lock_irqsave (& ec -> lock , flags );
992
+ ec -> busy_polling = ec_busy_polling ;
993
+ ec -> polling_guard = ec_polling_guard ;
994
+ ec_log_drv ("interrupt unblocked" );
995
+ spin_unlock_irqrestore (& ec -> lock , flags );
996
+ }
997
+
976
998
void acpi_ec_block_transactions (void )
977
999
{
978
1000
struct acpi_ec * ec = first_ec ;
@@ -1253,15 +1275,15 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
1253
1275
if (function != ACPI_READ && function != ACPI_WRITE )
1254
1276
return AE_BAD_PARAMETER ;
1255
1277
1256
- if (ec_busy_polling || bits > 8 )
1278
+ if (ec -> busy_polling || bits > 8 )
1257
1279
acpi_ec_burst_enable (ec );
1258
1280
1259
1281
for (i = 0 ; i < bytes ; ++ i , ++ address , ++ value )
1260
1282
result = (function == ACPI_READ ) ?
1261
1283
acpi_ec_read (ec , address , value ) :
1262
1284
acpi_ec_write (ec , address , * value );
1263
1285
1264
- if (ec_busy_polling || bits > 8 )
1286
+ if (ec -> busy_polling || bits > 8 )
1265
1287
acpi_ec_burst_disable (ec );
1266
1288
1267
1289
switch (result ) {
@@ -1304,6 +1326,8 @@ static struct acpi_ec *acpi_ec_alloc(void)
1304
1326
spin_lock_init (& ec -> lock );
1305
1327
INIT_WORK (& ec -> work , acpi_ec_event_handler );
1306
1328
ec -> timestamp = jiffies ;
1329
+ ec -> busy_polling = true;
1330
+ ec -> polling_guard = 0 ;
1307
1331
return ec ;
1308
1332
}
1309
1333
@@ -1365,6 +1389,7 @@ static int ec_install_handlers(struct acpi_ec *ec, bool handle_events)
1365
1389
acpi_ec_start (ec , false);
1366
1390
1367
1391
if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , & ec -> flags )) {
1392
+ acpi_ec_enter_noirq (ec );
1368
1393
status = acpi_install_address_space_handler (ec -> handle ,
1369
1394
ACPI_ADR_SPACE_EC ,
1370
1395
& acpi_ec_space_handler ,
@@ -1404,6 +1429,7 @@ static int ec_install_handlers(struct acpi_ec *ec, bool handle_events)
1404
1429
/* This is not fatal as we can poll EC events */
1405
1430
if (ACPI_SUCCESS (status )) {
1406
1431
set_bit (EC_FLAGS_GPE_HANDLER_INSTALLED , & ec -> flags );
1432
+ acpi_ec_leave_noirq (ec );
1407
1433
if (test_bit (EC_FLAGS_STARTED , & ec -> flags ) &&
1408
1434
ec -> reference_count >= 1 )
1409
1435
acpi_ec_enable_gpe (ec , true);
@@ -1786,34 +1812,6 @@ int __init acpi_ec_ecdt_probe(void)
1786
1812
}
1787
1813
1788
1814
#ifdef CONFIG_PM_SLEEP
1789
- static void acpi_ec_enter_noirq (struct acpi_ec * ec )
1790
- {
1791
- unsigned long flags ;
1792
-
1793
- if (ec == first_ec ) {
1794
- spin_lock_irqsave (& ec -> lock , flags );
1795
- ec -> saved_busy_polling = ec_busy_polling ;
1796
- ec -> saved_polling_guard = ec_polling_guard ;
1797
- ec_busy_polling = true;
1798
- ec_polling_guard = 0 ;
1799
- ec_log_drv ("interrupt blocked" );
1800
- spin_unlock_irqrestore (& ec -> lock , flags );
1801
- }
1802
- }
1803
-
1804
- static void acpi_ec_leave_noirq (struct acpi_ec * ec )
1805
- {
1806
- unsigned long flags ;
1807
-
1808
- if (ec == first_ec ) {
1809
- spin_lock_irqsave (& ec -> lock , flags );
1810
- ec_busy_polling = ec -> saved_busy_polling ;
1811
- ec_polling_guard = ec -> saved_polling_guard ;
1812
- ec_log_drv ("interrupt unblocked" );
1813
- spin_unlock_irqrestore (& ec -> lock , flags );
1814
- }
1815
- }
1816
-
1817
1815
static int acpi_ec_suspend_noirq (struct device * dev )
1818
1816
{
1819
1817
struct acpi_ec * ec =
0 commit comments