Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'arm-soc/for-4.21/drivers' of https://github.com/Broadcom/stblinux into next/drivers

This pull request contains Broadcom ARM/ARM64/MIPS SoCs drivers changes
for 4.21, please pull the following changes:

- James fixes the firmware interface after a commit changed the use of
VLA and broke large transfers

- Stefan adds a timeout check for Raspberry Pi firmware transactions and
updates a bunch of SoC/firmware files to use SPDX tags

- Wolfram switches the GISB bus arbiter to use dev_get_drvdata()

- Yangtao provides a fix for a reference leak due to a call to
of_find_node_by_path()

- Florian fixes the CPU re-entry point out of S3 suspend with kernels
built in Thumb2 mode

* tag 'arm-soc/for-4.21/drivers' of https://github.com/Broadcom/stblinux:
soc: bcm: brcmstb: Don't leak device tree node reference
firmware: raspberrypi: Switch to SPDX identifier
firmware: raspberrypi: Fix firmware calls with large buffers
soc: bcm: Switch raspberrypi-power to SPDX identifier
firmware: raspberrypi: Define timeout for transactions
bus: brcmstb_gisb: simplify getting .driver_data
soc: bcm: brcmstb: Fix re-entry point with a THUMB2_KERNEL

Signed-off-by: Olof Johansson <olof@lixom.net>

+38 -45
+4 -8
drivers/bus/brcmstb_gisb.c
··· 150 150 struct device_attribute *attr, 151 151 char *buf) 152 152 { 153 - struct platform_device *pdev = to_platform_device(dev); 154 - struct brcmstb_gisb_arb_device *gdev = platform_get_drvdata(pdev); 153 + struct brcmstb_gisb_arb_device *gdev = dev_get_drvdata(dev); 155 154 u32 timeout; 156 155 157 156 mutex_lock(&gdev->lock); ··· 164 165 struct device_attribute *attr, 165 166 const char *buf, size_t count) 166 167 { 167 - struct platform_device *pdev = to_platform_device(dev); 168 - struct brcmstb_gisb_arb_device *gdev = platform_get_drvdata(pdev); 168 + struct brcmstb_gisb_arb_device *gdev = dev_get_drvdata(dev); 169 169 int val, ret; 170 170 171 171 ret = kstrtoint(buf, 10, &val); ··· 416 418 #ifdef CONFIG_PM_SLEEP 417 419 static int brcmstb_gisb_arb_suspend(struct device *dev) 418 420 { 419 - struct platform_device *pdev = to_platform_device(dev); 420 - struct brcmstb_gisb_arb_device *gdev = platform_get_drvdata(pdev); 421 + struct brcmstb_gisb_arb_device *gdev = dev_get_drvdata(dev); 421 422 422 423 gdev->saved_timeout = gisb_read(gdev, ARB_TIMER); 423 424 ··· 428 431 */ 429 432 static int brcmstb_gisb_arb_resume_noirq(struct device *dev) 430 433 { 431 - struct platform_device *pdev = to_platform_device(dev); 432 - struct brcmstb_gisb_arb_device *gdev = platform_get_drvdata(pdev); 434 + struct brcmstb_gisb_arb_device *gdev = dev_get_drvdata(dev); 433 435 434 436 gisb_write(gdev, gdev->saved_timeout, ARB_TIMER); 435 437
+25 -23
drivers/firmware/raspberrypi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Defines interfaces for interacting wtih the Raspberry Pi firmware's 3 4 * property channel. 4 5 * 5 6 * Copyright © 2015 Broadcom 6 - * 7 - * This program is free software; you can redistribute it and/or modify 8 - * it under the terms of the GNU General Public License version 2 as 9 - * published by the Free Software Foundation. 10 7 */ 11 8 12 9 #include <linux/dma-mapping.h> ··· 11 14 #include <linux/module.h> 12 15 #include <linux/of_platform.h> 13 16 #include <linux/platform_device.h> 17 + #include <linux/slab.h> 14 18 #include <soc/bcm2835/raspberrypi-firmware.h> 15 19 16 20 #define MBOX_MSG(chan, data28) (((data28) & ~0xf) | ((chan) & 0xf)) 17 21 #define MBOX_CHAN(msg) ((msg) & 0xf) 18 22 #define MBOX_DATA28(msg) ((msg) & ~0xf) 19 23 #define MBOX_CHAN_PROPERTY 8 20 - 21 - #define MAX_RPI_FW_PROP_BUF_SIZE 32 22 24 23 25 static struct platform_device *rpi_hwmon; 24 26 ··· 52 56 reinit_completion(&fw->c); 53 57 ret = mbox_send_message(fw->chan, &message); 54 58 if (ret >= 0) { 55 - wait_for_completion(&fw->c); 56 - ret = 0; 59 + if (wait_for_completion_timeout(&fw->c, HZ)) { 60 + ret = 0; 61 + } else { 62 + ret = -ETIMEDOUT; 63 + WARN_ONCE(1, "Firmware transaction timeout"); 64 + } 57 65 } else { 58 66 dev_err(fw->cl.dev, "mbox_send_message returned %d\n", ret); 59 67 } ··· 144 144 int rpi_firmware_property(struct rpi_firmware *fw, 145 145 u32 tag, void *tag_data, size_t buf_size) 146 146 { 147 - /* Single tags are very small (generally 8 bytes), so the 148 - * stack should be safe. 149 - */ 150 - u8 data[sizeof(struct rpi_firmware_property_tag_header) + 151 - MAX_RPI_FW_PROP_BUF_SIZE]; 152 - struct rpi_firmware_property_tag_header *header = 153 - (struct rpi_firmware_property_tag_header *)data; 147 + struct rpi_firmware_property_tag_header *header; 154 148 int ret; 155 149 156 - if (WARN_ON(buf_size > sizeof(data) - sizeof(*header))) 157 - return -EINVAL; 150 + /* Some mailboxes can use over 1k bytes. Rather than checking 151 + * size and using stack or kmalloc depending on requirements, 152 + * just use kmalloc. Mailboxes don't get called enough to worry 153 + * too much about the time taken in the allocation. 154 + */ 155 + void *data = kmalloc(sizeof(*header) + buf_size, GFP_KERNEL); 158 156 157 + if (!data) 158 + return -ENOMEM; 159 + 160 + header = data; 159 161 header->tag = tag; 160 162 header->buf_size = buf_size; 161 163 header->req_resp_size = 0; 162 - memcpy(data + sizeof(struct rpi_firmware_property_tag_header), 163 - tag_data, buf_size); 164 + memcpy(data + sizeof(*header), tag_data, buf_size); 164 165 165 - ret = rpi_firmware_property_list(fw, &data, buf_size + sizeof(*header)); 166 - memcpy(tag_data, 167 - data + sizeof(struct rpi_firmware_property_tag_header), 168 - buf_size); 166 + ret = rpi_firmware_property_list(fw, data, buf_size + sizeof(*header)); 167 + 168 + memcpy(tag_data, data + sizeof(*header), buf_size); 169 + 170 + kfree(data); 169 171 170 172 return ret; 171 173 }
+5 -1
drivers/soc/bcm/brcmstb/common.c
··· 31 31 32 32 bool soc_is_brcmstb(void) 33 33 { 34 + const struct of_device_id *match; 34 35 struct device_node *root; 35 36 36 37 root = of_find_node_by_path("/"); 37 38 if (!root) 38 39 return false; 39 40 40 - return of_match_node(brcmstb_machine_match, root) != NULL; 41 + match = of_match_node(brcmstb_machine_match, root); 42 + of_node_put(root); 43 + 44 + return match != NULL; 41 45 } 42 46 43 47 u32 brcmstb_get_family_id(void)
+1 -1
drivers/soc/bcm/brcmstb/pm/pm-arm.c
··· 404 404 { 405 405 struct brcmstb_s3_params *params = ctrl.s3_params; 406 406 dma_addr_t params_pa = ctrl.s3_params_pa; 407 - phys_addr_t reentry = virt_to_phys(&cpu_resume); 407 + phys_addr_t reentry = virt_to_phys(&cpu_resume_arm); 408 408 enum bsp_initiate_command cmd; 409 409 u32 flags; 410 410
+1 -4
drivers/soc/bcm/raspberrypi-power.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* (C) 2015 Pengutronix, Alexander Aring <aar@pengutronix.de> 2 - * 3 - * This program is free software; you can redistribute it and/or modify 4 - * it under the terms of the GNU General Public License version 2 as 5 - * published by the Free Software Foundation. 6 3 * 7 4 * Authors: 8 5 * Alexander Aring <aar@pengutronix.de>
+1 -4
include/dt-bindings/power/raspberrypi-power.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright © 2015 Broadcom 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 as 6 - * published by the Free Software Foundation. 7 4 */ 8 5 9 6 #ifndef _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H
+1 -4
include/soc/bcm2835/raspberrypi-firmware.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright © 2015 Broadcom 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 as 6 - * published by the Free Software Foundation. 7 4 */ 8 5 9 6 #ifndef __SOC_RASPBERRY_FIRMWARE_H__