Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6469358imu; Wed, 14 Nov 2018 01:53:05 -0800 (PST) X-Google-Smtp-Source: AJdET5f8z5HQpuGnoXUSGxzHDjiG4z9OpuEisN33Fcl95/NEaRLADKphJikPvsvzLRAxft5Crot7 X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr1274822pfa.82.1542189185637; Wed, 14 Nov 2018 01:53:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542189185; cv=none; d=google.com; s=arc-20160816; b=yhW6s5mkW1OUWicZb1w5+rq9lzhDJ2Qza2B/GKjMLceUoPGzO9kkbiF3uk9qsh80qf hEg9/McHWOlZ5vZfESPO+UeIOP5BBPOaZt83BAEpJItNN520QXPsykU5y32t8gKtUTW1 nSN1ZKLTt2sxsLNI0VMfEgQTVRZH2hJQJlBaTAlnQ463mkM7ObIN4Ao5I7rqpj8Z4Z9B UKc6+Qobs/qryOU7bBWh7q9pgj1PUmTT4j002JA84N44kl2B120SQyW47TWJud3vu5LR rfY1850NLRBCLLvkiIMCLlSADPGWncyn3F1Oj93/37wZyij8jm/4n19oqxdVHjYAxhcG uCfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZNz5YgYTPnII28rFeGMfjGk7DOL3qdF6IxklGZ86AF8=; b=jL7EVcCs+mQNwYNNykQwLQaQw5mICcLG8KoKNuNeG3cdiOG83D4e60dts7A2EdyTys X3sqdWdhUMDDuuyLFmaGhEsATVdIHmCSqpBjEyJ9pN149ckZ2gNwTvk2xL0hfa8RI4wY gWloTJeRx39ck/DOSi70ou5JAewHCYTG8BQ+FkYhB0VEHnJNnWSd+bmzrsV/JWe1d4wF KAEJpo+Ae+pywbjyg7ilAIMs5SHt4wmxKoSdWgD1bgwbDegi5s+XtPx+jC1YVTlx5eXF QFIfFTIqemtLoLpqaAcUN3qFAx5QsJkRJYTaWYS5SuYXnsM1riJUPt/yjfPEW/pwdaxo Eyug== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b25-v6si7074916pfo.240.2018.11.14.01.52.49; Wed, 14 Nov 2018 01:53:05 -0800 (PST) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731899AbeKNTzA (ORCPT + 99 others); Wed, 14 Nov 2018 14:55:00 -0500 Received: from mga06.intel.com ([134.134.136.31]:23477 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727558AbeKNTzA (ORCPT ); Wed, 14 Nov 2018 14:55:00 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2018 01:52:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,232,1539673200"; d="scan'208";a="91012542" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by orsmga006.jf.intel.com with SMTP; 14 Nov 2018 01:52:26 -0800 Received: by lahna (sSMTP sendmail emulation); Wed, 14 Nov 2018 11:52:25 +0200 Date: Wed, 14 Nov 2018 11:52:25 +0200 From: "mika.westerberg@linux.intel.com" To: Shameerali Kolothum Thodi Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Wangzhou (B)" , Linuxarm , Lukas Wunner Subject: Re: Qemu Guest kernel 4.20-rc1 PCIe hotplug issue Message-ID: <20181114095225.GN2500@lahna.fi.intel.com> References: <5FC3163CFD30C246ABAA99954A238FA8387DD344@FRAEML521-MBX.china.huawei.com> <20181113122522.GA2500@lahna.fi.intel.com> <5FC3163CFD30C246ABAA99954A238FA8387DF43F@FRAEML521-MBX.china.huawei.com> <20181113125910.GB2500@lahna.fi.intel.com> <5FC3163CFD30C246ABAA99954A238FA8387DF51F@FRAEML521-MBX.china.huawei.com> <20181113150749.GC2500@lahna.fi.intel.com> <5FC3163CFD30C246ABAA99954A238FA8387DF7B5@FRAEML521-MBX.china.huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5FC3163CFD30C246ABAA99954A238FA8387DF7B5@FRAEML521-MBX.china.huawei.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 13, 2018 at 03:57:47PM +0000, Shameerali Kolothum Thodi wrote: > > The smb_mb() thing is not that clear (at least to me) because it is used > > in two places in the driver and both seem to be making write to > > ctrl->cmd_busy visible to other CPUs but I don't see where we deal with > > the read part. > > > > I may be missing something, though. > > I think the read part is in wait_event_timeout() which evaluates the condition. > The wake_up is called from the pciehp_isr(). Since the flag is being updated > in both process level and interrupt handler context, smp_mb() is used. I think > the same now applies to ctrl->slot_ctrl now as this being used in process > context and interrupt context as well. Right, but that would require to use another read/general barrier in the pciehp_isr() before we read the variable in case interrupt happens immediately on another CPU (at least that's my understanding). Since I'm not too comfortable with all these barriers to be honest I would prefer reading the slot control register directly in pciehp_isr() :-) I wonder if the below works in your case? I think it is still easier to understand than adding another barrier there. diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 7dd443aea5a5..575da1005836 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -518,11 +518,9 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) u16 status, events; /* - * Interrupts only occur in D3hot or shallower and only if enabled - * in the Slot Control register (PCIe r4.0, sec 6.7.3.4). + * Interrupts only occur in D3hot or shallower (PCIe r4.0, sec 6.7.3.4). */ - if (pdev->current_state == PCI_D3cold || - (!(ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE) && !pciehp_poll_mode)) + if (pdev->current_state == PCI_D3cold) return IRQ_NONE; /* @@ -548,6 +546,22 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) return IRQ_NONE; } + if (!pciehp_poll_mode) { + u16 ctrl; + + /* + * Check that the hotplug interrupt was enabled. It may + * be that the interrupt was meant for PME instead as + * they share the MSI vector. + */ + pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &ctrl); + if (ctrl == (u16) ~0 || !(ctrl & PCI_EXP_SLTCTL_HPIE)) { + if (parent) + pm_runtime_put(parent); + return IRQ_NONE; + } + } + /* * Slot Status contains plain status bits as well as event * notification bits; right now we only want the event bits.