Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1909775pxu; Tue, 24 Nov 2020 11:50:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvtBxrU70AYauBDxBmVjkraZyWfbr2gF8+PVedeB1DaQGFA6GatVWuhJI1sJiiWO0ELcfA X-Received: by 2002:a05:6402:1a58:: with SMTP id bf24mr85456edb.191.1606247409317; Tue, 24 Nov 2020 11:50:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606247409; cv=none; d=google.com; s=arc-20160816; b=WmZx7MBKa/S1a45XwRzSo11BRbPqj5xm3z58Tu0bfJmJ9LnCfKX+qTMTyUAqe4kbEK 3dt7wi/apLzPDx0WE8pDTXsu752On6duO8kbnEtyUULyqfvytUMNR67SLpIWLtmTxkhF sa1MMvw+pSl4T6rnpR3PFq7KUm1EWsH9G9Ofm/EN1ZQZX/wrpM7zTAfDmaj/fQDUUrB+ 7/GvwbueP5rgSNsPdTtAtgKXmY9/ucc0Azgj9TmR2CN5C4AkR6Hn9GoytXFQHEfo8iuw kU3lXpq1WZHZQyt59r1bFIqJYtBUHKjlcl9tA+R+kJrldAi27+COJk3/tyLVS6TOoh0T JHYA== 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=x1B9rUPXQy5knRBPa+3sVZUliMadPFEAxeQowvLADP4=; b=dcT6Sp5fZG3LgshGs2aAWVex2VPDz9+iLvuKAFJTPz7ES30OftBjFxOBHuU6tKtrFp 2SSq/zniJsixN3wQ8qFUjn8Ll9/773+lCj7dyZtFyDLPv/p1vBNsvYbWQAcRyodMpj+B lwYiQMSSN4eNCpZbHmxIq2Z5CSRnkB367Hm+olRUNGkWwAvuUak7pJOGGZM2ZBUXzAUR drVk7CijyXaEtgSxvf+YaZ7cgRuzUj0LTrmVCr0j9PCjfWPnr3LbNzmYs82CWjXoW/lY IR/GVWvlgCShykyVbHsLQguuwaTCzPjHhTCUDKhDDIWgQX9DmLw2JzMwkBfuJHp4bCoJ +gqA== 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 z7si4108638edr.139.2020.11.24.11.49.46; Tue, 24 Nov 2020 11:50:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729066AbgKXGS5 (ORCPT + 99 others); Tue, 24 Nov 2020 01:18:57 -0500 Received: from ozlabs.ru ([107.174.27.60]:49914 "EHLO ozlabs.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727771AbgKXGS5 (ORCPT ); Tue, 24 Nov 2020 01:18:57 -0500 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 75863AE80257; Tue, 24 Nov 2020 01:18:20 -0500 (EST) From: Alexey Kardashevskiy To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Frederic Barrat , =?UTF-8?q?Michal=20Such=C3=A1nek?= , "Oliver O'Halloran" , Marc Zyngier , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, Alexey Kardashevskiy Subject: [PATCH kernel v4 8/8] powerpc/pci: Remove LSI mappings on device teardown Date: Tue, 24 Nov 2020 17:17:20 +1100 Message-Id: <20201124061720.86766-9-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124061720.86766-1-aik@ozlabs.ru> References: <20201124061720.86766-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. Signed-off-by: Oliver O'Halloran Reviewed-by: Cédric Le Goater 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