From: Sascha Hauer <sha@pengutronix.de>
To: "Daniel Brát" <danek.brat@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] video: Fix broken bcm2835 fb driver
Date: Mon, 4 Oct 2021 12:51:06 +0200 [thread overview]
Message-ID: <20211004105106.GT28453@pengutronix.de> (raw)
In-Reply-To: <20210907072915.18451-1-danek.brat@gmail.com>
On Tue, Sep 07, 2021 at 09:29:15AM +0200, Daniel Brát wrote:
> The bcm2835 framebuffer driver was broken, because the address of video
> buffer allocated for us by the GPU and returned through mailbox was
> used without converting it back to ARM address space. That unconverted
> address was also in the range of peripheral addresses, which caused
> other issues later on due to it being filled with garbage data.
> The offset by which to convert the address back can vary by device,
> so the value is read from devicetree 'dma-ranges' for somewhat portable
> operation.
> This fix was tested on Raspberry PI B+ and Raspberry PI 3B+.
>
> Signed-off-by: Daniel Brát <danek.brat@gmail.com>
> ---
> drivers/video/bcm2835.c | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
Applied with Rolands remarks, thanks
Sascha
>
> diff --git a/drivers/video/bcm2835.c b/drivers/video/bcm2835.c
> index d808bc5c9..2ebe912d0 100644
> --- a/drivers/video/bcm2835.c
> +++ b/drivers/video/bcm2835.c
> @@ -14,6 +14,7 @@
> #include <malloc.h>
> #include <xfuncs.h>
>
> +#include <of_address.h>
> #include <mach/mbox.h>
>
> struct bcm2835fb_info {
> @@ -58,9 +59,24 @@ static int bcm2835fb_probe(struct device_d *dev)
> BCM2835_MBOX_STACK_ALIGN(struct msg_fb_query, msg_query);
> BCM2835_MBOX_STACK_ALIGN(struct msg_fb_setup, msg_setup);
> struct bcm2835fb_info *info;
> + struct device_node *soc;
> u32 w, h;
> + u64 dma_addr, cpu_addr, _region_size;
> + phys_addr_t buffer_addr;
> int ret;
>
> + soc = of_find_node_by_path("/soc");
> + if (!soc) {
> + dev_err(dev, "could not find required of node /soc\n");
> + return -ENODEV;
> + }
> +
> + ret = of_dma_get_range(soc, &dma_addr, &cpu_addr, &_region_size);
> + if (ret) {
> + dev_err(dev, "of node /soc has no dma-ranges\n");
> + return ret;
> + }
> +
> BCM2835_MBOX_INIT_HDR(msg_query);
> BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_query->physical_w_h,
> GET_PHYSICAL_W_H);
> @@ -99,10 +115,11 @@ static int bcm2835fb_probe(struct device_d *dev)
> return ret;
> }
>
> + buffer_addr = (msg_setup->allocate_buffer.body.resp.fb_address & ~dma_addr) + cpu_addr;
> +
> info = xzalloc(sizeof *info);
> info->fbi.fbops = &bcm2835fb_ops;
> - info->fbi.screen_base =
> - (void *)msg_setup->allocate_buffer.body.resp.fb_address;
> + info->fbi.screen_base = phys_to_virt(buffer_addr);
> info->fbi.xres = msg_setup->physical_w_h.body.resp.width;
> info->fbi.yres = msg_setup->physical_w_h.body.resp.height;
> info->fbi.bits_per_pixel = 16;
> --
> 2.17.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2021-10-04 10:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 7:29 Daniel Brát
2021-09-08 18:36 ` Roland Hieber
2021-10-04 10:51 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211004105106.GT28453@pengutronix.de \
--to=sha@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=danek.brat@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox