Re: [PATCH v5 0/2] hyperv-fb: add support for generation 2 virtual machines

2014-02-28 Thread Gerd Hoffmann
On Fr, 2014-02-28 at 11:01 +0200, Tomi Valkeinen wrote:
 On 26/02/14 12:51, Gerd Hoffmann wrote:
Hi,
  
  This patch series adds support for uefi-based gen2 virtual machines
  to the hyperv-fb driver.  It depends on a few vmbus changes which are
  staged in Greg's char-misc tree (and linux-next).
 
 Depends how?

Will fail to build without the vmbus patches.

 Patches that depend on other patches should be merged via
 the same tree to avoid compile or functional breaks.

I think Greg will happily merge them through char-misc if he gets your
fbdev maintainer ACK for the patches.

cheers,
  Gerd


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 1/4] vmbus: add missing breaks

2014-02-28 Thread Gerd Hoffmann

 Why is this sent to fbdev list? Is this related to the hyperv-fb patches?

Yes, the hyperv-fb patches depend on this one.

Greg has picked it up meanwhile, that's why v4 + v5 of the patch series
don't include it any more.

cheers,
  Gerd


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 2/2] hyperv-fb: kick off efifb early

2014-02-26 Thread Gerd Hoffmann
  Hi,

  diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c index
  b7b3dd0..1b11886 100644
  --- a/drivers/video/hyperv_fb.c
  +++ b/drivers/video/hyperv_fb.c
  @@ -683,6 +683,7 @@ static int hvfb_getmem(struct fb_info *info)
  info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
  info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
  }
  +   remove_conflicting_framebuffers(info-apertures,
  KBUILD_MODNAME,
  +false);
 
 Thanks for the updates. I'm concerned about, after removing efifb, 
 if synthvid_send_config(hdev) fails, then there will be no video driver
 available.

That may happen, yes.

 Is there a way to bring the generic driver back if 
 synthvid_send_config(hdev) fails?

Not that I know of.

 If no way to recover the generic driver, please limit the early
 remove_conflicting_framebuffers() to Gen2 VM only.

I'll send updated patches once they are tested.

cheers,
  Gerd


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 0/2] hyperv-fb: add support for generation 2 virtual machines

2014-02-26 Thread Gerd Hoffmann
  Hi,

This patch series adds support for uefi-based gen2 virtual machines
to the hyperv-fb driver.  It depends on a few vmbus changes which are
staged in Greg's char-misc tree (and linux-next).

Patch #1 implements gen2 vm support for hyperv-fb.

Patch #2 unregisters efifb early to make sure the framebuffer isn't used
any more while hyperv-fb initialization is in progress.

v5 changes:
 - call remove_conflicting_framebuffers() only on gen2
   virtual machines.

v4 changes:
 - use KBUILD_MODNAME everywhere for consistent naming.
 - drop the two patches which Greg has staged in char-misc.

please apply,
  Gerd

Gerd Hoffmann (2):
  hyperv-fb: add support for generation 2 virtual machines.
  hyperv-fb: kick off efifb early

 drivers/video/hyperv_fb.c | 88 +--
 1 file changed, 62 insertions(+), 26 deletions(-)

-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 1/2] hyperv-fb: add support for generation 2 virtual machines.

2014-02-26 Thread Gerd Hoffmann
UEFI-based generation 2 virtual machines support vmbus devices only.
There is no pci bus.  Thus they use a different mechanism for the
graphics framebuffer:  Instead of using the vga pci bar a chunk of
memory muct be allocated from the hyperv mmio region declared using
APCI.  This patch implements support for it.

Based on a patch by Haiyang Zhang haiya...@microsoft.com

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 86 +--
 1 file changed, 60 insertions(+), 26 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..b7b3dd0 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -42,6 +42,7 @@
 #include linux/completion.h
 #include linux/fb.h
 #include linux/pci.h
+#include linux/efi.h
 
 #include linux/hyperv.h
 
@@ -212,6 +213,7 @@ struct synthvid_msg {
 
 struct hvfb_par {
struct fb_info *info;
+   struct resource mem;
bool fb_ready; /* fb device is ready */
struct completion wait;
u32 synthvid_version;
@@ -460,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;
 
@@ -627,26 +629,46 @@ 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;
-   ulong fb_phys;
+   struct hvfb_par *par = info-par;
+   struct pci_dev *pdev  = NULL;
void __iomem *fb_virt;
+   int gen2vm = efi_enabled(EFI_BOOT);
+   int ret;
 
-   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
+   par-mem.name = KBUILD_MODNAME;
+   par-mem.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+   if (gen2vm) {
+   ret = allocate_resource(hyperv_mmio, par-mem,
+   screen_fb_size,
+   0, -1,
+   screen_fb_size,
+   NULL, NULL);
+   if (ret != 0) {
+   pr_err(Unable to allocate framebuffer memory\n);
+   return -ENODEV;
+   }
+   } 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;
-   if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME))
-   goto err1;
+   par-mem.end = pci_resource_end(pdev, 0);
+   par-mem.start = par-mem.end - screen_fb_size + 1;
+   ret = request_resource(pdev-resource[0], par-mem);
+   if (ret != 0) {
+   pr_err(Unable to request framebuffer memory\n);
+   goto err1;
+   }
+   }
 
-   fb_virt = ioremap(fb_phys, screen_fb_size);
+   fb_virt = ioremap(par-mem.start, screen_fb_size);
if (!fb_virt)
goto err2;
 
@@ -654,30 +676,42 @@ 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);
-   info-fix.smem_start = fb_phys;
+   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 = par-mem.start;
info-fix.smem_len = screen_fb_size;
info-screen_base = fb_virt;
info-screen_size = screen_fb_size

[PATCH v5 2/2] hyperv-fb: kick off efifb early

2014-02-26 Thread Gerd Hoffmann
Remove firmware framebuffer before initializing hyperv-fb.  Needed
on gen2 virtual machines.   Letting register_framebuffer handle the
switchover results in efifb still being active while hyperv graphics
are initialized, which in turn can make the linux kernel hang.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index b7b3dd0..e23392e 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -679,6 +679,8 @@ static int hvfb_getmem(struct fb_info *info)
if (gen2vm) {
info-apertures-ranges[0].base = screen_info.lfb_base;
info-apertures-ranges[0].size = screen_info.lfb_size;
+   remove_conflicting_framebuffers(info-apertures,
+   KBUILD_MODNAME, false);
} else {
info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 2/2] hyperv-fb: kick off efifb early

2014-02-25 Thread Gerd Hoffmann
Remove firmware framebuffer before initializing hyperv-fb.  Needed
on gen2 virtual machines.   Letting register_framebuffer handle the
switchover results in efifb still being active while hyperv graphics
are initialized, which in turn can make the linux kernel hang.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index b7b3dd0..1b11886 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -683,6 +683,7 @@ static int hvfb_getmem(struct fb_info *info)
info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
}
+   remove_conflicting_framebuffers(info-apertures, KBUILD_MODNAME, false);
 
info-fix.smem_start = par-mem.start;
info-fix.smem_len = screen_fb_size;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 1/2] hyperv-fb: add support for generation 2 virtual machines.

2014-02-25 Thread Gerd Hoffmann
UEFI-based generation 2 virtual machines support vmbus devices only.
There is no pci bus.  Thus they use a different mechanism for the
graphics framebuffer:  Instead of using the vga pci bar a chunk of
memory muct be allocated from the hyperv mmio region declared using
APCI.  This patch implements support for it.

Based on a patch by Haiyang Zhang haiya...@microsoft.com

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 86 +--
 1 file changed, 60 insertions(+), 26 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..b7b3dd0 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -42,6 +42,7 @@
 #include linux/completion.h
 #include linux/fb.h
 #include linux/pci.h
+#include linux/efi.h
 
 #include linux/hyperv.h
 
@@ -212,6 +213,7 @@ struct synthvid_msg {
 
 struct hvfb_par {
struct fb_info *info;
+   struct resource mem;
bool fb_ready; /* fb device is ready */
struct completion wait;
u32 synthvid_version;
@@ -460,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;
 
@@ -627,26 +629,46 @@ 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;
-   ulong fb_phys;
+   struct hvfb_par *par = info-par;
+   struct pci_dev *pdev  = NULL;
void __iomem *fb_virt;
+   int gen2vm = efi_enabled(EFI_BOOT);
+   int ret;
 
-   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
+   par-mem.name = KBUILD_MODNAME;
+   par-mem.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+   if (gen2vm) {
+   ret = allocate_resource(hyperv_mmio, par-mem,
+   screen_fb_size,
+   0, -1,
+   screen_fb_size,
+   NULL, NULL);
+   if (ret != 0) {
+   pr_err(Unable to allocate framebuffer memory\n);
+   return -ENODEV;
+   }
+   } 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;
-   if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME))
-   goto err1;
+   par-mem.end = pci_resource_end(pdev, 0);
+   par-mem.start = par-mem.end - screen_fb_size + 1;
+   ret = request_resource(pdev-resource[0], par-mem);
+   if (ret != 0) {
+   pr_err(Unable to request framebuffer memory\n);
+   goto err1;
+   }
+   }
 
-   fb_virt = ioremap(fb_phys, screen_fb_size);
+   fb_virt = ioremap(par-mem.start, screen_fb_size);
if (!fb_virt)
goto err2;
 
@@ -654,30 +676,42 @@ 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);
-   info-fix.smem_start = fb_phys;
+   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 = par-mem.start;
info-fix.smem_len = screen_fb_size;
info-screen_base = fb_virt;
info-screen_size = screen_fb_size

[PATCH v4 0/2] hyperv-fb: add support for generation 2 virtual machines.

2014-02-25 Thread Gerd Hoffmann
  Hi,

This patch series adds support for uefi-based gen2 virtual machines
to the hyperv-fb driver.  It depends on a few vmbus changes which are
staged in Greg's char-misc tree (and linux-next).

Patch #1 implements gen2 vm support for hyperv-fb.

Patch #2 unregisters efifb early to make sure the framebuffer isn't used
any more while hyperv-fb initialization is in progress.

v4 changes:
 - use KBUILD_MODNAME everywhere for consistent naming.
 - drop the two patches which Greg has staged in char-misc.

please apply,
  Gerd

Gerd Hoffmann (2):
  hyperv-fb: add support for generation 2 virtual machines.
  hyperv-fb: kick off efifb early

 drivers/video/hyperv_fb.c | 87 +--
 1 file changed, 61 insertions(+), 26 deletions(-)

-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/5] Drivers: hv: vmbus: Extract the mmio information from DSDT

2014-02-24 Thread Gerd Hoffmann
From: K. Y. Srinivasan k...@microsoft.com

On Gen2 firmware, Hyper-V does not emulate the PCI bus. However, the MMIO
information is packaged up in DSDT. Extract this information and export it
for use by the synthetic framebuffer driver. This is the only driver that
needs this currently.

In this version of the patch mmio, I have updated the hyperv header file
(linux/hyperv.h) with mmio definitions.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/hv/vmbus_drv.c | 45 -
 include/linux/hyperv.h |  3 +++
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 077bb1b..b37c91b 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -43,6 +43,10 @@ static struct acpi_device  *hv_acpi_dev;
 static struct tasklet_struct msg_dpc;
 static struct completion probe_event;
 static int irq;
+u64 hyperv_mmio_start;
+EXPORT_SYMBOL_GPL(hyperv_mmio_start);
+u64 hyperv_mmio_size;
+EXPORT_SYMBOL_GPL(hyperv_mmio_size);
 
 static int vmbus_exists(void)
 {
@@ -886,18 +890,19 @@ void vmbus_device_unregister(struct hv_device *device_obj)
 
 
 /*
- * VMBUS is an acpi enumerated device. Get the the IRQ information
- * from DSDT.
+ * VMBUS is an acpi enumerated device. Get the the information we
+ * need from DSDT.
  */
 
-static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *irq)
+static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *ctx)
 {
+   switch (res-type) {
+   case ACPI_RESOURCE_TYPE_IRQ:
+   irq = res-data.irq.interrupts[0];
 
-   if (res-type == ACPI_RESOURCE_TYPE_IRQ) {
-   struct acpi_resource_irq *irqp;
-   irqp = res-data.irq;
-
-   *((unsigned int *)irq) = irqp-interrupts[0];
+   case ACPI_RESOURCE_TYPE_ADDRESS64:
+   hyperv_mmio_start = res-data.address64.minimum;
+   hyperv_mmio_size = res-data.address64.address_length;
}
 
return AE_OK;
@@ -906,18 +911,32 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *irq)
 static int vmbus_acpi_add(struct acpi_device *device)
 {
acpi_status result;
+   int ret_val = -ENODEV;
 
hv_acpi_dev = device;
 
result = acpi_walk_resources(device-handle, METHOD_NAME__CRS,
-   vmbus_walk_resources, irq);
+   vmbus_walk_resources, NULL);
 
-   if (ACPI_FAILURE(result)) {
-   complete(probe_event);
-   return -ENODEV;
+   if (ACPI_FAILURE(result))
+   goto acpi_walk_err;
+   /*
+* The parent of the vmbus acpi device (Gen2 firmware) is the VMOD that
+* has the mmio ranges. Get that.
+*/
+   if (device-parent) {
+   result = acpi_walk_resources(device-parent-handle,
+   METHOD_NAME__CRS,
+   vmbus_walk_resources, NULL);
+
+   if (ACPI_FAILURE(result))
+   goto acpi_walk_err;
}
+   ret_val = 0;
+
+acpi_walk_err:
complete(probe_event);
-   return 0;
+   return ret_val;
 }
 
 static const struct acpi_device_id vmbus_acpi_device_ids[] = {
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 344883d..be3028f 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1459,6 +1459,9 @@ int hv_vss_init(struct hv_util_service *);
 void hv_vss_deinit(void);
 void hv_vss_onchannelcallback(void *);
 
+extern u64 hyperv_mmio_start;
+extern u64 hyperv_mmio_size;
+
 /*
  * Negotiated version with the Host.
  */
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 2/5] vmbus: add missing breaks

2014-02-24 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/hv/vmbus_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index b37c91b..2352ae48 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -899,10 +899,12 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *ctx)
switch (res-type) {
case ACPI_RESOURCE_TYPE_IRQ:
irq = res-data.irq.interrupts[0];
+   break;
 
case ACPI_RESOURCE_TYPE_ADDRESS64:
hyperv_mmio_start = res-data.address64.minimum;
hyperv_mmio_size = res-data.address64.address_length;
+   break;
}
 
return AE_OK;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 3/5] vmbus: use resource for hyperv mmio region

2014-02-24 Thread Gerd Hoffmann
Use a resource for the hyperv mmio region instead of start/size
variables.  Register the region properly so it shows up in
/proc/iomem.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/hv/vmbus_drv.c | 16 ++--
 include/linux/hyperv.h |  3 +--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 2352ae48..a14f603 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -43,10 +43,12 @@ static struct acpi_device  *hv_acpi_dev;
 static struct tasklet_struct msg_dpc;
 static struct completion probe_event;
 static int irq;
-u64 hyperv_mmio_start;
-EXPORT_SYMBOL_GPL(hyperv_mmio_start);
-u64 hyperv_mmio_size;
-EXPORT_SYMBOL_GPL(hyperv_mmio_size);
+
+struct resource hyperv_mmio = {
+   .name  = hyperv mmio,
+   .flags = IORESOURCE_MEM,
+};
+EXPORT_SYMBOL_GPL(hyperv_mmio);
 
 static int vmbus_exists(void)
 {
@@ -902,8 +904,8 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *ctx)
break;
 
case ACPI_RESOURCE_TYPE_ADDRESS64:
-   hyperv_mmio_start = res-data.address64.minimum;
-   hyperv_mmio_size = res-data.address64.address_length;
+   hyperv_mmio.start = res-data.address64.minimum;
+   hyperv_mmio.end = res-data.address64.maximum;
break;
}
 
@@ -933,6 +935,8 @@ static int vmbus_acpi_add(struct acpi_device *device)
 
if (ACPI_FAILURE(result))
goto acpi_walk_err;
+   if (hyperv_mmio.start  hyperv_mmio.end)
+   request_resource(iomem_resource, hyperv_mmio);
}
ret_val = 0;
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index be3028f..c93e342 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1459,8 +1459,7 @@ int hv_vss_init(struct hv_util_service *);
 void hv_vss_deinit(void);
 void hv_vss_onchannelcallback(void *);
 
-extern u64 hyperv_mmio_start;
-extern u64 hyperv_mmio_size;
+extern struct resource hyperv_mmio;
 
 /*
  * Negotiated version with the Host.
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 4/5] hyperv-fb: add support for generation 2 virtual machines.

2014-02-24 Thread Gerd Hoffmann
UEFI-based generation 2 virtual machines support vmbus devices only.
There is no pci bus.  Thus they use a different mechanism for the
graphics framebuffer:  Instead of using the vga pci bar a chunk of
memory muct be allocated from the hyperv mmio region declared using
APCI.  This patch implements support for it.

Based on a patch by Haiyang Zhang haiya...@microsoft.com

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 86 +--
 1 file changed, 60 insertions(+), 26 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..ec4b22c 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -42,6 +42,7 @@
 #include linux/completion.h
 #include linux/fb.h
 #include linux/pci.h
+#include linux/efi.h
 
 #include linux/hyperv.h
 
@@ -212,6 +213,7 @@ struct synthvid_msg {
 
 struct hvfb_par {
struct fb_info *info;
+   struct resource mem;
bool fb_ready; /* fb device is ready */
struct completion wait;
u32 synthvid_version;
@@ -460,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;
 
@@ -627,26 +629,46 @@ 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;
-   ulong fb_phys;
+   struct hvfb_par *par = info-par;
+   struct pci_dev *pdev  = NULL;
void __iomem *fb_virt;
+   int gen2vm = efi_enabled(EFI_BOOT);
+   int ret;
 
-   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
+   par-mem.name = hyperv_fb;
+   par-mem.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+   if (gen2vm) {
+   ret = allocate_resource(hyperv_mmio, par-mem,
+   screen_fb_size,
+   0, -1,
+   screen_fb_size,
+   NULL, NULL);
+   if (ret != 0) {
+   pr_err(Unable to allocate framebuffer memory\n);
+   return -ENODEV;
+   }
+   } 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;
-   if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME))
-   goto err1;
+   par-mem.end = pci_resource_end(pdev, 0);
+   par-mem.start = par-mem.end - screen_fb_size + 1;
+   ret = request_resource(pdev-resource[0], par-mem);
+   if (ret != 0) {
+   pr_err(Unable to request framebuffer memory\n);
+   return -ENODEV;
+   }
+   }
 
-   fb_virt = ioremap(fb_phys, screen_fb_size);
+   fb_virt = ioremap(par-mem.start, screen_fb_size);
if (!fb_virt)
goto err2;
 
@@ -654,30 +676,42 @@ 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);
-   info-fix.smem_start = fb_phys;
+   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 = par-mem.start;
info-fix.smem_len = screen_fb_size;
info-screen_base = fb_virt;
info-screen_size = screen_fb_size

[PATCH v2 5/5] hyperv-fb: kick off efifb early

2014-02-24 Thread Gerd Hoffmann
Remove firmware framebuffer before initializing hyperv-fb.  Needed
on gen2 virtual machines.   Letting register_framebuffer handle the
switchover results in efifb still being active while hyperv graphics
are initialized, which in turn can make the linux kernel hang.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index ec4b22c..b425951 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -683,6 +683,7 @@ static int hvfb_getmem(struct fb_info *info)
info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
}
+   remove_conflicting_framebuffers(info-apertures, hyperv-fb, false);
 
info-fix.smem_start = par-mem.start;
info-fix.smem_len = screen_fb_size;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/5] vmbus: add missing breaks

2014-02-24 Thread Gerd Hoffmann
On Mo, 2014-02-24 at 13:42 +0300, Dan Carpenter wrote:
 I'm sorry, I know it sucks to not get credit for fixes, but please just
 fold this into [patch 1/5].  We really should have a tag for this kind
 of thing.

It's not because of the credits, but because Greg picked up #1 into one
of his branches already (cover letter explains this).  I'll happily
submit a v3 with 1+2 squashed together if that doesn't ruin the patch
workflow.  Greg?

cheers,
  Gerd


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/4] vmbus: add missing breaks

2014-02-24 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/hv/vmbus_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index b37c91b..2352ae48 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -899,10 +899,12 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *ctx)
switch (res-type) {
case ACPI_RESOURCE_TYPE_IRQ:
irq = res-data.irq.interrupts[0];
+   break;
 
case ACPI_RESOURCE_TYPE_ADDRESS64:
hyperv_mmio_start = res-data.address64.minimum;
hyperv_mmio_size = res-data.address64.address_length;
+   break;
}
 
return AE_OK;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 2/4] vmbus: use resource for hyperv mmio region

2014-02-24 Thread Gerd Hoffmann
Use a resource for the hyperv mmio region instead of start/size
variables.  Register the region properly so it shows up in
/proc/iomem.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/hv/vmbus_drv.c | 16 ++--
 include/linux/hyperv.h |  3 +--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 2352ae48..a14f603 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -43,10 +43,12 @@ static struct acpi_device  *hv_acpi_dev;
 static struct tasklet_struct msg_dpc;
 static struct completion probe_event;
 static int irq;
-u64 hyperv_mmio_start;
-EXPORT_SYMBOL_GPL(hyperv_mmio_start);
-u64 hyperv_mmio_size;
-EXPORT_SYMBOL_GPL(hyperv_mmio_size);
+
+struct resource hyperv_mmio = {
+   .name  = hyperv mmio,
+   .flags = IORESOURCE_MEM,
+};
+EXPORT_SYMBOL_GPL(hyperv_mmio);
 
 static int vmbus_exists(void)
 {
@@ -902,8 +904,8 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *ctx)
break;
 
case ACPI_RESOURCE_TYPE_ADDRESS64:
-   hyperv_mmio_start = res-data.address64.minimum;
-   hyperv_mmio_size = res-data.address64.address_length;
+   hyperv_mmio.start = res-data.address64.minimum;
+   hyperv_mmio.end = res-data.address64.maximum;
break;
}
 
@@ -933,6 +935,8 @@ static int vmbus_acpi_add(struct acpi_device *device)
 
if (ACPI_FAILURE(result))
goto acpi_walk_err;
+   if (hyperv_mmio.start  hyperv_mmio.end)
+   request_resource(iomem_resource, hyperv_mmio);
}
ret_val = 0;
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index be3028f..c93e342 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1459,8 +1459,7 @@ int hv_vss_init(struct hv_util_service *);
 void hv_vss_deinit(void);
 void hv_vss_onchannelcallback(void *);
 
-extern u64 hyperv_mmio_start;
-extern u64 hyperv_mmio_size;
+extern struct resource hyperv_mmio;
 
 /*
  * Negotiated version with the Host.
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 3/4] hyperv-fb: add support for generation 2 virtual machines.

2014-02-24 Thread Gerd Hoffmann
UEFI-based generation 2 virtual machines support vmbus devices only.
There is no pci bus.  Thus they use a different mechanism for the
graphics framebuffer:  Instead of using the vga pci bar a chunk of
memory muct be allocated from the hyperv mmio region declared using
APCI.  This patch implements support for it.

Based on a patch by Haiyang Zhang haiya...@microsoft.com

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 86 +--
 1 file changed, 60 insertions(+), 26 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..135d8cd 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -42,6 +42,7 @@
 #include linux/completion.h
 #include linux/fb.h
 #include linux/pci.h
+#include linux/efi.h
 
 #include linux/hyperv.h
 
@@ -212,6 +213,7 @@ struct synthvid_msg {
 
 struct hvfb_par {
struct fb_info *info;
+   struct resource mem;
bool fb_ready; /* fb device is ready */
struct completion wait;
u32 synthvid_version;
@@ -460,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;
 
@@ -627,26 +629,46 @@ 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;
-   ulong fb_phys;
+   struct hvfb_par *par = info-par;
+   struct pci_dev *pdev  = NULL;
void __iomem *fb_virt;
+   int gen2vm = efi_enabled(EFI_BOOT);
+   int ret;
 
-   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
+   par-mem.name = hyperv_fb;
+   par-mem.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+   if (gen2vm) {
+   ret = allocate_resource(hyperv_mmio, par-mem,
+   screen_fb_size,
+   0, -1,
+   screen_fb_size,
+   NULL, NULL);
+   if (ret != 0) {
+   pr_err(Unable to allocate framebuffer memory\n);
+   return -ENODEV;
+   }
+   } 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;
-   if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME))
-   goto err1;
+   par-mem.end = pci_resource_end(pdev, 0);
+   par-mem.start = par-mem.end - screen_fb_size + 1;
+   ret = request_resource(pdev-resource[0], par-mem);
+   if (ret != 0) {
+   pr_err(Unable to request framebuffer memory\n);
+   goto err1;
+   }
+   }
 
-   fb_virt = ioremap(fb_phys, screen_fb_size);
+   fb_virt = ioremap(par-mem.start, screen_fb_size);
if (!fb_virt)
goto err2;
 
@@ -654,30 +676,42 @@ 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);
-   info-fix.smem_start = fb_phys;
+   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 = par-mem.start;
info-fix.smem_len = screen_fb_size;
info-screen_base = fb_virt;
info-screen_size = screen_fb_size;
 
-   pci_dev_put

[PATCH v3 4/4] hyperv-fb: kick off efifb early

2014-02-24 Thread Gerd Hoffmann
Remove firmware framebuffer before initializing hyperv-fb.  Needed
on gen2 virtual machines.   Letting register_framebuffer handle the
switchover results in efifb still being active while hyperv graphics
are initialized, which in turn can make the linux kernel hang.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 135d8cd..a570836 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -683,6 +683,7 @@ static int hvfb_getmem(struct fb_info *info)
info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
}
+   remove_conflicting_framebuffers(info-apertures, hyperv-fb, false);
 
info-fix.smem_start = par-mem.start;
info-fix.smem_len = screen_fb_size;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 0/4] hyperv-fb: add support for generation 2 virtual machines.

2014-02-24 Thread Gerd Hoffmann
  Hi,

This patch series adds support for uefi-based gen2 virtual machines to
the hyperv-fb driver.  It depends on -next commit
90f3453585479d5beb75058da46eb573ced0e6ac

Patch #1 is a bugfix for 90f3453585479d5beb75058da46eb573ced0e6ac.

Patch #2 changes vmbus to properly hook the hyperv mmio area into
the linux resource management.

Patch #3 actually implements gen2 vm support for hyperv-fb, building
on the hyperv mmio support added by the other patches.

Patch #4 unregisters efifb early to make sure the framebuffer isn't used
any more while hyperv-fb initialization is in progress.  This patch is
new in v2 and it fixes the hang listed as known issue in v1 of this
patch series.

v3 changes:
 - fix a error handling bug in patch #3.
 - don't include 90f3453585479d5beb75058da46eb573ced0e6ac
   to avoid confusion

please apply,
  Gerd

Gerd Hoffmann (4):
  vmbus: add missing breaks
  vmbus: use resource for hyperv mmio region
  hyperv-fb: add support for generation 2 virtual machines.
  hyperv-fb: kick off efifb early

K. Y. Srinivasan (1):
  Drivers: hv: vmbus: Extract the mmio information from DSDT

 drivers/hv/vmbus_drv.c| 51 ---
 drivers/video/hyperv_fb.c | 87 +--
 include/linux/hyperv.h|  2 ++
 3 files changed, 101 insertions(+), 39 deletions(-)

-- 
1.8.3.1


Gerd Hoffmann (4):
  vmbus: add missing breaks
  vmbus: use resource for hyperv mmio region
  hyperv-fb: add support for generation 2 virtual machines.
  hyperv-fb: kick off efifb early

 drivers/hv/vmbus_drv.c| 18 ++
 drivers/video/hyperv_fb.c | 87 +--
 include/linux/hyperv.h|  3 +-
 3 files changed, 74 insertions(+), 34 deletions(-)

-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] vmbus: add missing breaks

2014-02-21 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/hv/vmbus_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index b37c91b..2352ae48 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -899,10 +899,12 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *ctx)
switch (res-type) {
case ACPI_RESOURCE_TYPE_IRQ:
irq = res-data.irq.interrupts[0];
+   break;
 
case ACPI_RESOURCE_TYPE_ADDRESS64:
hyperv_mmio_start = res-data.address64.minimum;
hyperv_mmio_size = res-data.address64.address_length;
+   break;
}
 
return AE_OK;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] Drivers: hv: vmbus: Extract the mmio information from DSDT

2014-02-21 Thread Gerd Hoffmann
From: K. Y. Srinivasan k...@microsoft.com

On Gen2 firmware, Hyper-V does not emulate the PCI bus. However, the MMIO
information is packaged up in DSDT. Extract this information and export it
for use by the synthetic framebuffer driver. This is the only driver that
needs this currently.

In this version of the patch mmio, I have updated the hyperv header file
(linux/hyperv.h) with mmio definitions.

Signed-off-by: K. Y. Srinivasan k...@microsoft.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/hv/vmbus_drv.c | 45 -
 include/linux/hyperv.h |  3 +++
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 077bb1b..b37c91b 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -43,6 +43,10 @@ static struct acpi_device  *hv_acpi_dev;
 static struct tasklet_struct msg_dpc;
 static struct completion probe_event;
 static int irq;
+u64 hyperv_mmio_start;
+EXPORT_SYMBOL_GPL(hyperv_mmio_start);
+u64 hyperv_mmio_size;
+EXPORT_SYMBOL_GPL(hyperv_mmio_size);
 
 static int vmbus_exists(void)
 {
@@ -886,18 +890,19 @@ void vmbus_device_unregister(struct hv_device *device_obj)
 
 
 /*
- * VMBUS is an acpi enumerated device. Get the the IRQ information
- * from DSDT.
+ * VMBUS is an acpi enumerated device. Get the the information we
+ * need from DSDT.
  */
 
-static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *irq)
+static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *ctx)
 {
+   switch (res-type) {
+   case ACPI_RESOURCE_TYPE_IRQ:
+   irq = res-data.irq.interrupts[0];
 
-   if (res-type == ACPI_RESOURCE_TYPE_IRQ) {
-   struct acpi_resource_irq *irqp;
-   irqp = res-data.irq;
-
-   *((unsigned int *)irq) = irqp-interrupts[0];
+   case ACPI_RESOURCE_TYPE_ADDRESS64:
+   hyperv_mmio_start = res-data.address64.minimum;
+   hyperv_mmio_size = res-data.address64.address_length;
}
 
return AE_OK;
@@ -906,18 +911,32 @@ static acpi_status vmbus_walk_resources(struct 
acpi_resource *res, void *irq)
 static int vmbus_acpi_add(struct acpi_device *device)
 {
acpi_status result;
+   int ret_val = -ENODEV;
 
hv_acpi_dev = device;
 
result = acpi_walk_resources(device-handle, METHOD_NAME__CRS,
-   vmbus_walk_resources, irq);
+   vmbus_walk_resources, NULL);
 
-   if (ACPI_FAILURE(result)) {
-   complete(probe_event);
-   return -ENODEV;
+   if (ACPI_FAILURE(result))
+   goto acpi_walk_err;
+   /*
+* The parent of the vmbus acpi device (Gen2 firmware) is the VMOD that
+* has the mmio ranges. Get that.
+*/
+   if (device-parent) {
+   result = acpi_walk_resources(device-parent-handle,
+   METHOD_NAME__CRS,
+   vmbus_walk_resources, NULL);
+
+   if (ACPI_FAILURE(result))
+   goto acpi_walk_err;
}
+   ret_val = 0;
+
+acpi_walk_err:
complete(probe_event);
-   return 0;
+   return ret_val;
 }
 
 static const struct acpi_device_id vmbus_acpi_device_ids[] = {
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 344883d..be3028f 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1459,6 +1459,9 @@ int hv_vss_init(struct hv_util_service *);
 void hv_vss_deinit(void);
 void hv_vss_onchannelcallback(void *);
 
+extern u64 hyperv_mmio_start;
+extern u64 hyperv_mmio_size;
+
 /*
  * Negotiated version with the Host.
  */
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] hyperv-fb: add support for generation 2 virtual machines.

2014-02-21 Thread Gerd Hoffmann
UEFI-based generation 2 virtual machines support vmbus devices only.
There is no pci bus.  Thus they use a different mechanism for the
graphics framebuffer:  Instead of using the vga pci bar a chunk of
memory muct be allocated from the hyperv mmio region declared using
APCI.  This patch implements support for it.

Based on a patch by Haiyang Zhang haiya...@microsoft.com

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 86 +--
 1 file changed, 60 insertions(+), 26 deletions(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 130708f..f956cd9 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -42,6 +42,7 @@
 #include linux/completion.h
 #include linux/fb.h
 #include linux/pci.h
+#include linux/efi.h
 
 #include linux/hyperv.h
 
@@ -212,6 +213,7 @@ struct synthvid_msg {
 
 struct hvfb_par {
struct fb_info *info;
+   struct resource mem;
bool fb_ready; /* fb device is ready */
struct completion wait;
u32 synthvid_version;
@@ -460,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;
 
@@ -627,26 +629,46 @@ 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;
-   ulong fb_phys;
+   struct hvfb_par *par = info-par;
+   struct pci_dev *pdev  = NULL;
void __iomem *fb_virt;
+   bool gen2vm = efi_enabled(EFI_BOOT);
+   int ret;
 
-   pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
+   par-mem.name = hyperv_fb;
+   par-mem.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+   if (gen2vm) {
+   ret = allocate_resource(hyperv_mmio, par-mem,
+   screen_fb_size,
+   0, -1,
+   screen_fb_size,
+   NULL, NULL);
+   if (ret != 0) {
+   pr_err(Unable to allocate framebuffer memory\n);
+   return -ENODEV;
+   }
+   } 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;
-   if (!request_mem_region(fb_phys, screen_fb_size, KBUILD_MODNAME))
-   goto err1;
+   par-mem.end = pci_resource_end(pdev, 0);
+   par-mem.start = par-mem.end - screen_fb_size + 1;
+   ret = request_resource(pdev-resource[0], par-mem);
+   if (ret != 0) {
+   pr_err(Unable to request framebuffer memory\n);
+   return -ENODEV;
+   }
+   }
 
-   fb_virt = ioremap(fb_phys, screen_fb_size);
+   fb_virt = ioremap(par-mem.start, screen_fb_size);
if (!fb_virt)
goto err2;
 
@@ -654,30 +676,42 @@ 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);
-   info-fix.smem_start = fb_phys;
+   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 = par-mem.start;
info-fix.smem_len = screen_fb_size;
info-screen_base = fb_virt;
info-screen_size = screen_fb_size

[PATCH] hyperv-fb: kick off efifb early

2014-02-21 Thread Gerd Hoffmann
Remove firmware framebuffer before initializing hyperv-fb.  Needed
on gen2 virtual machines.   Letting register_framebuffer handle the
switchover results in efifb still being active while hyperv graphics
are initialized, which in turn can make the linux kernel hang.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index f956cd9..3901ffe 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -683,6 +683,7 @@ static int hvfb_getmem(struct fb_info *info)
info-apertures-ranges[0].base = pci_resource_start(pdev, 0);
info-apertures-ranges[0].size = pci_resource_len(pdev, 0);
}
+   remove_conflicting_framebuffers(info-apertures, hyperv-fb, false);
 
info-fix.smem_start = par-mem.start;
info-fix.smem_len = screen_fb_size;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] hyperv-fb: add pci stub

2013-10-08 Thread Gerd Hoffmann
On Mo, 2013-10-07 at 17:12 +, KY Srinivasan wrote:
 
  -Original Message-
  From: Gerd Hoffmann [mailto:kra...@redhat.com]
  Sent: Sunday, October 06, 2013 11:51 PM
  To: KY Srinivasan
  Cc: Haiyang Zhang; Jean-Christophe Plagniol-Villard; Tomi Valkeinen; open
  list:Hyper-V CORE AND...; open list:FRAMEBUFFER LAYER; open list
  Subject: Re: [PATCH 1/2] hyperv-fb: add pci stub
  
  On Mi, 2013-10-02 at 14:29 +, KY Srinivasan wrote:
  
This patch adds a pci stub driver to hyper-fb.  The hyperv framebuffer
driver will bind to the pci device then, so linux kernel and userspace
know there is a proper kernel driver for the device active.  lspci shows
this for example:
  
   Gerd,
  
   Thanks for doing this. This certainly will address some of the issues 
   that are
  reported. I do have a question though - how would this work if we don't 
  have PCI
  bus in the guest.
  
  The hyperv framebuffer driver wouldn't work in the first place then as
  it looks up the framebuffer address in pci config space (see hvfb_getmem
  function).
 
 We are going to fix this as we move this code to run on our UEFI firmware. 

Hmm, windows server 2012 seems to have no option to enable uefi.  So I
guess this is still in development?  How this is going to look like?

Probably you are going for pure uefi firmware, without csm, to be able
to leave all the legacy bios stuff behind in uefi mode.  Therefore no
vesa bios support.  efi drivers for vmbus network/storage/display/input
in the firmware.  No legacy ide/vga pci devices.  Correct?

The linux kernel will come up with efifb then, switching over to
hyperv-fb once the driver is loaded.  The hyperv-fb pci stub driver will
not bind to the hyperv vga pci device if it isn't present in the guest.
hyperv-fb will load just fine nevertheless (once hvfb_getmem is fixed to
not depend on the pci device config space).  The pci stub added by the
patch and the vmbus driver in hyperv-fb are completely independent.

cheers,
  Gerd


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] hyperv-fb: add pci stub

2013-10-07 Thread Gerd Hoffmann
On Mi, 2013-10-02 at 14:29 +, KY Srinivasan wrote:
 
  This patch adds a pci stub driver to hyper-fb.  The hyperv framebuffer
  driver will bind to the pci device then, so linux kernel and userspace
  know there is a proper kernel driver for the device active.  lspci shows
  this for example:

 Gerd,
 
 Thanks for doing this. This certainly will address some of the issues that 
 are reported. I do have a question though - how would this work if we don't 
 have PCI bus in the guest.

The hyperv framebuffer driver wouldn't work in the first place then as
it looks up the framebuffer address in pci config space (see hvfb_getmem
function).

cheers,
  Gerd



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] hyperv-fb: add pci stub

2013-10-02 Thread Gerd Hoffmann
This patch adds a pci stub driver to hyper-fb.  The hyperv framebuffer
driver will bind to the pci device then, so linux kernel and userspace
know there is a proper kernel driver for the device active.  lspci shows
this for example:

[root@dhcp231 ~]# lspci -vs8
00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual
VGA (prog-if 00 [VGA controller])
Flags: bus master, fast devsel, latency 0, IRQ 11
Memory at f800 (32-bit, non-prefetchable) [size=64M]
Expansion ROM at unassigned [disabled]
Kernel driver in use: hyperv_fb

Another effect is that the xorg vesa driver will not attach to the
device and thus the Xorg server will automatically use the fbdev
driver instead.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 drivers/video/hyperv_fb.c | 40 +++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
index 8ac99b8..8d456dc 100644
--- a/drivers/video/hyperv_fb.c
+++ b/drivers/video/hyperv_fb.c
@@ -795,12 +795,21 @@ static int hvfb_remove(struct hv_device *hdev)
 }
 
 
+static DEFINE_PCI_DEVICE_TABLE(pci_stub_id_table) = {
+   {
+   .vendor  = PCI_VENDOR_ID_MICROSOFT,
+   .device  = PCI_DEVICE_ID_HYPERV_VIDEO,
+   },
+   { /* end of list */ }
+};
+
 static const struct hv_vmbus_device_id id_table[] = {
/* Synthetic Video Device GUID */
{HV_SYNTHVID_GUID},
{}
 };
 
+MODULE_DEVICE_TABLE(pci, pci_stub_id_table);
 MODULE_DEVICE_TABLE(vmbus, id_table);
 
 static struct hv_driver hvfb_drv = {
@@ -810,14 +819,43 @@ static struct hv_driver hvfb_drv = {
.remove = hvfb_remove,
 };
 
+static int hvfb_pci_stub_probe(struct pci_dev *pdev,
+  const struct pci_device_id *ent)
+{
+   return 0;
+}
+
+static void hvfb_pci_stub_remove(struct pci_dev *pdev)
+{
+}
+
+static struct pci_driver hvfb_pci_stub_driver = {
+   .name = KBUILD_MODNAME,
+   .id_table = pci_stub_id_table,
+   .probe =hvfb_pci_stub_probe,
+   .remove =   hvfb_pci_stub_remove,
+};
 
 static int __init hvfb_drv_init(void)
 {
-   return vmbus_driver_register(hvfb_drv);
+   int ret;
+
+   ret = vmbus_driver_register(hvfb_drv);
+   if (ret != 0)
+   return ret;
+
+   ret = pci_register_driver(hvfb_pci_stub_driver);
+   if (ret != 0) {
+   vmbus_driver_unregister(hvfb_drv);
+   return ret;
+   }
+
+   return 0;
 }
 
 static void __exit hvfb_drv_exit(void)
 {
+   pci_unregister_driver(hvfb_pci_stub_driver);
vmbus_driver_unregister(hvfb_drv);
 }
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel