From patchwork Tue Feb 18 21:11:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 3674441 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B592C9F35F for ; Tue, 18 Feb 2014 20:22:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD9BD20163 for ; Tue, 18 Feb 2014 20:22:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F03A12011D for ; Tue, 18 Feb 2014 20:22:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752478AbaBRUVi (ORCPT ); Tue, 18 Feb 2014 15:21:38 -0500 Received: from p3plsmtps2ded01.prod.phx3.secureserver.net ([208.109.80.58]:46612 "EHLO p3plsmtps2ded01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752269AbaBRUUm (ORCPT ); Tue, 18 Feb 2014 15:20:42 -0500 Received: from linuxonhyperv.com ([72.167.245.219]) by p3plsmtps2ded01.prod.phx3.secureserver.net with : DED : id TwLi1n04U4kklxU01wLiRW; Tue, 18 Feb 2014 13:20:42 -0700 x-originating-ip: 72.167.245.219 Received: by linuxonhyperv.com (Postfix, from userid 503) id 8378B1902D9; Tue, 18 Feb 2014 13:12:05 -0800 (PST) From: Haiyang Zhang To: plagnioj@jcrosoft.com, tomi.valkeinen@ti.com, akpm@linux-foundation.org, linux-fbdev@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, olaf@aepfle.de, jasowang@redhat.com, linux-kernel@vger.kernel.org, driverdev-devel@linuxdriverproject.org Subject: [PATCH 2/2] hyperv_fb: Add support for Gen2 VM Date: Tue, 18 Feb 2014 13:11:31 -0800 Message-Id: <1392757891-28680-3-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1392757891-28680-1-git-send-email-haiyangz@microsoft.com> References: <1392757891-28680-1-git-send-email-haiyangz@microsoft.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch enables Hyper-V FB driver to run on Gen2 VM. The Gen2 VM provides MMIO area for synthetic video from ACPI module, which is exported by vmbus. The generic video is provided by UEFI. PCI video in Gen1 is no longer available. To support synthetic video on Hyper-V Gen2 VM, this patch updated code related to the changes above. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan --- drivers/video/hyperv_fb.c | 60 ++++++++++++++++++++++++++++++-------------- 1 files changed, 41 insertions(+), 19 deletions(-) diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c index bbcc8c0..5db1f20 100644 --- a/drivers/video/hyperv_fb.c +++ b/drivers/video/hyperv_fb.c @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -461,13 +462,13 @@ static int synthvid_connect_vsp(struct hv_device *hdev) goto error; } - if (par->synthvid_version == SYNTHVID_VERSION_WIN7) { + if (par->synthvid_version == SYNTHVID_VERSION_WIN7) screen_depth = SYNTHVID_DEPTH_WIN7; - screen_fb_size = SYNTHVID_FB_SIZE_WIN7; - } else { + else screen_depth = SYNTHVID_DEPTH_WIN8; - screen_fb_size = SYNTHVID_FB_SIZE_WIN8; - } + + screen_fb_size = hdev->channel->offermsg.offer. + mmio_megabytes * 1024 * 1024; return 0; @@ -635,22 +636,33 @@ static void hvfb_get_option(struct fb_info *info) /* Get framebuffer memory from Hyper-V video pci space */ static int hvfb_getmem(struct fb_info *info) { - struct pci_dev *pdev; + struct pci_dev *pdev = NULL; ulong fb_phys; void __iomem *fb_virt; + bool gen2vm = efi_enabled(EFI_BOOT); - pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT, + if (gen2vm) { + if (!hyperv_mmio_start || hyperv_mmio_size < screen_fb_size) { + pr_err("Unable to find ACPI MMIO area\n"); + return -ENODEV; + } + + fb_phys = hyperv_mmio_start; + } else { + pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT, PCI_DEVICE_ID_HYPERV_VIDEO, NULL); - if (!pdev) { - pr_err("Unable to find PCI Hyper-V video\n"); - return -ENODEV; - } + if (!pdev) { + pr_err("Unable to find PCI Hyper-V video\n"); + return -ENODEV; + } - if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) || - pci_resource_len(pdev, 0) < screen_fb_size) - goto err1; + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) || + pci_resource_len(pdev, 0) < screen_fb_size) + goto err1; + + fb_phys = pci_resource_end(pdev, 0) - screen_fb_size + 1; + } - fb_phys = pci_resource_end(pdev, 0) - screen_fb_size + 1; if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME)) goto err1; @@ -662,14 +674,22 @@ static int hvfb_getmem(struct fb_info *info) if (!info->apertures) goto err3; - info->apertures->ranges[0].base = pci_resource_start(pdev, 0); - info->apertures->ranges[0].size = pci_resource_len(pdev, 0); + if (gen2vm) { + info->apertures->ranges[0].base = screen_info.lfb_base; + info->apertures->ranges[0].size = screen_info.lfb_size; + } else { + info->apertures->ranges[0].base = pci_resource_start(pdev, 0); + info->apertures->ranges[0].size = pci_resource_len(pdev, 0); + } + info->fix.smem_start = fb_phys; info->fix.smem_len = screen_fb_size; info->screen_base = fb_virt; info->screen_size = screen_fb_size; - pci_dev_put(pdev); + if (!gen2vm) + pci_dev_put(pdev); + return 0; err3: @@ -677,7 +697,9 @@ err3: err2: release_mem_region(fb_phys, screen_fb_size); err1: - pci_dev_put(pdev); + if (!gen2vm) + pci_dev_put(pdev); + return -ENOMEM; }