From patchwork Fri Jun 30 05:24:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 9818439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33E3E6035F for ; Fri, 30 Jun 2017 05:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26B3E2847A for ; Fri, 30 Jun 2017 05:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B5ED285D2; Fri, 30 Jun 2017 05:24:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C09F12847A for ; Fri, 30 Jun 2017 05:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751947AbdF3FYy (ORCPT ); Fri, 30 Jun 2017 01:24:54 -0400 Received: from ozlabs.ru ([107.173.13.209]:39218 "EHLO ozlabs.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942AbdF3FYx (ORCPT ); Fri, 30 Jun 2017 01:24:53 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 8CC8F3A60013; Fri, 30 Jun 2017 01:25:30 -0400 (EDT) From: Alexey Kardashevskiy To: kvm@vger.kernel.org Cc: Alexey Kardashevskiy , David Gibson , Alex Williamson , Bjorn Helgaas , Yongji Xie , Eric Auger , Yongji Xie Subject: [PATCH kernel v4 4/6] iommu: Set PCI_BUS_FLAGS_MSI_REMAP on iommu driver initialization Date: Fri, 30 Jun 2017 15:24:34 +1000 Message-Id: <20170630052436.15212-5-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630052436.15212-1-aik@ozlabs.ru> References: <20170630052436.15212-1-aik@ozlabs.ru> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yongji Xie Some iommu drivers would be initialized after PCI device enumeration. So PCI_BUS_FLAGS_MSI_REMAP would not be set when probing PCI devices although IOMMU enables capability of IRQ remapping. This patch tests this capability and set the flag when iommu driver is initialized. Signed-off-by: Yongji Xie Signed-off-by: Alexey Kardashevskiy --- drivers/iommu/iommu.c | 8 ++++++++ drivers/pci/probe.c | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index cf7ca7e70777..0b5881ddca09 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1063,6 +1063,14 @@ static int add_iommu_group(struct device *dev, void *data) const struct iommu_ops *ops = cb->ops; int ret; + /* + * Set PCI_BUS_FLAGS_MSI_REMAP for all PCI buses when IOMMU + * have capability of IRQ remapping. + */ + if (dev_is_pci(dev) && ops->capable && + ops->capable(IOMMU_CAP_INTR_REMAP)) + to_pci_dev(dev)->bus->bus_flags |= PCI_BUS_FLAGS_MSI_REMAP; + if (!ops->add_device) return 0; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index f2393b7d7ebf..14aac9df3d17 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "pci.h" #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */