From patchwork Thu Aug 17 08:14:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Glauber X-Patchwork-Id: 9905285 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 2042A6038C for ; Thu, 17 Aug 2017 08:16:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1039628AC7 for ; Thu, 17 Aug 2017 08:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03E6328AC9; Thu, 17 Aug 2017 08:16:27 +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=-2.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B1BBE28AC7 for ; Thu, 17 Aug 2017 08:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ynZAqPgqXwyFrsk+vrmsySicN2bwTubsNaiTTErLOM0=; b=s61YaxwkDd7mPUhBV2VwcJADtT yx4g9d9uYAhL+353V/84L2ut7fWJKMm+gRHkp8y7XvocCzr+9AQNwX4M5SuOtXpgIUQF0Apo3knuF V4Tb5ts0ApLcQf0rRB0VeJxUEO0jhJ2JDIGMZrTxPp0jilup11RrG9j8ypr1bD16c99CFOxgCZ3iX 1YQkx71vItNhHApsme/6w3KXP0Gx5BiNsoNlbDzK1Zqs1jAJbyTN+rcGdmIfEOAhGfyx9ETS9Gcr1 1xwcxI/q5ai8czEelXPCxSPjPCkD6fYN1eZUx6BjOMjOR9odj9KGzTwFV25bGKbTE4Jbwc1EB0SLb Al7lEIMA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1diFyX-0004qq-NB; Thu, 17 Aug 2017 08:16:21 +0000 Received: from mail-wr0-f195.google.com ([209.85.128.195]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diFxc-0002vf-BR for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2017 08:15:32 +0000 Received: by mail-wr0-f195.google.com with SMTP id p8so983856wrf.2 for ; Thu, 17 Aug 2017 01:15:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l/LoCL2lhUNZ1BLafGDC+kBuQZaRjOetVe57J3MOTNc=; b=lbLcj8/RdVduuMCGF5cYCApVKHK8BckQuLhiBdY7v6YzuGjM1+DOssWKBdffCOZMLM q+HZO8Xwxq7c4dLneySHIe4I0/QnQNUdarpkeEizbTcA8wQtVZUVEMsNBI7z4xuh+SNR TjzvdOttFatPlxlJtUWw1UrPIbInxB8iQ9WxuzUCAKMSqmJT2020erJAtyWLaygzf3Cc zXDSj3QK4jFLBKMo05Ul/B8iOQSxsfQl+ZwojaUYkx0TRsqRGxhb9NGDQsLkChePjVnh Vs3Y+TzzjERlt7fM5ddp5X6yE56/dpUiD007Y5V7I8TIkcvCF4dOwmKj8jOKGTlJBmZg u6dA== X-Gm-Message-State: AHYfb5jSSfOLI5t/FpbpHySLf+4eXKyc08dMuUCv8Cw353c1c2s0MaJg Nuk9gsLLfV+e9A== X-Received: by 10.223.170.140 with SMTP id h12mr2685615wrc.79.1502957705644; Thu, 17 Aug 2017 01:15:05 -0700 (PDT) Received: from wintermute.fritz.box (HSI-KBW-46-223-170-164.hsi.kabel-badenwuerttemberg.de. [46.223.170.164]) by smtp.gmail.com with ESMTPSA id x14sm8467633wmd.19.2017.08.17.01.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Aug 2017 01:15:04 -0700 (PDT) From: Jan Glauber To: Bjorn Helgaas , linux-pci@vger.kernel.org, Alex Williamson Subject: [PATCH v2 3/3] vfio/pci: Don't probe devices that can't be reset Date: Thu, 17 Aug 2017 10:14:23 +0200 Message-Id: <1502957663-5527-4-git-send-email-jglauber@cavium.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502957663-5527-1-git-send-email-jglauber@cavium.com> References: <1502957663-5527-1-git-send-email-jglauber@cavium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170817_011524_699066_349F1795 X-CRM114-Status: GOOD ( 10.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, david.daney@cavium.com, Jon Masters , linux-kernel@vger.kernel.org, Robert Richter , Jan Glauber , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If a PCI device supports neither function-level reset, nor slot or bus reset then refuse to probe it. A line is printed to inform the user. Without this change starting qemu with a vfio-pci device can lead to a kernel panic on some Cavium cn8xxx systems, depending on the used device. Signed-off-by: Jan Glauber --- drivers/vfio/pci/vfio_pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 063c1ce..029ba13 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1196,6 +1196,12 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL) return -EINVAL; + ret = pci_probe_reset_bus(pdev->bus); + if (ret) { + dev_warn(&pdev->dev, "Refusing to probe because reset is not possible.\n"); + return ret; + } + group = vfio_iommu_group_get(&pdev->dev); if (!group) return -EINVAL;