Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2501186pxb; Sun, 16 Jan 2022 22:55:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJykt6hi72UCaEoaMZ0iIEKoK8z8bObRmpjqtdKBRE2JBQnIGPBvt0MIfm0527tVN7jlm7Lh X-Received: by 2002:a17:902:e80f:b0:14a:43d9:c91 with SMTP id u15-20020a170902e80f00b0014a43d90c91mr21325579plg.160.1642402528906; Sun, 16 Jan 2022 22:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642402528; cv=none; d=google.com; s=arc-20160816; b=Go/WwUO04fhcZQPiwwDw1Wfr2YZ41Df56AY99IwiGPfrRB1Vi2RHZV3yButsKlO4aG 93gC0ciragKzrfTMdDi38V/srY5NNXdhsPj0HjsqUn5tgf6ZhqyZBf9hd7slCiY0ASEV 6RnopBapgjSJKVlVSByW0btvUnZOHzV5Q9t7o7fXChYSTnr0PAz8sQsJkGsdz7Gp0cgY EH4LNq7Vsu3N46MNBDMJMDUIW5+F01t0kwxPx5ygNekoms6jJSZ3S2ENtNnWAnNXW3Wi hD9MV87hTDZlzvhuTBhw9SDX7nf1ANsL0BmKzM2+Y3W8tiHJo/LmovHfbJTmCuWtR3Ag Xamg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=qdt9jhw27kWimGZ0skfYHaLVfyHTm4u5jYedxLsxl9s=; b=ryMgMBFe2M7VSDU5kiyvi2Z5oV7Qrj+JlFbInMkA02p5zaSZ9pKhXnLevcvplD+hua fF4cEHeF7Z7WkM/dZUVEij3/cEGtuEf1Fq5Vj0yVvFaWhW/uAi/3XNmpnTdNof0yGMcH WQ+WYpC+k8V5vNqUOovfmE8nLWYXxc2ja2VKspGBPbhBNoOOyNe89A6frcSng0o8oA5/ qIiWZvAnic4vux/3k4SuxwyZocUV9Q35lkFfMG2WHqHnYOl4Z5piG3kVrPIohyUjsX1C KzEUvlQQ1cF01qBiokoYNP6MU87agaNzetGl4abodJ/WsSOtHz4XNtBwVmRRlrJsLLJ7 qLLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IqUzl8la; 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 u21si6060153plq.325.2022.01.16.22.55.17; Sun, 16 Jan 2022 22:55:28 -0800 (PST) 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=IqUzl8la; 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 S235027AbiAPMIF (ORCPT + 99 others); Sun, 16 Jan 2022 07:08:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235015AbiAPMIE (ORCPT ); Sun, 16 Jan 2022 07:08:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 230A5C061574 for ; Sun, 16 Jan 2022 04:08:04 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id E1810B80D36 for ; Sun, 16 Jan 2022 12:08:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AE24C36AE3; Sun, 16 Jan 2022 12:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642334881; bh=QGNKE7gbEb/ZzfuejdUhcHsHbvOyANPOdasmGXvhZfc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IqUzl8lalETftViUl232zvy4jSTKKmAHDGE0hph/1tJNyEjXXUthXDtV8CTlPYpyG WATInUbsF6NS8ZKk5gY35IqlpBmfCnTwk4d+qNyZR2GHJLkSrb9PhEBgfo6Av6HFt3 Kb+DzeI5G8LAeB0UKuuTgeNp8cs67AyC2gST9Pnq2IHQ5uMq2pbeU7qagTGyPJBRSk tzGUViPCcisfZxevycZL+NbVRBm1RfBvCqkg+pVv1wQRLGl490mUu2HNp4AQ+DSW4r TWrRwOBEhM/n5P7eAfFaM7ZC4+zT0kHZzHqVct54y9EJpw1Dhq4KthgV/LgO6ZwD4/ llVeH+WSUZW2w== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n94KF-000lcj-LU; Sun, 16 Jan 2022 12:07:59 +0000 Date: Sun, 16 Jan 2022 12:07:59 +0000 Message-ID: <87v8yjyjc0.wl-maz@kernel.org> From: Marc Zyngier To: John Garry Cc: Thomas Gleixner , chenxiang , Shameer Kolothum , "linux-kernel@vger.kernel.org" , "liuqi (BA)" Subject: Re: PCI MSI issue for maxcpus=1 In-Reply-To: <19d55cdf-9ef7-e4a3-5ae5-0970f0d7751b@huawei.com> References: <78615d08-1764-c895-f3b7-bfddfbcbdfb9@huawei.com> <87a6g8vp8k.wl-maz@kernel.org> <19d55cdf-9ef7-e4a3-5ae5-0970f0d7751b@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: john.garry@huawei.com, tglx@linutronix.de, chenxiang66@hisilicon.com, shameerali.kolothum.thodi@huawei.com, linux-kernel@vger.kernel.org, liuqi115@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 07 Jan 2022 11:24:38 +0000, John Garry wrote: > > Hi Marc, > > >> So it's the driver call to pci_alloc_irq_vectors_affinity() which > >> errors [1]: > >> > >> [ 9.619070] hisi_sas_v3_hw: probe of 0000:74:02.0 failed with error -2 > > Can you log what error is returned from pci_alloc_irq_vectors_affinity()? > > -EINVAL > > > > >> Some details: > >> - device supports 32 MSI > >> - min and max msi for that function is 17 and 32, respect. > > This 17 is a bit odd, owing to the fact that MultiMSI can only deal > > with powers of 2. You will always allocate 32 in this case. Not sure > > why that'd cause an issue though. Unless... > > Even though 17 is the min, we still try for nvec=32 in > msi_capability_init() as possible CPUs is 96. > > > > >> - affd pre and post are 16 and 0, respect. > >> > >> I haven't checked to see what the issue is yet and I think that the > >> pci_alloc_irq_vectors_affinity() usage is ok... > > ... we really end-up with desc->nvec_used == 32 and try to activate > > past vector 17 (which is likely to fail). Could you please check this? > > Yeah, that looks to fail. Reason being that in the GIC ITS driver when > we try to activate the irq for this managed interrupt all cpus in the > affinity mask are offline. Calling its_irq_domain_activate() -> > its_select_cpu() it gives cpu=nr_cpu_ids. The affinity mask for that > interrupt is 24-29. I guess that for managed interrupts, it shouldn't matter, as these interrupts should only be used when the relevant CPUs come online. Would something like below help? Totally untested, as I don't have a Multi-MSI capable device that I can plug in a GICv3 system (maybe I should teach that to a virtio device...). Thanks, M. diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index d25b7a864bbb..850407294adb 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1632,6 +1632,10 @@ static int its_select_cpu(struct irq_data *d, cpumask_and(tmpmask, tmpmask, cpumask_of_node(node)); cpu = cpumask_pick_least_loaded(d, tmpmask); + + /* If all the possible CPUs are offline, just pick a victim. */ + if (cpu == nr_cpu_ids) + cpu = cpumask_pick_least_loaded(d, irq_data_get_affinity_mask(d)); } out: free_cpumask_var(tmpmask); -- Without deviation from the norm, progress is not possible.