Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752028Ab3FZJhO (ORCPT ); Wed, 26 Jun 2013 05:37:14 -0400 Received: from mga01.intel.com ([192.55.52.88]:22316 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751678Ab3FZJhM (ORCPT ); Wed, 26 Jun 2013 05:37:12 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,943,1363158000"; d="scan'208";a="360712136" From: "Kirill A. Shutemov" To: Andy Shevchenko Cc: Mika Westerberg , Greg Kroah-Hartman , Bjorn Helgaas , "Rafael J. Wysocki" , Jesse Barnes , Yinghai Lu , john.ronciak@intel.com, miles.j.penner@intel.com, bruce.w.allan@intel.com, "Kirill A. Shutemov" , Heikki Krogerus , "linux-kernel@vger.kernel.org" , linux-pci@vger.kernel.org, x86@kernel.org In-Reply-To: References: <1372177330-28013-1-git-send-email-mika.westerberg@linux.intel.com> <1372177330-28013-5-git-send-email-mika.westerberg@linux.intel.com> Subject: Re: [PATCH 4/6] PCI: acpiphp: check for new devices on enabled host Content-Transfer-Encoding: 7bit Message-Id: <20130626093930.DB6B6E0090@blue.fi.intel.com> Date: Wed, 26 Jun 2013 12:39:30 +0300 (EEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2182 Lines: 59 Andy Shevchenko wrote: > On Tue, Jun 25, 2013 at 7:22 PM, Mika Westerberg > wrote: > > > Current acpiphp_check_bridge() implementation is pretty dumb: > > - it enables the slot if it's not enabled and the slot status is > > ACPI_STA_ALL; > > - it disables the slot if it's enabled and slot is not in ACPI_STA_ALL > > state. > > > > This behavior is not enough to handle Thunderbolt chaining case > > properly. We need to actually rescan for new devices even if a device > > has already in the slot. > > > > The new implementation disables and stops the slot if it's not in > > ACPI_STA_ALL state. > > > > For ACPI_STA_ALL state we first trim devices which don't respond and > > look for the ones after that. We do that even if slot already enabled > > (SLOT_ENABLED). > > Just a couple of nitpicks below. > > > list_for_each_entry(slot, &bridge->slots, node) { > > + struct pci_bus *bus = slot->bridge->pci_bus; > > + struct pci_dev *dev, *tmp; > > + int retval; > > + > > + mutex_lock(&slot->crit_sect); > > Does it make sense to introduce a helper let's say > __acpiphp_check_slot() and put there all lines inside this mutex? No. Why? > > + if (get_slot_status(slot) == ACPI_STA_ALL) { > > + /* remove stale devices if any */ > > + list_for_each_entry_safe(dev, tmp, > > + &bus->devices, bus_list) { > > + if (PCI_SLOT(dev->devfn) != slot->device) > > + continue; > > + pci_trim_stale_devices(dev); > > Perhaps > > list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) { > if (PCI_SLOT(dev->devfn) == slot->device) > pci_trim_stale_devices(dev); > } Makes sense, thanks. -- Kirill A. Shutemov -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/