From patchwork Mon Oct 5 08:46:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenji Kaneshige X-Patchwork-Id: 51711 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n958oT9d032637 for ; Mon, 5 Oct 2009 08:50:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758661AbZJEIru (ORCPT ); Mon, 5 Oct 2009 04:47:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758687AbZJEIru (ORCPT ); Mon, 5 Oct 2009 04:47:50 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:60809 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758661AbZJEIrt (ORCPT ); Mon, 5 Oct 2009 04:47:49 -0400 Received: from m2.gw.fujitsu.co.jp ([10.0.50.72]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id n958lCNk022421 for (envelope-from kaneshige.kenji@jp.fujitsu.com); Mon, 5 Oct 2009 17:47:12 +0900 Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 736D245DE51 for ; Mon, 5 Oct 2009 17:47:12 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 4F29C45DE55 for ; Mon, 5 Oct 2009 17:47:12 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 1D2361DB8042 for ; Mon, 5 Oct 2009 17:47:12 +0900 (JST) Received: from ml13.s.css.fujitsu.com (ml13.s.css.fujitsu.com [10.249.87.103]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id BC0F41DB803E for ; Mon, 5 Oct 2009 17:47:11 +0900 (JST) Received: from ml13.css.fujitsu.com (ml13 [127.0.0.1]) by ml13.s.css.fujitsu.com (Postfix) with ESMTP id 8FFF8FD0001; Mon, 5 Oct 2009 17:47:11 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.100.137]) by ml13.s.css.fujitsu.com (Postfix) with ESMTP id 43165FD0003; Mon, 5 Oct 2009 17:47:11 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Received: from KANE-LIFEBOOK[10.124.100.137] by KANE-LIFEBOOK (FujitsuOutboundMailChecker v1.3.1/9992[10.124.100.137]); Mon, 05 Oct 2009 17:46:47 +0900 (JST) Message-ID: <4AC9B273.7030204@jp.fujitsu.com> Date: Mon, 05 Oct 2009 17:46:43 +0900 From: Kenji Kaneshige User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: jbarnes@virtuousgeek.org, linux-pci@vger.kernel.org Subject: [PATCH 6/6] pciehp: prevent unnecessary power off References: <4AC9B0AE.3010908@jp.fujitsu.com> In-Reply-To: <4AC9B0AE.3010908@jp.fujitsu.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Index: linux-2.6.32-rc3/drivers/pci/hotplug/pciehp_core.c =================================================================== --- linux-2.6.32-rc3.orig/drivers/pci/hotplug/pciehp_core.c +++ linux-2.6.32-rc3/drivers/pci/hotplug/pciehp_core.c @@ -253,14 +253,13 @@ static int pciehp_probe(struct pcie_devi int rc; struct controller *ctrl; struct slot *slot; - u8 value; - struct pci_dev *pdev = dev->port; + u8 occupied, poweron; if (pciehp_force) dev_info(&dev->device, "Bypassing BIOS check for pciehp use on %s\n", - pci_name(pdev)); - else if (pciehp_get_hp_hw_control_from_firmware(pdev)) + pci_name(dev->port)); + else if (pciehp_get_hp_hw_control_from_firmware(dev->port)) goto err_out_none; ctrl = pcie_init(dev); @@ -290,18 +289,13 @@ static int pciehp_probe(struct pcie_devi /* Check if slot is occupied */ slot = ctrl->slot; - pciehp_get_adapter_status(slot, &value); - if (value) { - if (pciehp_force) - pciehp_enable_slot(slot); - } else { - /* Power off slot if not occupied */ - if (POWER_CTRL(ctrl)) { - rc = pciehp_power_off_slot(slot); - if (rc) - goto err_out_free_ctrl_slot; - } - } + pciehp_get_adapter_status(slot, &occupied); + pciehp_get_power_status(slot, &poweron); + if (occupied && pciehp_force) + pciehp_enable_slot(slot); + /* If empty slot's power status is on, turn power off */ + if (!occupied && poweron && POWER_CTRL(ctrl)) + pciehp_power_off_slot(slot); return 0;