Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp107172pxx; Tue, 27 Oct 2020 23:04:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/EE9+tEIsivNgT+MGmt+A2xEiBgcAF26LViqHDcDtGIOPvEpkcISRy5fquVzLCDShH7al X-Received: by 2002:a17:907:72cd:: with SMTP id du13mr737097ejc.398.1603865059859; Tue, 27 Oct 2020 23:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603865059; cv=none; d=google.com; s=arc-20160816; b=WJmtwEe0/H/1EEO77bIfllDP2LSQyRIECj2CBPbNSY4EdFPRwqWAAZuyMHe+anvFC/ bRLjr0QVBFl8cfYJBDtxkjReyOd9C8zKiqlm0DiwTjoZ76IyLaPTQAd9gZvp/zwdxR5g /033+2bsJEjNb01H43etYKwKVKqhIXEHvoluxXPyiSvDL9s91TV9Guvmx8mn2skguR24 4Em2mDHTa3bxsD+VxSzcJHErGgYh17WfiQLnawXj8tovS+/GOi8gWRmcMWBmqhAJovha G+ealcHwje6b3s0ZhZs2uLt4wwTAjNMi5FikmhLlvfCN+JLB3QgBeoeGoX38lHExdLia bmgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=56/pUYoV1DXkYH922k9ZpR0m/79v3k+HFem7kuOEB/k=; b=wutBx8MSZBNTDE802BtHZT1O6GXp/l9Jpmll2RtxFOGJc4bjNmz0ZVY/EFuvIOfomD uTDIRClngWNo0zHEz5D1gTavcAdBG02QHsepwApzq0rnzoMEKkT6/lVWq+cgpWT05d+R fpsH7KNKpOMetEN3WxqPMdWxhQz0LfxcuxR5cE7CZE+Wx90ajgzb2v8P8lXWfNW4FEEu 4P7NOyIZQAwAZAlWtqbGIA8C7T5VXcIkHom7+4pMQPRiytp/a7viTFdB+lf1Owv+YxNK 8OQjXXJS90Tvp/kl5/1L7bQj6bYZTke61dyE8pH3U9nXDwSs+CjW+9uRGqyA8NtYx109 H0Cw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si2594068ejt.9.2020.10.27.23.03.57; Tue, 27 Oct 2020 23:04:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2895355AbgJ0JH6 (ORCPT + 99 others); Tue, 27 Oct 2020 05:07:58 -0400 Received: from ozlabs.ru ([107.174.27.60]:43022 "EHLO ozlabs.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2895351AbgJ0JH6 (ORCPT ); Tue, 27 Oct 2020 05:07:58 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id D4AB2AE80274; Tue, 27 Oct 2020 05:06:42 -0400 (EDT) From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , "Oliver O'Halloran" , Marc Zyngier , Michael Ellerman , Qian Cai , Rob Herring , Thomas Gleixner , linux-kernel@vger.kernel.org, Frederic Barrat , =?UTF-8?q?Michal=20Such=C3=A1nek?= , Alexey Kardashevskiy Subject: [RFC PATCH kernel 2/2] powerpc/pci: Remove LSI mappings on device teardown Date: Tue, 27 Oct 2020 20:06:55 +1100 Message-Id: <20201027090655.14118-3-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201027090655.14118-1-aik@ozlabs.ru> References: <20201027090655.14118-1-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver O'Halloran When a passthrough IO adapter is removed from a pseries machine using hash MMU and the XIVE interrupt mode, the POWER hypervisor expects the guest OS to clear all page table entries related to the adapter. If some are still present, the RTAS call which isolates the PCI slot returns error 9001 "valid outstanding translations" and the removal of the IO adapter fails. This is because when the PHBs are scanned, Linux maps automatically the INTx interrupts in the Linux interrupt number space but these are never removed. This problem can be fixed by adding the corresponding unmap operation when the device is removed. There's no pcibios_* hook for the remove case, but the same effect can be achieved using a bus notifier. Cc: Cédric Le Goater Cc: Michael Ellerman Signed-off-by: Oliver O'Halloran Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/kernel/pci-common.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index be108616a721..95f4e173368a 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -404,6 +404,27 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) return 0; } +static int ppc_pci_unmap_irq_line(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct pci_dev *pdev = to_pci_dev(data); + + if (action == BUS_NOTIFY_DEL_DEVICE) + irq_dispose_mapping(pdev->irq); + + return NOTIFY_DONE; +} + +static struct notifier_block ppc_pci_unmap_irq_notifier = { + .notifier_call = ppc_pci_unmap_irq_line, +}; + +static int ppc_pci_register_irq_notifier(void) +{ + return bus_register_notifier(&pci_bus_type, &ppc_pci_unmap_irq_notifier); +} +arch_initcall(ppc_pci_register_irq_notifier); + /* * Platform support for /proc/bus/pci/X/Y mmap()s. * -- paulus. -- 2.17.1