Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5533987imu; Tue, 13 Nov 2018 08:01:08 -0800 (PST) X-Google-Smtp-Source: AJdET5fKIfMFma2+KwpfcQXn830vnMdW+Vnc9q1cVwL+syXuFwqepVaksdDINaNsz6kT2FxSH6a8 X-Received: by 2002:a62:3406:: with SMTP id b6-v6mr5771549pfa.50.1542124868329; Tue, 13 Nov 2018 08:01:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542124868; cv=none; d=google.com; s=arc-20160816; b=iDLWZlBR8HaI2nV44W6ByjTKbWDyJlnBDU5qXBs3VHj7d7NmYkgW/hgFOgVix7oJkl TN1YOwgGSoj4plxuytiM+FSXL/ua1O0nCi96BaAykug4FoQuixqI3mk1G/kE4cp2evP7 xQpZlV4/2kwLl8wFUU5i9OyTED2Ir96B3pDYpDMfqmUg30WHALtMPCAatp/6yrRAP9Z9 V2rhB9GqFM5UuFCOlxtUIO58TfppKeF+bpu+ZDbK9PLRPVrXT4LO40UM1CpoNBKXEVzf dep01d0IWN4wtFJAXTsQ/GDYIhNk4gULEa/KIOUJOHq5+5HeazYFLHPQQNGUA7C3/UAX CJmw== 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=i7EQBvpZol2z2tZze7M54fK+1trXhrxDVpiKiMuGtwc=; b=ngs98GQvvXwOHshAsHMquVk85xiXzbaZ6UdOdXiwhYDqU0MMZ1+mbiVGQjEoT+D+4h tlhPC99Twtn7vTAcof69GGxuJNXBqGc8M6uHgTO7BLiI3P/vnUVNbBiqk5abaYrCU4nE TLrLAfcDlF7GERkW1LO09ku2YVY7tNWgGe+15CYpI0xgGZH/eahYg+ioIXvNcOZJUjY7 ARp0MpKev0Qrwh/oXSVif7V08IVd0svYYMPvFs+0yxVN1CeALHXdPQTPKwTQtnXMFQcT Q7q/v9B4Kihuy5q05qd9LesrwjyWD+a2FpwAKdL/NrZ825yl4DcGUKt8Ta9tZdzXKEPC GBzQ== 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 l63-v6si21396550plb.385.2018.11.13.08.00.37; Tue, 13 Nov 2018 08:01:08 -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 S2388015AbeKNB4l convert rfc822-to-8bit (ORCPT + 99 others); Tue, 13 Nov 2018 20:56:41 -0500 Received: from lhrrgout.huawei.com ([185.176.76.210]:32757 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731811AbeKNB4l (ORCPT ); Tue, 13 Nov 2018 20:56:41 -0500 Received: from LHREML710-CAH.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 9CB011FFFE0DB; Tue, 13 Nov 2018 15:57:56 +0000 (GMT) Received: from FRAEMA702-CHM.china.huawei.com (10.206.14.51) by LHREML710-CAH.china.huawei.com (10.201.108.33) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 13 Nov 2018 15:57:58 +0000 Received: from FRAEML521-MBX.china.huawei.com ([169.254.1.76]) by FRAEMA702-CHM.china.huawei.com ([169.254.2.148]) with mapi id 14.03.0415.000; Tue, 13 Nov 2018 16:57:48 +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//6WQQgAA6joD//+e+AA== Date: Tue, 13 Nov 2018 15:57:47 +0000 Message-ID: <5FC3163CFD30C246ABAA99954A238FA8387DF7B5@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> <5FC3163CFD30C246ABAA99954A238FA8387DF51F@FRAEML521-MBX.china.huawei.com> <20181113150749.GC2500@lahna.fi.intel.com> In-Reply-To: <20181113150749.GC2500@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 15:08 > 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 [...] > > 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(). > > OK, I see. > > > > 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. > > Can you still check that the previous one (without _CCIE check) works? Yes, it works for me without _CCIE. > > 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 :) > > Both are good questions :) > > For the moving ctrl->slot_ctrl before pcie_capability_write_word(), I > think we should be fine and this is actually more correct because if we > are unmasking interrupts they may trigger immediately making > pciehp_isr() find wrong values in ctrl->slot_ctrl (as can be seen in the > issue you reported). Ok. I was more concerned about an unsolicited event triggering the _isr while we are modifying the ctrl->slot_ctrl. But that's ok I think as the _isr reads the hw status anyway. > 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. Thanks, Shameer