Skip to content

Vchiq cache #2666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions arch/arm/boot/dts/bcm2708-rpi.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
usb = &usb;
leds = &leds;
fb = &fb;
vchiq = &vchiq;
thermal = &thermal;
axiperf = &axiperf;
};
Expand Down Expand Up @@ -67,12 +66,10 @@
status = "disabled";
};

vchiq: vchiq {
mailbox@7e00b840 {
compatible = "brcm,bcm2835-vchiq";
reg = <0x7e00b840 0xf>;
reg = <0x7e00b840 0x3c>;
interrupts = <0 2>;
cache-line-size = <32>;
firmware = <&firmware>;
};

vcsm: vcsm {
Expand All @@ -95,7 +92,7 @@
};

__overrides__ {
cache_line_size = <&vchiq>, "cache-line-size:0";
cache_line_size;

uart0 = <&uart0>,"status";
uart1 = <&uart1>,"status";
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/bcm2835-rpi.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

mailbox@7e00b840 {
compatible = "brcm,bcm2835-vchiq";
reg = <0x7e00b840 0xf>;
reg = <0x7e00b840 0x3c>;
interrupts = <0 2>;
};
};
Expand Down
34 changes: 25 additions & 9 deletions drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <linux/uaccess.h>
#include <linux/mm.h>
#include <linux/of.h>
#include <asm/cputype.h>
#include <soc/bcm2835/raspberrypi-firmware.h>

#define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32)
Expand Down Expand Up @@ -77,7 +78,19 @@ struct vchiq_pagelist_info {
};

static void __iomem *g_regs;
static unsigned int g_cache_line_size = sizeof(CACHE_LINE_SIZE);
/* This value is the size of the L2 cache lines as understood by the
* VPU firmware, which determines the required alignment of the
* offsets/sizes in pagelists.
*
* Previous VPU firmware looked for a DT "cache-line-size" property in
* the VCHIQ node and would overwrite it with the actual L2 cache size,
* which the kernel must then respect. That property was rejected
* upstream, so we now rely on both sides to "do the right thing" independently
* of the other. To improve backwards compatibility, this new behaviour is
* signalled to the firmware by the use of a corrected "reg" property on the
* relevant Device Tree node.
*/
static unsigned int g_cache_line_size;
static unsigned int g_fragments_size;
static char *g_fragments_base;
static char *g_free_fragments;
Expand Down Expand Up @@ -117,14 +130,17 @@ int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state)
if (err < 0)
return err;

err = of_property_read_u32(dev->of_node, "cache-line-size",
&g_cache_line_size);

if (err) {
dev_err(dev, "Missing cache-line-size property\n");
return -ENODEV;
}

/*
* The tempting L1_CACHE_BYTES macro doesn't work in the case of
* a kernel built with bcm2835_defconfig running on a BCM2836/7
* processor, hence the need for a runtime check. The dcache line size
* is encoded in one of the coprocessor registers, but there is no
* convenient way to access it short of embedded assembler, hence
* the use of read_cpuid_id(). The following test evaluates to true
* on a BCM2835 showing that it is ARMv6-ish, whereas
* cpu_architecture() will indicate that it is an ARMv7.
*/
g_cache_line_size = ((read_cpuid_id() & 0x7f000) == 0x7b000) ? 32 : 64;
g_fragments_size = 2 * g_cache_line_size;

/* Allocate space for the channels in coherent memory */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#ifndef VCHIQ_PAGELIST_H
#define VCHIQ_PAGELIST_H

#define CACHE_LINE_SIZE 32
#define PAGELIST_WRITE 0
#define PAGELIST_READ 1
#define PAGELIST_READ_WITH_FRAGMENTS 2
Expand Down