Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5361297imu; Tue, 13 Nov 2018 05:29:30 -0800 (PST) X-Google-Smtp-Source: AJdET5dCQ+/yssaR+RQKcz52xKAmQ8E/htNt+e7yMvmogWC4r6cW1u0qKkJhOOSGKhXhwp+hq5Vf X-Received: by 2002:a17:902:b181:: with SMTP id s1-v6mr5225901plr.51.1542115770714; Tue, 13 Nov 2018 05:29:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542115770; cv=none; d=google.com; s=arc-20160816; b=Kxkd2M3pA9QJ/KEFNXAOq9jXGhvbPdRRRsp9ZYyr438q6Cadeu7BDPhsaOoXedDC+f d3AaVO7x2illK8HZ7yPC2xk45p5A8mFzFzReZE2Xz14o9amgM6+29sQ7GgBcI0p0Rq3/ lLZdrlFgNeKeDXNd086L3neVKGFA3UZ43itq6n0MVSqeik8hRYsSZi0g89TBvyRyGlGV wasvD5RXuXoCof2cjKsR+2etzkyhN6/b+UMOelGlQW0kvyYLb7V8PoNE/U3y5qXcFMZ8 ncTIB6NtGGdvjAoUnf5QW0+cY4I37ZlcfYoQL+HyIX8dQSG10djel5btWe8eFLe9QfLt dZlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=8c1nC6rbDBhiD20jqK9+c0C4lseWRvdiQkzwpgbTXCI=; b=Us0Gzb2UPaRQDqoGhZHss+JDpVtM40a78JGbmRTq9dq/P1131Ta9i2xztntkl7/KeW /jnGCpd3e+h0kMZbZfiPX2mqxUaILBZMkJt3BVD6Glcl93kbrLKdzpIsUAQaNYtVCKPo ng2WANvbvAFq81BXu5ihZVbVWXQ4dA78CIk6fOGEgeGLiBsa4OEXmLO1BaZrej6G4n2j Zlozg7WRIstu2D981XnHcmkRFirdqDY8m694aaKcI9qHgkorD6OzlWWq+66GPJuMoiDG wnhoG1SRzMPc7MYdjMuwsL5dFrYMQP0mowIY5/pwUuWfBB4mKgm06vEhODAbMqSfUqdX MdUA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97-v6si21670428plb.403.2018.11.13.05.29.14; Tue, 13 Nov 2018 05:29:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387514AbeKMX0V convert rfc822-to-8bit (ORCPT + 99 others); Tue, 13 Nov 2018 18:26:21 -0500 Received: from lhrrgout.huawei.com ([185.176.76.210]:32754 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732728AbeKMX0V (ORCPT ); Tue, 13 Nov 2018 18:26:21 -0500 Received: from LHREML713-CAH.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id A78109683A999; Tue, 13 Nov 2018 13:28:10 +0000 (GMT) Received: from FRAEMA706-CHM.china.huawei.com (10.206.14.55) by LHREML713-CAH.china.huawei.com (10.201.108.36) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 13 Nov 2018 13:28:11 +0000 Received: from FRAEML521-MBX.china.huawei.com ([169.254.1.76]) by FRAEMA706-CHM.china.huawei.com ([169.254.6.151]) with mapi id 14.03.0415.000; Tue, 13 Nov 2018 14:28:04 +0100 From: Shameerali Kolothum Thodi To: "mika.westerberg@linux.intel.com" 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 Thread-Topic: Qemu Guest kernel 4.20-rc1 PCIe hotplug issue Thread-Index: AdR7RP5EYT33x2cVTRiE4AudJSgcHP///SQA///uY1CAABsPAP//6WQQ Date: Tue, 13 Nov 2018 13:28:04 +0000 Message-ID: <5FC3163CFD30C246ABAA99954A238FA8387DF51F@FRAEML521-MBX.china.huawei.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> In-Reply-To: <20181113125910.GB2500@lahna.fi.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.237] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: mika.westerberg@linux.intel.com > [mailto:mika.westerberg@linux.intel.com] > Sent: 13 November 2018 12:59 > 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 > > On Tue, Nov 13, 2018 at 12:36:20PM +0000, Shameerali Kolothum Thodi wrote: > > > @@ -156,9 +156,9 @@ static void pcie_do_write_cmd(struct controller > > > *ctrl, > > > u16 cmd, > > > slot_ctrl |= (cmd & mask); > > > ctrl->cmd_busy = 1; > > > smp_mb(); > > > + ctrl->slot_ctrl = slot_ctrl; > > > > Actually I tried this one, but it doesn't help in this case as the > > initial > > pcie_capability_read_word() returns the slot_ctrl without > > PCI_EXP_SLTCTL_HPIE bit set. It looks to me > > pcie_enable_notification() function enables this, > > > > if (!pciehp_poll_mode) > > cmd |= PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE; > > > > I don't know this is as per the spec or not as the initial cap read > > doesn't seems to have the PCI_EXP_SLTCTL_HPIE bit set. > > If I read the code right cmd value should end up in ctrl->slot_ctrl properly from > pcie_enable_notification(). Right. As I mentioned in my previous mail, I missed the fact that you are updating the ctrl->slot_ctrl with cmd value while in my test I did my update with the value returned by pcie_capability_read_word(). > However, I think we are missing check for PCI_EXP_SLTCTL_CCIE in > pciehp_isr(). Ok. > Here's an updated patch, can you try and see if it makes any difference? I just tried this and it works. Thanks. See few comments below. > diff --git a/drivers/pci/hotplug/pciehp_hpc.c > b/drivers/pci/hotplug/pciehp_hpc.c > index 7dd443aea5a5..da2cbe892444 100644 > --- a/drivers/pci/hotplug/pciehp_hpc.c > +++ b/drivers/pci/hotplug/pciehp_hpc.c > @@ -156,9 +156,9 @@ static void pcie_do_write_cmd(struct controller *ctrl, > u16 cmd, > slot_ctrl |= (cmd & mask); > ctrl->cmd_busy = 1; > smp_mb(); > + ctrl->slot_ctrl = slot_ctrl; Does it make more sense if we can move this before smp_mb()?. Also I am not sure updating the ctrl->slot_ctrl before actually the hardware is programmed with that value will result in any other race conditions? TBH, I am not that familiar with this code and I leave that to you :) Thanks, Shameer > pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl); > ctrl->cmd_started = jiffies; > - ctrl->slot_ctrl = slot_ctrl; > > /* > * Controllers with the Intel CF118 and similar errata advertise @@ - > 522,7 +522,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) > * in the Slot Control register (PCIe r4.0, sec 6.7.3.4). > */ > if (pdev->current_state == PCI_D3cold || > - (!(ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE) && !pciehp_poll_mode)) > + (!(ctrl->slot_ctrl & (PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE)) > +&& !pciehp_poll_mode)) > return IRQ_NONE; > > /*