From: popcornmix Date: Thu, 4 May 2017 16:38:22 +0000 (+0100) Subject: bcm2708_fb: Avoid firmware mbox call in vc_mem_copy X-Git-Tag: archive/raspbian/4.9.82-1+deb9u3+rpi1_jessie~5^2~240 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=db96fc33a15832b86dd4215b2f1732e2bf575117;p=linux-4.9.git bcm2708_fb: Avoid firmware mbox call in vc_mem_copy If firmware has locked up it is useful to get vcdbg log out without a firmware mbox response. Issue the mbox call at probe time instead. Signed-off-by: popcornmix --- diff --git a/drivers/video/fbdev/bcm2708_fb.c b/drivers/video/fbdev/bcm2708_fb.c index 53c5a0bdadb4..612293cf9f1b 100644 --- a/drivers/video/fbdev/bcm2708_fb.c +++ b/drivers/video/fbdev/bcm2708_fb.c @@ -96,6 +96,7 @@ struct bcm2708_fb { wait_queue_head_t dma_waitq; struct bcm2708_fb_stats stats; unsigned long fb_bus_address; + struct { u32 base, length; } gpu; }; #define to_bcm2708(info) container_of(info, struct bcm2708_fb, fb) @@ -472,7 +473,6 @@ static long vc_mem_copy(struct bcm2708_fb *fb, unsigned long arg) dma_addr_t bus_addr; long rc = 0; size_t offset; - struct { u32 base, length; } gpu = {}; /* restrict this to root user */ if (!uid_eq(current_euid(), GLOBAL_ROOT_UID)) @@ -491,16 +491,13 @@ static long vc_mem_copy(struct bcm2708_fb *fb, unsigned long arg) goto out; } - rc = rpi_firmware_property(fb->fw, - RPI_FIRMWARE_GET_VC_MEMORY, - &gpu, sizeof(gpu)); - if (rc != 0 || gpu.base == 0 || gpu.length == 0) { - pr_err("[%s]: Unable to determine gpu memory %ld,%x,%x)\n", __func__, rc, gpu.base, gpu.length); + if (fb->gpu.base == 0 || fb->gpu.length == 0) { + pr_err("[%s]: Unable to determine gpu memory (%x,%x)\n", __func__, fb->gpu.base, fb->gpu.length); return -EFAULT; } - if (INTALIAS_NORMAL(ioparam.src) < gpu.base || INTALIAS_NORMAL(ioparam.src) >= gpu.base + gpu.length) { - pr_err("[%s]: Invalid memory access %x (%x-%x)", __func__, INTALIAS_NORMAL(ioparam.src), gpu.base, gpu.base + gpu.length); + if (INTALIAS_NORMAL(ioparam.src) < fb->gpu.base || INTALIAS_NORMAL(ioparam.src) >= fb->gpu.base + fb->gpu.length) { + pr_err("[%s]: Invalid memory access %x (%x-%x)", __func__, INTALIAS_NORMAL(ioparam.src), fb->gpu.base, fb->gpu.base + fb->gpu.length); return -EFAULT; } @@ -869,6 +866,11 @@ static int bcm2708_fb_probe(struct platform_device *dev) fb->dev = dev; fb->fb.device = &dev->dev; + // failure here isn't fatal, but we'll fail in vc_mem_copy if fb->gpu is not valid + rpi_firmware_property(fb->fw, + RPI_FIRMWARE_GET_VC_MEMORY, + &fb->gpu, sizeof(fb->gpu)); + ret = bcm2708_fb_register(fb); if (ret == 0) { platform_set_drvdata(dev, fb);