Print this page
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/utilities/utmutex.c
          +++ new/usr/src/common/acpica/components/utilities/utmutex.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: utmutex - local mutex support
   4    4   *
   5    5   ******************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2013, 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 ↓ 70 lines elided ↑ open up ↑
  89   89  
  90   90      for (i = 0; i < ACPI_NUM_MUTEX; i++)
  91   91      {
  92   92          Status = AcpiUtCreateMutex (i);
  93   93          if (ACPI_FAILURE (Status))
  94   94          {
  95   95              return_ACPI_STATUS (Status);
  96   96          }
  97   97      }
  98   98  
  99      -    /* Create the spinlocks for use at interrupt level */
       99 +    /* Create the spinlocks for use at interrupt level or for speed */
 100  100  
 101  101      Status = AcpiOsCreateLock (&AcpiGbl_GpeLock);
 102  102      if (ACPI_FAILURE (Status))
 103  103      {
 104  104          return_ACPI_STATUS (Status);
 105  105      }
 106  106  
 107  107      Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock);
 108  108      if (ACPI_FAILURE (Status))
 109  109      {
 110  110          return_ACPI_STATUS (Status);
 111  111      }
 112  112  
      113 +    Status = AcpiOsCreateLock (&AcpiGbl_ReferenceCountLock);
      114 +    if (ACPI_FAILURE (Status))
      115 +    {
      116 +        return_ACPI_STATUS (Status);
      117 +    }
      118 +
 113  119      /* Mutex for _OSI support */
      120 +
 114  121      Status = AcpiOsCreateMutex (&AcpiGbl_OsiMutex);
 115  122      if (ACPI_FAILURE (Status))
 116  123      {
 117  124          return_ACPI_STATUS (Status);
 118  125      }
 119  126  
 120  127      /* Create the reader/writer lock for namespace access */
 121  128  
 122  129      Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock);
 123  130      return_ACPI_STATUS (Status);
↓ open down ↓ 29 lines elided ↑ open up ↑
 153  160      {
 154  161          AcpiUtDeleteMutex (i);
 155  162      }
 156  163  
 157  164      AcpiOsDeleteMutex (AcpiGbl_OsiMutex);
 158  165  
 159  166      /* Delete the spinlocks */
 160  167  
 161  168      AcpiOsDeleteLock (AcpiGbl_GpeLock);
 162  169      AcpiOsDeleteLock (AcpiGbl_HardwareLock);
      170 +    AcpiOsDeleteLock (AcpiGbl_ReferenceCountLock);
 163  171  
 164  172      /* Delete the reader/writer lock */
 165  173  
 166  174      AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock);
 167  175      return_VOID;
 168  176  }
 169  177  
 170  178  
 171  179  /*******************************************************************************
 172  180   *
↓ open down ↓ 45 lines elided ↑ open up ↑
 218  226      ACPI_MUTEX_HANDLE       MutexId)
 219  227  {
 220  228  
 221  229      ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId);
 222  230  
 223  231  
 224  232      AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
 225  233  
 226  234      AcpiGbl_MutexInfo[MutexId].Mutex = NULL;
 227  235      AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
      236 +
      237 +    return_VOID;
 228  238  }
 229  239  
 230  240  
 231  241  /*******************************************************************************
 232  242   *
 233  243   * FUNCTION:    AcpiUtAcquireMutex
 234  244   *
 235  245   * PARAMETERS:  MutexID         - ID of the mutex to be acquired
 236  246   *
 237  247   * RETURN:      Status
↓ open down ↓ 19 lines elided ↑ open up ↑
 257  267      }
 258  268  
 259  269      ThisThreadId = AcpiOsGetThreadId ();
 260  270  
 261  271  #ifdef ACPI_MUTEX_DEBUG
 262  272      {
 263  273          UINT32                  i;
 264  274          /*
 265  275           * Mutex debug code, for internal debugging only.
 266  276           *
 267      -         * Deadlock prevention.  Check if this thread owns any mutexes of value
 268      -         * greater than or equal to this one.  If so, the thread has violated
 269      -         * the mutex ordering rule.  This indicates a coding error somewhere in
      277 +         * Deadlock prevention. Check if this thread owns any mutexes of value
      278 +         * greater than or equal to this one. If so, the thread has violated
      279 +         * the mutex ordering rule. This indicates a coding error somewhere in
 270  280           * the ACPI subsystem code.
 271  281           */
 272  282          for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
 273  283          {
 274  284              if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId)
 275  285              {
 276  286                  if (i == MutexId)
 277  287                  {
 278  288                      ACPI_ERROR ((AE_INFO,
 279  289                          "Mutex [%s] already acquired by this thread [%u]",
↓ open down ↓ 48 lines elided ↑ open up ↑
 328  338   * RETURN:      Status
 329  339   *
 330  340   * DESCRIPTION: Release a mutex object.
 331  341   *
 332  342   ******************************************************************************/
 333  343  
 334  344  ACPI_STATUS
 335  345  AcpiUtReleaseMutex (
 336  346      ACPI_MUTEX_HANDLE       MutexId)
 337  347  {
 338      -    ACPI_THREAD_ID          ThisThreadId;
 339      -
 340      -
 341  348      ACPI_FUNCTION_NAME (UtReleaseMutex);
 342  349  
 343  350  
 344      -    ThisThreadId = AcpiOsGetThreadId ();
 345  351      ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n",
 346      -        (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
      352 +        (UINT32) AcpiOsGetThreadId (), AcpiUtGetMutexName (MutexId)));
 347  353  
 348  354      if (MutexId > ACPI_MAX_MUTEX)
 349  355      {
 350  356          return (AE_BAD_PARAMETER);
 351  357      }
 352  358  
 353  359      /*
 354  360       * Mutex must be acquired in order to release it!
 355  361       */
 356  362      if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED)
↓ open down ↓ 3 lines elided ↑ open up ↑
 360  366  
 361  367          return (AE_NOT_ACQUIRED);
 362  368      }
 363  369  
 364  370  #ifdef ACPI_MUTEX_DEBUG
 365  371      {
 366  372          UINT32                  i;
 367  373          /*
 368  374           * Mutex debug code, for internal debugging only.
 369  375           *
 370      -         * Deadlock prevention.  Check if this thread owns any mutexes of value
 371      -         * greater than this one.  If so, the thread has violated the mutex
 372      -         * ordering rule.  This indicates a coding error somewhere in
      376 +         * Deadlock prevention. Check if this thread owns any mutexes of value
      377 +         * greater than this one. If so, the thread has violated the mutex
      378 +         * ordering rule. This indicates a coding error somewhere in
 373  379           * the ACPI subsystem code.
 374  380           */
 375  381          for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
 376  382          {
 377      -            if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId)
      383 +            if (AcpiGbl_MutexInfo[i].ThreadId == AcpiOsGetThreadId ())
 378  384              {
 379  385                  if (i == MutexId)
 380  386                  {
 381  387                      continue;
 382  388                  }
 383  389  
 384  390                  ACPI_ERROR ((AE_INFO,
 385  391                      "Invalid release order: owns [%s], releasing [%s]",
 386  392                      AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId)));
 387  393  
↓ open down ↓ 3 lines elided ↑ open up ↑
 391  397      }
 392  398  #endif
 393  399  
 394  400      /* Mark unlocked FIRST */
 395  401  
 396  402      AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
 397  403  
 398  404      AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
 399  405      return (AE_OK);
 400  406  }
 401      -
 402      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX