From patchwork Fri May 27 03:32:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: aaron lu X-Patchwork-Id: 822662 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4R3XQYe015709 for ; Fri, 27 May 2011 03:33:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753627Ab1E0Dd0 (ORCPT ); Thu, 26 May 2011 23:33:26 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:37690 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753085Ab1E0DdZ (ORCPT ); Thu, 26 May 2011 23:33:25 -0400 Received: by ywe9 with SMTP id 9so580312ywe.19 for ; Thu, 26 May 2011 20:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer; bh=f+VWhp4pD81UAyCC1DLBzfS+tLWYjw2e5lkYQTAkT8Y=; b=chLcBInhfjqZ21nn46bgpslfAKNfojh/pQ+Cb3xuIsi+xciaspk9D7DKZRvDc5eHIG jof3CxFgW3esx1xAUt17Tj6Gd7r0iOYDvdgIL/QmLWFfBdmR6zABUhXIc5nedphf5v8J f3bTvXzMvDZHUH+jftfFxia0n0D7HpjpVna/E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=BnkAsE5U9QZCBlLe705pvlglHKSFyMiV6AEDuo4G8OWtC/BtRJxDkt8+7uVZAIuryN mpb4UWNfIro8N9jsKwn5hkGAEFfiY2yqrfXnxvnBBlUJwBvWhT0xVf3kLfcYDjZRVtjf IkvGqwa1EdqfapOJUqV4zCbi2lQAApzpg3Zxw= Received: by 10.150.63.12 with SMTP id l12mr1738496yba.120.1306467203397; Thu, 26 May 2011 20:33:23 -0700 (PDT) Received: from localhost.localdomain ([210.13.97.168]) by mx.google.com with ESMTPS id w15sm815895ybk.16.2011.05.26.20.33.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 May 2011 20:33:22 -0700 (PDT) From: Aaron Lu To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org, arindam.nath@amd.com, henry.su@amd.com, mjg59@srcf.ucam.org, Aaron Lu Subject: [PATCH v2] ACPI: execute _PSx control method if exists during device power init phase Date: Fri, 27 May 2011 11:32:26 +0800 Message-Id: <1306467146-5994-1-git-send-email-aaron.lu@amd.com> X-Mailer: git-send-email 1.7.4.4 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 27 May 2011 03:33:26 +0000 (UTC) V2: Added a check to the power state, make sure it's valid before executing the _PSx control method. V1: Per the acpi spec, for OSPM to put the device in the Dx device state, the following must occur: 1. All Power Resources referenced by elements 1 through N must be in the ON state. 2. All Power Resources no longer referenced by any device in the system must be in the OFF state. 3. If present, the _PSx control method is executed to set the device into the Dx device state. This patch adds support for the execution of _PSx control method during device power init phase. This could also solves the problem I encountered, please see: http://marc.info/?l=linux-acpi&m=130579961021505&w=2 --- drivers/acpi/bus.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 9749980..ea4eb64 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -337,8 +337,22 @@ int acpi_bus_init_power(struct acpi_device *device) if (result) return result; - if (device->power.flags.power_resources) + if (device->power.flags.power_resources) { result = acpi_power_on_resources(device, state); + if (result) + return result; + } + + /* if state is valid and _PSx exists, execute it */ + if (state >= ACPI_STATE_D0 && state <= ACPI_STATE_D3 && + device->power.states[state].flags.explicit_set) { + acpi_status status; + char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; + status = acpi_evaluate_object(device->handle, object_name, + NULL, NULL); + if (ACPI_FAILURE(status)) + result = -ENODEV; + } if (!result) device->power.state = state;