From patchwork Mon Jun 13 19:45:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9174179 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 0AA4C6044F for ; Mon, 13 Jun 2016 19:45:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECFD61FF12 for ; Mon, 13 Jun 2016 19:45:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF88622064; Mon, 13 Jun 2016 19:45:35 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77D6B1FF12 for ; Mon, 13 Jun 2016 19:45:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1480B6E57B; Mon, 13 Jun 2016 19:45:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x244.google.com (mail-qk0-x244.google.com [IPv6:2607:f8b0:400d:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03D9E6E57B for ; Mon, 13 Jun 2016 19:45:29 +0000 (UTC) Received: by mail-qk0-x244.google.com with SMTP id b136so4295566qkg.2 for ; Mon, 13 Jun 2016 12:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=uZfmaHZV9DvXMWPhvAnZamJzgcZVRBMdWhzsZhZhhXY=; b=WCwCJ2Gvru4B1l/hgE1LU8wLl+pANBsXprNjs5UCBLV+2mknsuuqY8+bUM54HBjXvS ITqc4aAyQEOnB+drCmHLbYyCvDfoceSZxRl08LrIDA5dORsBc657I1twKtWAbBAfsLvT UWpqP2NrhMz+1REoc0Fw+Ou06SN1wlfTrtvzfTZMFtqbjbI2thr1TXtPeoZ4X/I9vjq0 rKiHlKT5y06TWj5+EVBCHeQCIIxRc1nWihLuwhcQkwKxSTWyM0+f4T41JCRWBZ6gC1iC n4m3LifvYVQUHBoHtsrBewCHrCD7I/XTwkDdj1OOkkDss0DNIL+FztVSEdRLa5X2L8xt 4Teg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uZfmaHZV9DvXMWPhvAnZamJzgcZVRBMdWhzsZhZhhXY=; b=P2pDmLst8fNbNCKn43UfdieZLZuKEUsrJ4MNjLbjLwPLRhIHanLqEoLlmbgaE2nPVS 3BW4a4QFjNnEFZE+hcfU/quU3kHId9BZlDFTDAiDS8zdAS1/bs9FPXPg9rmhkrlPKJA8 zXgwPee40xixk/aLE4HRIPeRVNh7r6CH7FNc2GMLqE+ph4GUK7/3gz6tjQnoVDpESKNY OmADSFcwXPUWWX7D6uwEyeHCcGafLlGJGliKCK2lLa4BGbuy7ysgR3EP5j1YBrUJEvFp LRapV/bLkVa580iaCgLbuIJHRoGKNuga0BUux1uAq2ji8DAb6+X1r4UhgYcLvhx+DxOh lPEg== X-Gm-Message-State: ALyK8tJc1FY6O6YeeTRhPX5iGh3yjGs5bzZDecUyIYoycpbKO+veuvUIBgF/72Gg7U/jXw== X-Received: by 10.55.45.66 with SMTP id t63mr16638538qkh.72.1465847128760; Mon, 13 Jun 2016 12:45:28 -0700 (PDT) Received: from cm.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id q17sm7294405qgq.49.2016.06.13.12.45.28 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 13 Jun 2016 12:45:28 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon: fix asic initialization for virtualized environments Date: Mon, 13 Jun 2016 15:45:20 -0400 Message-Id: <1465847120-17924-1-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.5 Cc: Alex Deucher , Alex Williamson , Andres Rodriguez , stable@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When executing in a PCI passthrough based virtuzliation environment, the hypervisor will usually attempt to send a PCIe bus reset signal to the ASIC when the VM reboots. In this scenario, the card is not correctly initialized, but we still consider it to be posted. Therefore, in a passthrough based environemnt we should always post the card to guarantee it is in a good state for driver initialization. Ported from amdgpu commit: amdgpu: fix asic initialization for virtualized environments Cc: Andres Rodriguez Cc: Alex Williamson Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/radeon/radeon_device.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index e61c763..21c44b2 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c @@ -630,6 +630,23 @@ void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) /* * GPU helpers function. */ + +/** + * radeon_device_is_virtual - check if we are running is a virtual environment + * + * Check if the asic has been passed through to a VM (all asics). + * Used at driver startup. + * Returns true if virtual or false if not. + */ +static bool radeon_device_is_virtual(void) +{ +#ifdef CONFIG_X86 + return boot_cpu_has(X86_FEATURE_HYPERVISOR); +#else + return false; +#endif +} + /** * radeon_card_posted - check if the hw has already been initialized * @@ -643,6 +660,10 @@ bool radeon_card_posted(struct radeon_device *rdev) { uint32_t reg; + /* for pass through, always force asic_init */ + if (radeon_device_is_virtual()) + return false; + /* required for EFI mode on macbook2,1 which uses an r5xx asic */ if (efi_enabled(EFI_BOOT) && (rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) &&