Received: by 10.192.165.148 with SMTP id m20csp371750imm; Fri, 20 Apr 2018 08:06:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx48tn+SwoX8g3SpgpydTkFZNCMDXWv31HLG6gTlJwNHa1H1y0/6G8O25v0ipEN28DXmUV3p2 X-Received: by 10.99.112.88 with SMTP id a24mr9124345pgn.101.1524236769154; Fri, 20 Apr 2018 08:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524236769; cv=none; d=google.com; s=arc-20160816; b=MPEH7+6CcWXbKsTCsrOguYW+l6FFS7vbewQHTHX9eN/dXN8On+MD8DlXYMXKxBs9AQ Xc1WTqehGjk9X0HpiBPB22ND/wSmNstutZiLtb2hY6xczlZgtGgq9j0YKVnLjhfYlYhZ /9TYzVt3HZA47AF3JfB1riA6ily74D2hnZeNGaH61V9HfEVzZs4qM+cFlKY6DZQhdH6O m9hUBDjl2TABgRPcn46Jq8Gh03fDZI09WVrOPlzUtLYqMV2fWfAPxduiwA/lzVCPU80z J054bInKuWQyk9sCgghcXDfMHOstTowbp26BVgkuX02RlL/uPQ7icXDYgjr7Y6GAOIeO MCoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=h2iI65nXBTz5QmT7d7oqr9H2a5soiI1UYOtw9FuHfdU=; b=Qwmzq3f7WzRoj71Z0Nu55n0NjJjcGD3m5mhwiA3LF0ONNU4WyaBhZguTefnv1cjK+s 8POPcX0pRGxp3LyjX2V6dvYL8ro6AaiLIqNZSWGo6Mvy2t2fzGRRY+tAhZrS93GdarIJ FRv4mNlFvqpNXabP3Inz7DikHerQ0blimTltD08Cfq5Z+pVsFSz33MjVoZVrYD9+K/I2 vkucHUmogZA6UoezkM17jpS4k3Gojf4P9oA7fZmcOyttOlfy8kPvdBNkiG6S0hA4yHp1 TeVHHVgtflKlmY9Gy910oa1yWHpXGHYwq3qaLZNWSRgsDWS+uHjoHjnvYN56NWh3tvIk T/BQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si2593045plg.463.2018.04.20.08.05.52; Fri, 20 Apr 2018 08:06:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755317AbeDTPEY (ORCPT + 99 others); Fri, 20 Apr 2018 11:04:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40366 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755224AbeDTPEW (ORCPT ); Fri, 20 Apr 2018 11:04:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A72CA7F6A4; Fri, 20 Apr 2018 15:04:22 +0000 (UTC) Received: from w520.home (ovpn-116-103.phx2.redhat.com [10.3.116.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16E926179D; Fri, 20 Apr 2018 15:04:21 +0000 (UTC) Date: Fri, 20 Apr 2018 09:04:20 -0600 From: Alex Williamson To: Bjorn Helgaas Cc: Sinan Kaya , Jason Gunthorpe , Bjorn Helgaas , linux-pci@vger.kernel.org, sulrich@codeaurora.org, timur@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mike Marciniszyn , Dennis Dalessandro , Doug Ledford , "open list:HFI1 DRIVER" , open list , Alex Deucher , Rajat Jain Subject: Re: [PATCH 1/2] IB/hfi1: Try slot reset before secondary bus reset Message-ID: <20180420090420.03fb1e6c@w520.home> In-Reply-To: <20180420140049.GP28657@bhelgaas-glaptop.roam.corp.google.com> References: <1524167784-5911-1-git-send-email-okaya@codeaurora.org> <20180419202632.GE14063@ziepe.ca> <20180419214722.GO28657@bhelgaas-glaptop.roam.corp.google.com> <290e9530-dcde-9c10-7ae0-59ac4c509db4@codeaurora.org> <20180420140049.GP28657@bhelgaas-glaptop.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 20 Apr 2018 15:04:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Apr 2018 09:00:49 -0500 Bjorn Helgaas wrote: > [+cc Rajat, Alex because of their interest in the reset/hotplug issue] > > For context, Sinan's patch is this: > > > diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c > > index 83d66e8..75f49e3 100644 > > --- a/drivers/infiniband/hw/hfi1/pcie.c > > +++ b/drivers/infiniband/hw/hfi1/pcie.c > > @@ -908,7 +908,8 @@ static int trigger_sbr(struct hfi1_devdata *dd) > > * delay after a reset is required. Per spec requirements, > > * the link is either working or not after that point. > > */ > > - pci_reset_bridge_secondary_bus(dev->bus->self); > > + if (pci_reset_slot(dev->slot)) > > + pci_reset_bridge_secondary_bus(dev->bus->self); > > On Thu, Apr 19, 2018 at 06:19:32PM -0400, Sinan Kaya wrote: > > On 4/19/2018 5:47 PM, Bjorn Helgaas wrote: > > >> Bjorn, would be appropriate to export pci_parent_bus_reset() or some > > >> variation therin?? > > > I agree it would be really nice if the PCI core could help out somehow > > > so we could get some of this code out of individual drivers. > > What I was really thinking here was about the whole Gen3 transition > thing, not the reset thing by itself. > > > I can create a function called pci_reset_link() and move both slot and > > secondary bus reset inside. > > What exactly is your patch fixing? Is it the following? > > If the HFI link is not operating at 8GT/s, the driver's .probe() > method tries to transition it to 8GT/s, which involves resetting the > HFI device with pci_reset_bridge_secondary_bus(). If the HFI device > is in a hotplug slot, the reset causes a "Link Down" event, which > causes the pciehp driver to remove the HFI device and re-enumerate > it when the link comes back up. > > When pciehp removes the device, it calls the HFI .remove() method, > which is a problem because the .probe() method is still active. > > It looks like this should deadlock because __device_attach() holds > the device_lock while calling .probe() and the > device_release_driver() path tries to acquire it. > > Your patch uses pci_reset_slot(), which connects with Rajat's work > (06a8d89af551 ("PCI: pciehp: Disable link notification across slot > reset")) to avoid hotplug events for intentional resets. > > So I think I just reverse-engineered the whole rationale for your > patch :) Sorry about the long detour. > > I'm having a hard time articulating my thoughts here. I think my > concern is that knowledge about this reset/link down/hotplug issue is > leaking out and we'll end up with different reset interfaces that may > or may not result in hotplug events. This seems like a confusing API > because it's hard to explain which interface a driver should use. Is there a concern here about whether the endpoint device driver or the PCI core really knows better about link retraining? This makes me remember my unfinished (and need to revisit) Pericom quirk[1] where errata in the PCIe switch requires that upstream and downstream links are balanced (ie. same link rate) or else enabling ACS results in packets not properly flowing through the switch. If an endpoint driver starts deciding to retrain links, overriding quirks in the PCI core, then such topology manipulation isn't possible. Why does the driver .probe() function think it can retrain at a higher link rate than PCI core? Thanks, Alex [1]https://lists.linuxfoundation.org/pipermail/iommu/2016-October/018890.html