Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4044861pxb; Mon, 1 Feb 2021 10:54:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmsSyyVRdyTviq4NuSR0JpVKWwXnN17u20tpPMCFa2vjALhclJ+CGm9Zhcv+t0zjbfhTmk X-Received: by 2002:aa7:de10:: with SMTP id h16mr20482149edv.385.1612205685794; Mon, 01 Feb 2021 10:54:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612205685; cv=none; d=google.com; s=arc-20160816; b=jcFo2PwPjZ+ptwcD4nxK5lJ+iRZu7thonpvQXj7Jve9XWdb0zGxG1U2oCGTUjGIn7s 9NSfyQyNLzA4n/0D3RF7pSXBo6ImvcaaQfAF6Hu+9d4rc0oSyET0RKAS0A+2fKxR7RYS RmoI8y9/+T4kel7cv+8lk8cgOwIH73ZGd/8+dncvxzrGZ7LwdiyvHWIo1eCnNytgLfkg pY0zqDsIURWKNV3ZAFj19ZE97HHORa/LDkaWgFxB5Y/7Gtc48wqdObIBMFF7T/IacKrJ FmF2Uly+jmWhso7VnuYfXBCuiFdDhzpiDEF1LvTkaQgkYV1EfIGUGf4IxQDlb9PZJ924 XkSQ== 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; bh=R0DOcuqfvEGHhU/0JZ+vpmBFE0wigDbSoHpJkYGZXmo=; b=I2WFWLkKDHadpEhgjhCWtc5jNX4HFPMg7rbWBunrTfqECTPS9Fkj+G9z9dx0PAQMA9 m/ra4LTIRmQJwXUmf5GK/tC6I+BULtxJQbY2jVe9P+Hp/j/KQJOKe2qWHemorxXGzNil GIz+dONzhzm0anBEaWjW40T8WFztc0CrmTq5twYzeh/g2chka32IDKp/OptFGWyRZe3u Oh3oJ8/AxynTf075LAIiBnYw/oWVMYiC/i9/b9DDzq8wUwhW1Z/N5tq5ZAFsTHtUCZMh tFGaQjyot33RBgP5OU3zERGZUCKgpY3AGeWCn2c5ZRDI46KAcK29EpUmOYkIoyA1V05k oXwQ== ARC-Authentication-Results: i=1; mx.google.com; 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 hj12si4924325ejb.577.2021.02.01.10.54.20; Mon, 01 Feb 2021 10:54:45 -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; 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 S231191AbhBASvQ (ORCPT + 99 others); Mon, 1 Feb 2021 13:51:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:35728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbhBASvP (ORCPT ); Mon, 1 Feb 2021 13:51:15 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5BD864DA8; Mon, 1 Feb 2021 18:50:34 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] 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) (envelope-from ) id 1l6eHQ-00BLAx-Lg; Mon, 01 Feb 2021 18:50:32 +0000 Date: Mon, 01 Feb 2021 18:50:32 +0000 Message-ID: <87o8h3lj0n.wl-maz@kernel.org> From: Marc Zyngier To: John Garry Cc: Thomas Gleixner , Zhou Wang , "linux-kernel@vger.kernel.org" Subject: Re: PCI MSI issue with reinserting a driver In-Reply-To: References: 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: 62.31.163.78 X-SA-Exim-Rcpt-To: john.garry@huawei.com, tglx@linutronix.de, wangzhou1@hisilicon.com, linux-kernel@vger.kernel.org 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 Hi John, On Mon, 01 Feb 2021 18:34:59 +0000, John Garry wrote: > > Just a heads-up, by chance I noticed that I can't re-insert a specific > driver on v5.11-rc6: > > [ 64.356023] hisi_dma 0000:7b:00.0: Adding to iommu group 31 > [ 64.368627] hisi_dma 0000:7b:00.0: enabling device (0000 -> 0002) > [ 64.384156] hisi_dma 0000:7b:00.0: Failed to allocate MSI vectors! > [ 64.397180] hisi_dma: probe of 0000:7b:00.0 failed with error -28 > > That's with CONFIG_DEBUG_TEST_DRIVER_REMOVE=y > > Bisect tells me that this is the first bad commit: > 4615fbc3788d genirq/irqdomain: Don't try to free an interrupt that has > no mapping > > The relevant driver code is > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/dma/hisi_dma.c#n547 > > That driver only allocates 30 MSI, so maybe there's a problem with not > allocating (and freeing) all 32 MSI. Are they Multi-MSI (and not MSI-X)? > I'll have a bit more of a look tomorrow. Here's my suspicion: two of the interrupts are mapped in the low-level domain (the ITS, I'd expect in your case), but they have never been mapped at the higher level. On teardown, we only get rid of the 30 that were actually mapped, and leave the last two dangling in the ITS domain, and thus the ITS device resources are never freed. On reload, we request another 32 interrupts, which can't be satisfied for this device. Assuming I got it right, the question is: why weren't these interrupts mapped in the PCI domain the first place. And if I got it wrong, I'm even more curious! Thanks, M. -- Without deviation from the norm, progress is not possible.