linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
	Yinghai Lu <yinghai@kernel.org>,
	john.ronciak@intel.com, miles.j.penner@intel.com,
	bruce.w.allan@intel.com,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-pci@vger.kernel.org, x86@kernel.org
Subject: [PATCH v2 5/8] PCI: acpiphp: kill SLOT_ENABLED in favor of always re-enumerating the devices
Date: Wed,  3 Jul 2013 17:04:52 +0300	[thread overview]
Message-ID: <1372860295-8306-6-git-send-email-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <1372860295-8306-1-git-send-email-mika.westerberg@linux.intel.com>

The acpiphp driver checks SLOT_ENABLED flag only in aciphp_enable_slot() to
prevent re-enumeration of the already enabled slot.  Because of that it is
not possible to add new devices behind the slot later on (like it is the
case with Thunderbolt devices).

Now, there are two places where acpiphp_enable_slot() gets called:
 1) On Bus Check event for a function (in case of a dock).
 2) When userpace enables a slot by writing '1' to
    /sys/bus/pci/slots/*/power.

In the first case it doesn't make sense to do the check because we are
ought to re-enumerate the bus anyway and see if there are any new devices
added farther in the hierarchy, according the the ACPI specification.

The second case where userspace explicitly enables the device also doesn't
need this check as we already check if the slot is powered on or off in
power_on_slot() and don't do it twice.

So get rid of the SLOT_ENABLED flag and always re-enumerate devices behind
a slot when acpiphp_enable_slot() is called. In addition doing this allows
userspace to simulate Bus Check event by writing '1' to the 'power' file
under the slot.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pci/hotplug/acpiphp.h      |  1 -
 drivers/pci/hotplug/acpiphp_glue.c | 18 +-----------------
 2 files changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 6fdd49c..ecc61b7 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -154,7 +154,6 @@ struct acpiphp_attention_info
 /* slot flags */
 
 #define SLOT_POWEREDON		(0x00000001)
-#define SLOT_ENABLED		(0x00000002)
 #define SLOT_MULTIFUNCTION	(0x00000004)
 
 /* function flags */
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index c9ec06e..506f38f 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -304,7 +304,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
 
 	if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
 				       &val, 60*1000))
-		slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
+		slot->flags |= SLOT_POWEREDON;
 
 	if (is_dock_device(handle)) {
 		/* we don't want to call this device's _EJ0
@@ -725,18 +725,6 @@ static int __ref enable_device(struct acpiphp_slot *slot)
 
 	pci_bus_add_devices(bus);
 
-	slot->flags |= SLOT_ENABLED;
-	list_for_each_entry(func, &slot->funcs, sibling) {
-		dev = pci_get_slot(bus, PCI_DEVFN(slot->device,
-						  func->function));
-		if (!dev) {
-			/* Do not set SLOT_ENABLED flag if some funcs
-			   are not added. */
-			slot->flags &= (~SLOT_ENABLED);
-			continue;
-		}
-	}
-
 	return 0;
 }
 
@@ -782,8 +770,6 @@ static int disable_device(struct acpiphp_slot *slot)
 		acpiphp_bus_trim(func->handle);
 	}
 
-	slot->flags &= (~SLOT_ENABLED);
-
 	return 0;
 }
 
@@ -1229,8 +1215,6 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
 		goto err_exit;
 
 	if (get_slot_status(slot) == ACPI_STA_ALL) {
-		if (slot->flags & SLOT_ENABLED)
-			goto err_exit;
 		/* configure all functions */
 		retval = enable_device(slot);
 		if (retval)
-- 
1.8.3.2

  parent reply	other threads:[~2013-07-03 14:04 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03 14:04 [PATCH v2 0/8] Thunderbolt workarounds Mika Westerberg
2013-07-03 14:04 ` [PATCH v2 1/8] x86/PCI: prevent re-allocation of already existing bridge and ROM resources Mika Westerberg
2013-07-23  0:08   ` Bjorn Helgaas
2013-07-23  1:18     ` Bjorn Helgaas
2013-07-23  1:33       ` Bjorn Helgaas
2013-07-23  2:01         ` Rafael J. Wysocki
2013-07-23  1:50       ` Rafael J. Wysocki
2013-07-03 14:04 ` [PATCH v2 2/8] PCI: acpiphp: do not check for SLOT_ENABLED in enable_device() Mika Westerberg
2013-07-03 14:04 ` [PATCH v2 3/8] PCI: acpiphp: enable_device(): rescan even if no new devices on slot Mika Westerberg
2013-07-11  0:25   ` Rafael J. Wysocki
2013-07-11  5:11     ` Mika Westerberg
2013-07-11 22:48       ` Rafael J. Wysocki
2013-07-03 14:04 ` [PATCH v2 4/8] PCI: acpiphp: check for new devices on enabled host Mika Westerberg
2013-07-03 14:04 ` Mika Westerberg [this message]
2013-07-03 14:04 ` [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5 Mika Westerberg
2013-07-03 21:40   ` Rafael J. Wysocki
2013-07-04  8:58     ` Mika Westerberg
2013-07-04 12:36       ` Rafael J. Wysocki
2013-07-04 12:53         ` Mika Westerberg
2013-07-04 13:14           ` Rafael J. Wysocki
2013-07-04 13:33             ` Mika Westerberg
2013-07-04 13:53               ` Rafael J. Wysocki
2013-07-04 14:29                 ` [PATCH v2.1 " Mika Westerberg
2013-07-04 23:48                   ` Rafael J. Wysocki
2013-07-05  5:47                     ` Mika Westerberg
2013-07-19  3:57     ` [PATCH v2 " Robert Hancock
2013-07-19 12:18       ` Rafael J. Wysocki
2013-07-03 21:45   ` Bjorn Helgaas
2013-07-03 21:58     ` Rafael J. Wysocki
2013-07-03 14:04 ` [PATCH v2 7/8] PCI: acpiphp: get rid of unused constants in acpiphp.h Mika Westerberg
2013-07-03 14:04 ` [PATCH v2 8/8] PCI: acpiphp: sanitize acpiphp_get_[latch|adapter]_status() Mika Westerberg
2013-07-03 18:29 ` [PATCH v2 0/8] Thunderbolt workarounds Matthew Garrett
2013-07-03 18:33   ` Greg Kroah-Hartman
2013-07-03 18:44     ` Matthew Garrett
2013-07-03 19:57       ` Ronciak, John
2013-07-03 20:35         ` Matthew Garrett
2013-07-03 20:46           ` Ronciak, John
2013-07-03 21:21             ` Matthew Garrett
2013-07-03 18:41   ` Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372860295-8306-6-git-send-email-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=bruce.w.allan@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=john.ronciak@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=miles.j.penner@intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).