Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4236730pxk; Tue, 29 Sep 2020 19:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcHWpFwxM2gLCjbxcB8FMB4PxuzZhGaJDKPlxfsQEbt1C0CsUxRvnvBgxrkGcVzVBPj2VC X-Received: by 2002:a05:6402:1697:: with SMTP id a23mr400949edv.195.1601432703546; Tue, 29 Sep 2020 19:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601432703; cv=none; d=google.com; s=arc-20160816; b=LuTSuuISBsP2aGKKjkztqEO7nXO2exqO+6E10rdKfGhHSeFl+iQ/7BPgvSlKlo5dMl QytIJu6WHV7IhTVVSGSws/4RiQpMh+B3CqfRMqsR7weclH0o/Y1Gsurr14dJ+VXV4Oll fRNsBZZOuwT3S+fPOn5+x+VBeuz7205ADN85UiBdMv62LCTUruT64T/3wpuGwcXUtA6B eb9fcvSEth8MMcy0tkcqD716YXnjlEr8I/NXfaq6ElOBNp96JJORMyMBEbXyRCclqQzo erd+Q1C1wkUkH855nNC+x8ePLMPA/VGBze4yYDXdjuJ/EOR6Va/wt+jQY3Zir9LXMI7E k+8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=VviVj9bYE7aXVNpstffQ7ePdMsng1BehF9I+7/XekM8=; b=Hn9sXEysezB0h+YCromdr24Kke9QEU0C9xgTu3JZOXF+3hu9N8cV0a5ELsTBWR+s7a q+SxHpG8gUCZeISjZDj540SqmgvHZdqnfonZQjirZT2IvfOwA2HFXnDT1WA60ukNxVm4 GgC7ZUq8NTexYEbGS/9TnilsplJQ7Ve0zeUGYkVgBb7DShY7/n46B3YLVPBirh1DmcGV KJRJrR7PS+sRLKHDu6ATzvh15d+3nOyfRmSZgtLJKS5j8h9uPoghOqz9tBQgXAxvO7NF 8ZjZc8alwzX/+T5hYhty+3M7Gm01hK50dyubGWwXlZFXE1aMamu+Co5zdZOZusWRAtWJ D7TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LQjmSSLz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si98762eds.240.2020.09.29.19.24.41; Tue, 29 Sep 2020 19:25:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LQjmSSLz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729673AbgI3CVD (ORCPT + 99 others); Tue, 29 Sep 2020 22:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbgI3CVD (ORCPT ); Tue, 29 Sep 2020 22:21:03 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C390EC061755; Tue, 29 Sep 2020 19:21:02 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id nw23so530769ejb.4; Tue, 29 Sep 2020 19:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VviVj9bYE7aXVNpstffQ7ePdMsng1BehF9I+7/XekM8=; b=LQjmSSLzZ9xYDHO61ieHODLq/x3LIKoty3Zho6MH+qyAsGtCXqf1zsbpyYdcNjOnlg jDJwEezl9CWPcn4aXXwJdR/S7lVyj6Zr1RP2+KOGNdvW/KXEfM4B3+uO+RCXRzCOLJee 9s3hQcE7/Pk6DbfwhWhgtgKP8il+cYIcTFaZcFgp7xSw3L2N0ToUtFPX+ybtQO00RDdN vcs4N11g2A+uEZvNOzyoI3cO7v+bMoKAKRJp8ejjarx45ev2xpZNzi8c/Kp5tobzJSdV 9gqfjyjoOKuBG0tNH03aWWXGNnrL8z3eehgI/+dZFwUgdPJliWMrjAe1Qb5BqM7ZrIIV qr1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VviVj9bYE7aXVNpstffQ7ePdMsng1BehF9I+7/XekM8=; b=awLFjnx4XtxBt/HtNZ/zqubD855sZ+T177tlzFYCfQs63OgxlY/3QsYpYtTyT6U74L 15vQ633oc1QkueuSSkeqMaN9Fd1gvX6kQsZp8gQSHJIMJb6LDJpv93zBV3Gf1HVTBdqh KtVKgaucR3Lpaxv5v01Cp5OaTIuTtwLIvRu2ey5M6GL7tMbufge/5SKXKQL9GxaqVTqf 4sujg9jVqtoX/Ly9y+GmtLoLrLBN0GEb8chfkXdGEZ/Vug9xG3t8ga9kWgT0ywMC6Nns UA8uYE2Q2aw29xG56TPJ6Cx/mmjnY+0oPe+EFQ27u9NXOubBTj3oznAzFZUurjLTfWCb 9n7A== X-Gm-Message-State: AOAM532f74t3v4BL5pxgyCxbo9n/3vPm3RokHkxD1jiHNGTFtshzuhKj T8TyFsKz1gCPle7LDMgPQ+cjdHk3UXTB0SrgZs0= X-Received: by 2002:a17:906:6409:: with SMTP id d9mr580121ejm.344.1601432461534; Tue, 29 Sep 2020 19:21:01 -0700 (PDT) MIME-Version: 1.0 References: <20200927032829.11321-1-haifeng.zhao@intel.com> <20200927032829.11321-3-haifeng.zhao@intel.com> <20200929081800.GA15858@wunner.de> <20200929100759.GA21885@wunner.de> In-Reply-To: <20200929100759.GA21885@wunner.de> From: Ethan Zhao Date: Wed, 30 Sep 2020 10:20:50 +0800 Message-ID: Subject: Re: [PATCH 2/5 V2] PCI: pciehp: check and wait port status out of DPC before handling DLLSC and PDC To: Lukas Wunner Cc: Sinan Kaya , Ethan Zhao , Bjorn Helgaas , Oliver , ruscur@russell.cc, Andy Shevchenko , Stuart Hayes , Alexandru Gagniuc , Mika Westerberg , Keith Busch , linux-pci , Linux Kernel Mailing List , "Jia, Pei P" , ashok.raj@linux.intel.com, Sathyanarayanan Kuppuswamy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 6:08 PM Lukas Wunner wrote: > > On Tue, Sep 29, 2020 at 05:46:41PM +0800, Ethan Zhao wrote: > > On Tue, Sep 29, 2020 at 4:29 PM Lukas Wunner wrote: > > > On Sun, Sep 27, 2020 at 11:27:46AM -0400, Sinan Kaya wrote: > > > > On 9/26/2020 11:28 PM, Ethan Zhao wrote: > > > > > --- a/drivers/pci/hotplug/pciehp_hpc.c > > > > > +++ b/drivers/pci/hotplug/pciehp_hpc.c > > > > > @@ -710,8 +710,10 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) > > > > > down_read(&ctrl->reset_lock); > > > > > if (events & DISABLE_SLOT) > > > > > pciehp_handle_disable_request(ctrl); > > > > > - else if (events & (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC)) > > > > > + else if (events & (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC)) { > > > > > + pci_wait_port_outdpc(pdev); > > > > > pciehp_handle_presence_or_link_change(ctrl, events); > > > > > + } > > > > > up_read(&ctrl->reset_lock); > > > > > > > > This looks like a hack TBH. > [...] > > > > Why is device lock not protecting this situation? > > > > Is there a lock missing in hotplug driver? > > > > > > According to Ethan's commit message, there are two issues here: > > > One, that pciehp may remove a device even though DPC recovered the error, > > > and two, that a null pointer deref occurs. > > > > > > The latter is most certainly not a locking issue but failure of DPC > > > to hold a reference on the pci_dev. > > > > This is what patch 3/5 proposed to fix. > > Please reorder the series to fix the null pointer deref first, > i.e. move patch 3 before patch 2. If the null pointer deref is > fixed by patch 3, do not mention it in patch 2. Make sense. Thanks, Ethan > > Thanks, > > Lukas