Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5197393ybh; Wed, 7 Aug 2019 02:19:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHXhanWEIcdTVgRM5YZ/SvzNNrWEzs3hx3Vog91f5l9KZxxKGVvXfzH0LjDvXF09uvRsVw X-Received: by 2002:a65:6495:: with SMTP id e21mr6893944pgv.359.1565169568751; Wed, 07 Aug 2019 02:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565169568; cv=none; d=google.com; s=arc-20160816; b=vxCVIIDaRFyLh/aZg0VEXGtChqxvkUVFXuBMY4XNweVSBXgaZEUPbz7zSFv+tNUzmF 8J6aOIJvXplmh62IO+PiLGJLYWBgGXLlbJtthIrqSxUALstJqJFK2wpGS30KVtG4Lvpm OcCDOIC3eeHqStyt1+JPLZFJHoL724O8/FF9xWW/NW82yxovkPKIJ1HKRc218ESCSwI1 UhlJ38xRF7OTsqTcA3r8f5Busr1THOEojwWeF7jmETmMaQudFzKFQzGccBOoAe1CAbJJ FKa9syDVaZcvKydSEGQa0UzScvMWOHEs7C8CCh0PtejNNIgQWJexihsKHZ6ca2XvxmWL uDfw== 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=FaS+K6SehAYD9lxfxQzEGK8AWIBYSFMBk4kQOLvvFLw=; b=MrUmZTqmYpp/BJty7nj5JKd24bEJfbhmfFyUCjF04Y7Hw46uvxEtlbdmYjUFs8PbAY KOivDBCIKPNyWXTtktPYsVYJZB5mOmMJvx8oC7BL3zbgdxsdZ1awOu8VlAG3BOesg+0T 4IBu6xAoUOVZ/4b5JIAa+fV+jEFobyb3jqIDMZPiYRn1Ye1GZYaj1NifK0pPTHSQr+K2 3Ey5m+prIF6J4OBDoCOnLLFkfiw2BWBYTcZw3tLtofWmPsKi5Sac9xHKyGYq/6c17tHj GJU+TMYxbI2UOvG16o5RtDf7z2Cbkwr1wDryKtiS5aOsYT0RaNUlnUW8UbPYaZyrs7tP HxOQ== 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 d21si16757616pjw.18.2019.08.07.02.19.06; Wed, 07 Aug 2019 02:19:28 -0700 (PDT) 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 S1728365AbfHGJPQ (ORCPT + 99 others); Wed, 7 Aug 2019 05:15:16 -0400 Received: from bmailout3.hostsharing.net ([176.9.242.62]:36151 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbfHGJPQ (ORCPT ); Wed, 7 Aug 2019 05:15:16 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (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 bmailout3.hostsharing.net (Postfix) with ESMTPS id 22194100AFD86; Wed, 7 Aug 2019 11:15:14 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id DC3054BEEC; Wed, 7 Aug 2019 11:15:13 +0200 (CEST) Date: Wed, 7 Aug 2019 11:15:13 +0200 From: Lukas Wunner To: Xiongfeng Wang Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, yaohongbo@huawei.com, guohanjun@huawei.com, huawei.libin@huawei.com Subject: Re: [RFC PATCH] pciehp: use completion to wait irq_thread 'pciehp_ist' Message-ID: <20190807091513.m2aqfbk32y6qb343@wunner.de> References: <1562226638-54134-1-git-send-email-wangxiongfeng2@huawei.com> <20190806072428.2v7k775tvvgkbloh@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, Aug 07, 2019 at 04:28:32PM +0800, Xiongfeng Wang wrote: > On 2019/8/6 15:24, Lukas Wunner wrote: > > I'd suggest something like the below instead, could you give it a whirl > > and see if it reliably fixes the issue for you? > > I tested the below patch. It can fix the issue. Thank you! I'll submit it as a proper patch then. > I am not sure whether the following sequence will be a problem. > * pciehp_ist() is running, and 'ctrl->pending_events' is cleared > * a request to disable the slot is submitted via sysfs. > 'ctrl->pending_events' is set and the irq_thread 'pciehp_ist' is waken up. > But pciehp_ist() is running. So it doesn't take effect. > 'ctrl->pending_events' is not cleared until next time pciehp_ist() is > waken up. So pciehp_sysfs_enable_slot() will wait until next > pciehp_ist() is waken up. I am not sure how 'irq_wake_thread()' will > effect the running irq_thread. That's not a problem. If irq_wake_thread() is called while pciehp_ist() is running, the latter will automatically perform another iteration. It's the same situation if an interrupt is received while pciehp_ist() is running. irq_wake_thread() sets the IRQTF_RUNTHREAD flag and irq_wait_for_interrupt() checks that flag and causes irq_thread() to perform another invocation of handler_fn(), which is pciehp_ist() in this case. So pciehp basically treats a user request like an interrupt received from the hardware. It's meant to simplify the pciehp code. But it's non-trivial to understand because one needs to have an understanding of the genirq code to appreciate the simplicity. Let me know if this explanation wasn't clear enough and you have further questions. > How about making the process synchronous instead of waking up the > irq_thread? That's what we had before, but it has its own problems since it requires locking and interaction between the IRQ thread and the sysfs entry points. Thanks, Lukas