Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6682312imu; Wed, 14 Nov 2018 05:30:59 -0800 (PST) X-Google-Smtp-Source: AJdET5d5lujoUhLPCulV+a6ld3ZqVuFoie9i+1ubWjo5i42KrzEDxBP5+t+GkKELHlu0xf2eZzX+ X-Received: by 2002:a17:902:110a:: with SMTP id d10-v6mr1953564pla.85.1542202259027; Wed, 14 Nov 2018 05:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542202258; cv=none; d=google.com; s=arc-20160816; b=Kg+JYbEZFj/b8tKgc7KkMildSe57L2CipuG9f4hodbiie9f60RDvD3aUIcY1KcX/6j Yl4jir4eW4Q1dHKK8/cAtFhF7hBCt+ETcV20vT330TJzj9GnLdLGT01WQdV3mqIETUJ8 VjsytxNKCiSjDfTCfd71MRsOenUyOMwSlXSUS85f5Nwwx+v58QX9iId7MkEf6MhoSq6l mttAzgRkZpHDaZCgXRu2HKb/HLtLjY8cnLd2spa8jBCgXUEevVt1+cBDUcIt86U0Dmfz Hlk3AqqGGaqutIcv7sqCSUjn6H3NnNgO4BwkfodmnHv6hlJUoEy3bIfnOjOB55l1Fm8H rEbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Osz5jMSSxYmPgUFssOkP5RlZvzprhLVZ7L83a7+MDfE=; b=RPntBBjw5WngUogpdXrtWo+4LHmvFe0E+4r/UyEC4iqIj8zcpEnpo6MDv8r8bcW4OM E8A7AivDrJLD129A8S1WNQWexrEEo0Vhw1GLMkG0CLEr5DHrsSzLkjAE9gDNzNZC99i5 Tt5C6ItnBzzwGik9718Mc+T8InY7tPe1S7FAMYiKngCNkfGw91nseADOLt5tAS/nfrkb xQwRmo1gwKZgGfAzpNj7g80fw3JnTpBjSuZ/VgotVotlXxL8z++W9jbLvcpatCJLu4Fg agdrfpEAObIKO3iaxtN7l4un4bLdCcnBRcj12vi+4x6w8H0RffqYxZ5KRR1HfbN27hMF f1CQ== 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 i13si4612974pgi.260.2018.11.14.05.30.43; Wed, 14 Nov 2018 05:30:58 -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 S1732655AbeKNXdd (ORCPT + 99 others); Wed, 14 Nov 2018 18:33:33 -0500 Received: from bmailout2.hostsharing.net ([83.223.90.240]:33159 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbeKNXdd (ORCPT ); Wed, 14 Nov 2018 18:33:33 -0500 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id DE2FA2800B483; Wed, 14 Nov 2018 14:30:14 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 859F015429D; Wed, 14 Nov 2018 14:30:14 +0100 (CET) Date: Wed, 14 Nov 2018 14:30:14 +0100 From: Lukas Wunner To: "mika.westerberg@linux.intel.com" Cc: Shameerali Kolothum Thodi , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Wangzhou (B)" , Linuxarm Subject: Re: Qemu Guest kernel 4.20-rc1 PCIe hotplug issue Message-ID: <20181114133014.ge7cy2r2vrrtt6xx@wunner.de> 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> <20181114095225.GN2500@lahna.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181114095225.GN2500@lahna.fi.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 14, 2018 at 11:52:25AM +0200, mika.westerberg@linux.intel.com wrote: > 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). In pcie_do_write_cmd(), please just move the ctrl->slot_ctrl = slot_ctrl; above the call to pcie_capability_write_word(). AFAICS an explicit memory barrier isn't needed here because of the call to pcie_capability_write_word(), which "will [ordinarily] be guaranteed to be fully ordered and uncombined" (Documentation/memory-barriers.txt, section "KERNEL I/O BARRIER EFFECTS"). The memory barrier in pciehp_isr() is also bogus because the following wake_up() implies a memory barrier if a task was woken. (And if none was woken, who cares.) > 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() :-) That is an approach I'd strongly object to: While pciehp itself only signals very few interrupts (making an additional mmio read appear to be negligible), it may share its interrupt with other devices. On my MacBookPro9,1, a hotplug port of the Thunderbolt controller shares its interrupt line with the Wifi card and SD card reader, and those may signal a huge number of interrupts. On such a machine an additional mmio read per interrupt becomes a problem. Thanks, Lukas