Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1576495rwd; Thu, 25 May 2023 14:55:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6iHxuCZwbgXdgwGLFUOlzLB/kHlu1w2MOCHoNZs2034OPW8nxs1Df7ruD2C3q8E/S+Spl5 X-Received: by 2002:a17:90a:dd89:b0:255:2dfc:6c6f with SMTP id l9-20020a17090add8900b002552dfc6c6fmr102534pjv.24.1685051724011; Thu, 25 May 2023 14:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685051723; cv=none; d=google.com; s=arc-20160816; b=YsChGBfelgw/bZ453+HtYrrkNRGV6WGcNWwqIcG83UqW4D4ZGckQf0q7V2iTrkn1xm Aiko+MsYI2qYNL1k0IC9cop9hMeCP9T7ij05xQvGAi3uQOeSeksAl08slt9Kr0e9Bv/V oR+bBjvNrelurNm54OJVTMija83JKWw/8vqLBo/wNoFKsmO4sw9Go8fz5ngfJFpT/lHI vOJGW8u25FBr3qF5YTKvxkIQzXVQF0y6EXAr9OvCdRmr1opL4zYwGnlGjzn+5Y6Cpkby vefIDINSZM3i0J4JE4QGyDJZdX2UuP3vvOsmzwXzpS2/o7+sLz9Z6RqBgQcc/xFJDX3t AB9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=ndlUX5onQE03Fd1D154IdqNvrf4nRLRXV7WSpe+HMNk=; b=IcelRVK6Y7aP5LmpSO2oYVHzSyrdUiL1GOnJu4FEYx35nTgE+FQ1TCKaWaXmh4WBzj Ey7kVCDS7hhCeyTMV5rRrvtfs18knNQ1kUEBxjeiRewA4xEe9Y/Ou4wHwwXrhBofV5yB OFZgPwhxi8flkpUUZMMVMOjluDJVgKfbFwc6GPjcFbfkB0DVyL7u6qpClTdDbS91nHC+ 9gXhPyX97580tvL5376HDOuEPxOsjCKn+dkzii4o97Fo0ad4pTn85zhl0JPfi8m43npU MJ4Bv6z67TTGSds601QeR42i+2peJRaML3pFBLoGDi238HLRT0gj4Il8LQVTTUMeW/Lf 06zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="T8ILF/OA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a17090acf0300b0023d3fad2294si2469508pju.10.2023.05.25.14.55.11; Thu, 25 May 2023 14:55:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="T8ILF/OA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S241895AbjEYVk6 (ORCPT + 99 others); Thu, 25 May 2023 17:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235791AbjEYVkz (ORCPT ); Thu, 25 May 2023 17:40:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C7FE1A8; Thu, 25 May 2023 14:40:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A6BAF64B6A; Thu, 25 May 2023 21:40:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7906C4339B; Thu, 25 May 2023 21:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685050850; bh=1uqUk6bD9K92o66z+OLfJTef++cVjRmb/LhsCFinS0U=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=T8ILF/OALc4ipAqevwNHm2c9oon066GWZxBSUf/3nTTMrtAwf3lOiC+b7MH1z/QmO MN2OviW/Q/T/ga4W3koqQbWBvFn2PBstNGBTsJrJrnskdtEmZsP1mxOPh5T93nIUyr cV1h73AniJ1msYUFj17IWeeb1OFmqCb3pMMluvGfHeNX/mVWpcscRxqD+TYwn/4LoC eRPgS6GFKCYSoA7E4snPhdiMDehPe0LChhqNZe7l0Mz3v1iZEaqaHV/yDMRsk79kZP Qkh/cmNZV3pybWkVXaBcVHScVcJ6t2/Pyc0Eb9caJzku9g/LqyhXTBnVxYwaAjeD6k xcTXWeG/sB9Cw== Date: Thu, 25 May 2023 16:40:48 -0500 From: Bjorn Helgaas To: Huacai Chen Cc: Huacai Chen , Bjorn Helgaas , Thomas Gleixner , "Ahmed S . Darwish" , Jason Gunthorpe , Kevin Tian , linux-pci@vger.kernel.org, Jianmin Lv , Jiaxun Yang , loongson-kernel@lists.loongnix.cn, Juxin Gao , Marc Zyngier , linux-kernel@vger.kernel.org Subject: Re: [PATCH] pci: irq: Add an early parameter to limit pci irq numbers Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 25, 2023 at 05:14:28PM +0800, Huacai Chen wrote: > On Wed, May 24, 2023 at 11:21 PM Bjorn Helgaas wrote: > > On Wed, May 24, 2023 at 05:36:23PM +0800, Huacai Chen wrote: > > > Some platforms (such as LoongArch) cannot provide enough irq numbers as > > > many as logical cpu numbers. So we should limit pci irq numbers when > > > allocate msi/msix vectors, otherwise some device drivers may fail at > > > initialization. This patch add a cmdline parameter "pci_irq_limit=xxxx" > > > to control the limit. > > > > > > The default pci msi/msix number limit is defined 32 for LoongArch and > > > NR_IRQS for other platforms. > > > > The IRQ experts can chime in on this, but this doesn't feel right to > > me. I assume arch code should set things up so only valid IRQ numbers > > can be allocated. This doesn't seem necessarily PCI-specific, I'd > > prefer to avoid an arch #ifdef here, and I'd also prefer to avoid a > > command-line parameter that users have to discover and supply. > > The problem we meet: LoongArch machines can have as many as 256 > logical cpus, and the maximum of msi vectors is 192. Even on a 64-core > machine, 192 irqs can be easily exhausted if there are several NICs > (NIC usually allocates msi irqs depending on the number of online > cpus). So we want to limit the msi allocation. > > This is not a LoongArch-specific problem, because I think other > platforms can also meet if they have many NICs. But of course, > LoongArch can meet it more easily because the available msi vectors > are very few. So, adding a cmdline parameter is somewhat reasonable. The patch contains "#ifdef CONFIG_LOONGARCH", which makes this solution LoongArch-specific. I'm not willing for that yet. It sounds like the LoongArch MSI limit is known at compile-time, or at least at boot-time, so the kernel ought to be able to figure out what to do without a command-line parameter. > After some investigation, I think it may be possible to modify > drivers/irqchip/irq-loongson-pch-msi.c and override > msi_domain_info::domain_alloc_irqs() to limit msi allocation. However, > doing that need to remove the "static" before > __msi_domain_alloc_irqs(), which means revert > 762687ceb31fc296e2e1406559e8bb5 ("genirq/msi: Make > __msi_domain_alloc_irqs() static"), I don't know whether that is > acceptable. I guess you mean msi_domain_ops::domain_alloc_irqs() (not msi_domain_info). If this is really a generic problem, I'm surprised that no other arch has needed to override .domain_alloc_irqs(). I think you'll have better luck getting feedback if you can post the complete working patch. At the very least, you'll learn more about the problem by doing that. Bjorn