Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/events/evgpe.c
          +++ new/usr/src/common/acpica/components/events/evgpe.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: evgpe - General Purpose Event handling and dispatch
   4    4   *
   5    5   *****************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2014, Intel Corp.
   9    9   * All rights reserved.
  10   10   *
  11   11   * Redistribution and use in source and binary forms, with or without
  12   12   * modification, are permitted provided that the following conditions
  13   13   * are met:
  14   14   * 1. Redistributions of source code must retain the above copyright
  15   15   *    notice, this list of conditions, and the following disclaimer,
  16   16   *    without modification.
  17   17   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18   18   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 23 lines elided ↑ open up ↑
  42   42   */
  43   43  
  44   44  #include "acpi.h"
  45   45  #include "accommon.h"
  46   46  #include "acevents.h"
  47   47  #include "acnamesp.h"
  48   48  
  49   49  #define _COMPONENT          ACPI_EVENTS
  50   50          ACPI_MODULE_NAME    ("evgpe")
  51   51  
       52 +#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
       53 +
  52   54  /* Local prototypes */
  53   55  
  54   56  static void ACPI_SYSTEM_XFACE
  55   57  AcpiEvAsynchExecuteGpeMethod (
  56   58      void                    *Context);
  57   59  
  58   60  static void ACPI_SYSTEM_XFACE
  59   61  AcpiEvAsynchEnableGpe (
  60   62      void                    *Context);
  61   63  
↓ open down ↓ 21 lines elided ↑ open up ↑
  83   85  
  84   86      ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMask);
  85   87  
  86   88  
  87   89      GpeRegisterInfo = GpeEventInfo->RegisterInfo;
  88   90      if (!GpeRegisterInfo)
  89   91      {
  90   92          return_ACPI_STATUS (AE_NOT_EXIST);
  91   93      }
  92   94  
  93      -    RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
       95 +    RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
  94   96  
  95   97      /* Clear the run bit up front */
  96   98  
  97   99      ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit);
  98  100  
  99  101      /* Set the mask bit only if there are references to this GPE */
 100  102  
 101  103      if (GpeEventInfo->RuntimeCount)
 102  104      {
 103  105          ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, (UINT8) RegisterBit);
↓ open down ↓ 318 lines elided ↑ open up ↑
 422  424  
 423  425              GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
 424  426  
 425  427              /*
 426  428               * Optimization: If there are no GPEs enabled within this
 427  429               * register, we can safely ignore the entire register.
 428  430               */
 429  431              if (!(GpeRegisterInfo->EnableForRun |
 430  432                    GpeRegisterInfo->EnableForWake))
 431  433              {
      434 +                ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
      435 +                    "Ignore disabled registers for GPE%02X-GPE%02X: "
      436 +                    "RunEnable=%02X, WakeEnable=%02X\n",
      437 +                    GpeRegisterInfo->BaseGpeNumber,
      438 +                    GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
      439 +                    GpeRegisterInfo->EnableForRun,
      440 +                    GpeRegisterInfo->EnableForWake));
 432  441                  continue;
 433  442              }
 434  443  
 435  444              /* Read the Status Register */
 436  445  
 437  446              Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress);
 438  447              if (ACPI_FAILURE (Status))
 439  448              {
 440  449                  goto UnlockAndExit;
 441  450              }
 442  451  
 443  452              /* Read the Enable Register */
 444  453  
 445  454              Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress);
 446  455              if (ACPI_FAILURE (Status))
 447  456              {
 448  457                  goto UnlockAndExit;
 449  458              }
 450  459  
 451  460              ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
 452      -                "Read GPE Register at GPE%02X: Status=%02X, Enable=%02X\n",
 453      -                GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg));
      461 +                "Read registers for GPE%02X-GPE%02X: Status=%02X, Enable=%02X, "
      462 +                "RunEnable=%02X, WakeEnable=%02X\n",
      463 +                GpeRegisterInfo->BaseGpeNumber,
      464 +                GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
      465 +                StatusReg, EnableReg,
      466 +                GpeRegisterInfo->EnableForRun,
      467 +                GpeRegisterInfo->EnableForWake));
 454  468  
 455  469              /* Check if there is anything active at all in this register */
 456  470  
 457  471              EnabledStatusByte = (UINT8) (StatusReg & EnableReg);
 458  472              if (!EnabledStatusByte)
 459  473              {
 460  474                  /* No active GPEs in this register, move on */
 461  475  
 462  476                  continue;
 463  477              }
↓ open down ↓ 45 lines elided ↑ open up ↑
 509  523   ******************************************************************************/
 510  524  
 511  525  static void ACPI_SYSTEM_XFACE
 512  526  AcpiEvAsynchExecuteGpeMethod (
 513  527      void                    *Context)
 514  528  {
 515  529      ACPI_GPE_EVENT_INFO     *GpeEventInfo = Context;
 516  530      ACPI_STATUS             Status;
 517  531      ACPI_GPE_EVENT_INFO     *LocalGpeEventInfo;
 518  532      ACPI_EVALUATE_INFO      *Info;
      533 +    ACPI_GPE_NOTIFY_INFO    *Notify;
 519  534  
 520  535  
 521  536      ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod);
 522  537  
 523  538  
 524  539      /* Allocate a local GPE block */
 525  540  
 526  541      LocalGpeEventInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_EVENT_INFO));
 527  542      if (!LocalGpeEventInfo)
 528  543      {
 529  544          ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
 530  545              "while handling a GPE"));
 531  546          return_VOID;
 532  547      }
 533  548  
 534  549      Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
 535  550      if (ACPI_FAILURE (Status))
 536  551      {
      552 +        ACPI_FREE (LocalGpeEventInfo);
 537  553          return_VOID;
 538  554      }
 539  555  
 540  556      /* Must revalidate the GpeNumber/GpeBlock */
 541  557  
 542  558      if (!AcpiEvValidGpeEvent (GpeEventInfo))
 543  559      {
 544  560          Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
      561 +        ACPI_FREE (LocalGpeEventInfo);
 545  562          return_VOID;
 546  563      }
 547  564  
 548  565      /*
 549  566       * Take a snapshot of the GPE info for this level - we copy the info to
 550  567       * prevent a race condition with RemoveHandler/RemoveBlock.
 551  568       */
 552  569      ACPI_MEMCPY (LocalGpeEventInfo, GpeEventInfo,
 553  570          sizeof (ACPI_GPE_EVENT_INFO));
 554  571  
 555  572      Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
 556  573      if (ACPI_FAILURE (Status))
 557  574      {
      575 +        ACPI_FREE (LocalGpeEventInfo);
 558  576          return_VOID;
 559  577      }
 560  578  
 561  579      /* Do the correct dispatch - normal method or implicit notify */
 562  580  
 563  581      switch (LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
 564  582      {
 565  583      case ACPI_GPE_DISPATCH_NOTIFY:
 566      -
 567  584          /*
 568  585           * Implicit notify.
 569  586           * Dispatch a DEVICE_WAKE notify to the appropriate handler.
 570  587           * NOTE: the request is queued for execution after this method
 571  588           * completes. The notify handlers are NOT invoked synchronously
 572  589           * from this thread -- because handlers may in turn run other
 573  590           * control methods.
      591 +         *
      592 +         * June 2012: Expand implicit notify mechanism to support
      593 +         * notifies on multiple device objects.
 574  594           */
 575      -        Status = AcpiEvQueueNotifyRequest (
 576      -                    LocalGpeEventInfo->Dispatch.DeviceNode,
 577      -                    ACPI_NOTIFY_DEVICE_WAKE);
      595 +        Notify = LocalGpeEventInfo->Dispatch.NotifyList;
      596 +        while (ACPI_SUCCESS (Status) && Notify)
      597 +        {
      598 +            Status = AcpiEvQueueNotifyRequest (Notify->DeviceNode,
      599 +                        ACPI_NOTIFY_DEVICE_WAKE);
      600 +
      601 +            Notify = Notify->Next;
      602 +        }
 578  603          break;
 579  604  
 580  605      case ACPI_GPE_DISPATCH_METHOD:
 581  606  
 582  607          /* Allocate the evaluation information block */
 583  608  
 584  609          Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
 585  610          if (!Info)
 586  611          {
 587  612              Status = AE_NO_MEMORY;
↓ open down ↓ 10 lines elided ↑ open up ↑
 598  623              Status = AcpiNsEvaluate (Info);
 599  624              ACPI_FREE (Info);
 600  625          }
 601  626  
 602  627          if (ACPI_FAILURE (Status))
 603  628          {
 604  629              ACPI_EXCEPTION ((AE_INFO, Status,
 605  630                  "while evaluating GPE method [%4.4s]",
 606  631                  AcpiUtGetNodeName (LocalGpeEventInfo->Dispatch.MethodNode)));
 607  632          }
 608      -
 609  633          break;
 610  634  
 611  635      default:
      636 +
 612  637          return_VOID; /* Should never happen */
 613  638      }
 614  639  
 615  640      /* Defer enabling of GPE until all notify handlers are done */
 616  641  
 617  642      Status = AcpiOsExecute (OSL_NOTIFY_HANDLER,
 618  643                  AcpiEvAsynchEnableGpe, LocalGpeEventInfo);
 619  644      if (ACPI_FAILURE (Status))
 620  645      {
 621  646          ACPI_FREE (LocalGpeEventInfo);
↓ open down ↓ 166 lines elided ↑ open up ↑
 788  813          /* If requested, clear (if level-triggered) and reenable the GPE */
 789  814  
 790  815          if (ReturnValue & ACPI_REENABLE_GPE)
 791  816          {
 792  817              (void) AcpiEvFinishGpe (GpeEventInfo);
 793  818          }
 794  819          break;
 795  820  
 796  821      case ACPI_GPE_DISPATCH_METHOD:
 797  822      case ACPI_GPE_DISPATCH_NOTIFY:
 798      -
 799  823          /*
 800  824           * Execute the method associated with the GPE
 801  825           * NOTE: Level-triggered GPEs are cleared after the method completes.
 802  826           */
 803  827          Status = AcpiOsExecute (OSL_GPE_HANDLER,
 804  828                      AcpiEvAsynchExecuteGpeMethod, GpeEventInfo);
 805  829          if (ACPI_FAILURE (Status))
 806  830          {
 807  831              ACPI_EXCEPTION ((AE_INFO, Status,
 808  832                  "Unable to queue handler for GPE%02X - event disabled",
 809  833                  GpeNumber));
 810  834          }
 811  835          break;
 812  836  
 813  837      default:
 814      -
 815  838          /*
 816  839           * No handler or method to run!
 817  840           * 03/2010: This case should no longer be possible. We will not allow
 818  841           * a GPE to be enabled if it has no handler or method.
 819  842           */
 820  843          ACPI_ERROR ((AE_INFO,
 821  844              "No handler or method for GPE%02X, disabling event",
 822  845              GpeNumber));
 823  846          break;
 824  847      }
 825  848  
 826  849      return_UINT32 (ACPI_INTERRUPT_HANDLED);
 827  850  }
 828  851  
      852 +#endif /* !ACPI_REDUCED_HARDWARE */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX