Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2503742pxf; Sat, 27 Mar 2021 13:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjcxHY0P5TB3JvAsjtsd/2otO3/gjuznylLl2s0JEdNL94TbwuMoR/zjCVqvL2qDnEbKYV X-Received: by 2002:a17:906:4d94:: with SMTP id s20mr22234874eju.286.1616877502348; Sat, 27 Mar 2021 13:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616877502; cv=none; d=google.com; s=arc-20160816; b=w8D4Ap4Mw+s3YxpolQHXM2ogRiNaSCxmRbZGq86LV5rllYa3GGEpJ/I9fLl1+Fwf5Q VG8CK2zxblF0twR8dgqZMAty8ip2zeNwTzyFA9q9a+mhQrCY8PS4v1uLAzxuYtUo0icK 9yhBelM78+bfLKK0W+/ugdVNBWxMGoyeNMbLFZR7IOSklnCSUy5i/3YrIhGm+mHg893H LdfYVGQh9jdp4/qwTsiyuDukpgr+R1nVie9To7w/tGW5DwiSMl3eirobFA5OaOZZYr9S 6vIaqEEPyD3iC6GPGhF5r7TUSnFOI2CwrV2bf7eIhu4zPTfcCVkgsdUgl6SJiweomR9K m7Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cy/4OBciSLTMWNr3Z1M8oUuiVreOvsClH0f/YBg5oBY=; b=kX1sicKtZusKN0fBK/KlwU4YjeHEN/4pVzOeSJc2GC0YHA6s6MA2UyjA6cNvAkZYVw Y9qwAPTToYMZ0QaJ/4fOFqO2XMU4sFwdjdGkldIPSEBvNEPrpYdN5K9UqVPjMnSqFIvP dYORaJisk1c3jvnTC6hHN03YXnKOaFghr2MWfjM/V2oa/hmh08jjuQR6hNL+yU6Wz53h up4o6PIzrAy9BwlSn2jKsrX3+t1TNT2FiQCETCm3mpnSuXXUUc6NAl7j2tBtpph/AcDo nSY2s1wMQtEui/Dm7ip5SKnxvnFzLWMFYCqpHQHtb8NX5NBFouZr95QmfYY2n8KLwxaM 8hvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OVgsxOpR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si9784127edy.227.2021.03.27.13.38.00; Sat, 27 Mar 2021 13:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OVgsxOpR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbhC0U3Y (ORCPT + 99 others); Sat, 27 Mar 2021 16:29:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:57956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbhC0U3I (ORCPT ); Sat, 27 Mar 2021 16:29:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 714E361934; Sat, 27 Mar 2021 20:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616876947; bh=t3YCJEd2YPJjPW/VVlG0IFWi7wn9Hjx67R3VG5hzcl0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OVgsxOpRvQIxqPE+tVlAfHUdu4Ht9oWDHCLAsjOE+vmFKOWwLTVll1/pMalxxguzz 2ABiCxzQfFjMsFbKs2dU1YJOawTUQHpaZ4upIfCNQyEdjgxPdF4BJGNrBSRdLmzubC MrIO4ZKx6Zwh+dcpDQPtcptA5fgGib+YCGrJbfpR+O5i7Qivb1uDlQdJ5vV8dqLpbI p6Sc1hHEyjZFotDKbVpYjg+CT5IffrUtBP88CF1gWk6yteub0wDpelOOuv47JyeJo1 O0UK0jSAQSrvNT3blPK/jMLrwouakf5paB4o//qwQmiJrbGHv+QsiV3eRlqictBVn1 j1cI2jkt4CQKQ== Received: by pali.im (Postfix) id F180A95D; Sat, 27 Mar 2021 21:29:04 +0100 (CET) Date: Sat, 27 Mar 2021 21:29:04 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Marc Zyngier Cc: Jianjun Wang , Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi , Ryder Lee , Philipp Zabel , Matthias Brugger , linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, youlin.pei@mediatek.com, chuanjia.liu@mediatek.com, qizhong.cheng@mediatek.com, sin_jieyang@mediatek.com, drinkcat@chromium.org, Rex-BC.Chen@mediatek.com, anson.chuang@mediatek.com, Krzysztof Wilczyski Subject: Re: [v9,5/7] PCI: mediatek-gen3: Add MSI support Message-ID: <20210327202904.nvn7tfodmc2xw23l@pali> References: <20210324030510.29177-1-jianjun.wang@mediatek.com> <20210324030510.29177-6-jianjun.wang@mediatek.com> <20210327192837.4rr46oeiuokritlc@pali> <87o8f4fkkh.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87o8f4fkkh.wl-maz@kernel.org> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday 27 March 2021 19:44:30 Marc Zyngier wrote: > On Sat, 27 Mar 2021 19:28:37 +0000, > Pali Rohár wrote: > > > > On Wednesday 24 March 2021 11:05:08 Jianjun Wang wrote: > > > +static void mtk_pcie_msi_handler(struct mtk_pcie_port *port, int set_idx) > > > +{ > > > + struct mtk_msi_set *msi_set = &port->msi_sets[set_idx]; > > > + unsigned long msi_enable, msi_status; > > > + unsigned int virq; > > > + irq_hw_number_t bit, hwirq; > > > + > > > + msi_enable = readl_relaxed(msi_set->base + PCIE_MSI_SET_ENABLE_OFFSET); > > > + > > > + do { > > > + msi_status = readl_relaxed(msi_set->base + > > > + PCIE_MSI_SET_STATUS_OFFSET); > > > + msi_status &= msi_enable; > > > + if (!msi_status) > > > + break; > > > + > > > + for_each_set_bit(bit, &msi_status, PCIE_MSI_IRQS_PER_SET) { > > > + hwirq = bit + set_idx * PCIE_MSI_IRQS_PER_SET; > > > + virq = irq_find_mapping(port->msi_bottom_domain, hwirq); > > > + generic_handle_irq(virq); > > > + } > > > + } while (true); > > > > Hello! > > > > Just a question, cannot this while-loop cause block of processing other > > interrupts? > > This is a level interrupt. You don't have much choice but to handle it > immediately, although an alternative would be to mask it and deal with > it in a thread. And since Linux doesn't deal with interrupt priority, > a screaming interrupt is never a good thing. I see. Something like "interrupt priority" (which does not exist?) would be needed to handle it. > > I have done tests with different HW (aardvark) but with same while(true) > > loop logic. One XHCI PCIe controller was sending MSI interrupts too fast > > and interrupt handler with this while(true) logic was in infinite loop. > > During one IRQ it was calling infinite many times generic_handle_irq() > > as HW was feeding new and new MSI hwirq into status register. > > Define "too fast". Fast - next interrupt comes prior checking if while(true)-loop should stop. > If something in the system is able to program the > XHCI device in such a way that it causes a screaming interrupt, that's > the place to look for problems, and probably not in the interrupt > handling itself, which does what it is supposed to do. > > > But this is different HW, so it can have different behavior and does not > > have to cause above issue. > > > > I have just spotted same code pattern for processing MSI interrupts... > > This is a common pattern that you will find in pretty much any > interrupt handling/demuxing, and is done this way when the cost of > taking the exception is high compared to that of handling it. And would not help if while(true)-loop is replaced by loop with upper limit of iterations? Or just call only one iteration? > Which is pretty much any of the badly designed, level-driving, > DW-inspired, sorry excuse for MSI implementations that are popular on > low-end ARM SoCs. Ok. So thank you for information! > Thanks, > > M. > > -- > Without deviation from the norm, progress is not possible.