Add Broadcom VK driver
Subsystems (2)
Scott Branden
maintainerv2 cover Add Broadcom VK driver
This patch series drops previous patches in [1] that were incorporated by Kees Cook into patch series "Introduce partial kernel_read_file() support" [2].
Remaining patches are contained in this series to add Broadcom VK driver. (which depends on request_firmware_into_buf API addition in other patch series [2] being applied first).
Please note this patch series will not compile without [2].
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
Changes from v1:
- declare bcm_vk_intf_ver_chk as static
Scott Branden (3):
bcm-vk: add bcm_vk UAPI
misc: bcm-vk: add Broadcom VK driver
MAINTAINERS: bcm-vk: add maintainer for Broadcom VK Driver
MAINTAINERS | 7 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/bcm-vk/Kconfig | 29 + drivers/misc/bcm-vk/Makefile | 11 + drivers/misc/bcm-vk/bcm_vk.h | 424 +++++++++ drivers/misc/bcm-vk/bcm_vk_dev.c | 1369 +++++++++++++++++++++++++++ drivers/misc/bcm-vk/bcm_vk_msg.c | 1514 ++++++++++++++++++++++++++++++ drivers/misc/bcm-vk/bcm_vk_msg.h | 211 +++++ drivers/misc/bcm-vk/bcm_vk_sg.c | 275 ++++++ drivers/misc/bcm-vk/bcm_vk_sg.h | 61 ++ drivers/misc/bcm-vk/bcm_vk_tty.c | 365 +++++++ include/uapi/linux/misc/bcm_vk.h | 99 ++ 13 files changed, 4367 insertions(+) create mode 100644 drivers/misc/bcm-vk/Kconfig create mode 100644 drivers/misc/bcm-vk/Makefile create mode 100644 drivers/misc/bcm-vk/bcm_vk.h create mode 100644 drivers/misc/bcm-vk/bcm_vk_dev.c create mode 100644 drivers/misc/bcm-vk/bcm_vk_msg.c create mode 100644 drivers/misc/bcm-vk/bcm_vk_msg.h create mode 100644 drivers/misc/bcm-vk/bcm_vk_sg.c create mode 100644 drivers/misc/bcm-vk/bcm_vk_sg.h create mode 100644 drivers/misc/bcm-vk/bcm_vk_tty.c create mode 100644 include/uapi/linux/misc/bcm_vk.h
Signature · 1 line
2.17.1
Scott Branden
maintainerPATCH v2 1/3 bcm-vk: add bcm_vk UAPI
Add user space api for bcm-vk driver.
--- include/uapi/linux/misc/bcm_vk.h | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 include/uapi/linux/misc/bcm_vk.h
include/uapi/linux/misc/bcm_vk.h new file +99 -0
@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ +/* +* Copyright 2018-2020 Broadcom. +*/ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { +__u32 type;/* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1/* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2/* 2nd stage (load to DDR) */ +char filename[BCM_VK_MAX_FILENAME ];/* Filename of image */ +}; + +struct vk_reset { +__u32 arg1; +__u32 arg2; +}; + +#define VK_MAGIC 0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* +* message block - basic unit in the message where a message's size is always +* N x sizeof(basic_block) +*/ +struct vk_msg_blk { +__u8 function_id; +#define VK_FID_TRANS_BUF 5 +#define VK_FID_SHUTDOWN 8 +__u8 size; +__u16 trans_id;/* transport id, queue & msg_id */ +__u32 context_id; +__u32 args[2 ]; +#define VK_CMD_PLANES_MASK 0x000f/* number of planes to up/download */ +#define VK_CMD_UPLOAD 0x0400/* memory transfer to vk */ +#define VK_CMD_DOWNLOAD 0x0500/* memory transfer from vk */ +#define VK_CMD_MASK 0x0f00/* command mask */ +}; + +#define VK_BAR_FWSTS 0x41c +#define VK_BAR_COP_FWSTS 0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY BIT(0) +#define VK_FWSTS_RELOCATION_EXIT BIT(1) +#define VK_FWSTS_INIT_START BIT(2) +#define VK_FWSTS_ARCH_INIT_DONE BIT(3) +#define VK_FWSTS_PRE_KNL1_INIT_DONE BIT(4) +#define VK_FWSTS_PRE_KNL2_INIT_DONE BIT(5) +#define VK_FWSTS_POST_KNL_INIT_DONE BIT(6) +#define VK_FWSTS_INIT_DONE BIT(7) +#define VK_FWSTS_APP_INIT_START BIT(8) +#define VK_FWSTS_APP_INIT_DONE BIT(9) +#define VK_FWSTS_MASK 0xffffffff +#define VK_FWSTS_READY (VK_FWSTS_INIT_START | \ + VK_FWSTS_ARCH_INIT_DONE | \ + VK_FWSTS_PRE_KNL1_INIT_DONE | \ + VK_FWSTS_PRE_KNL2_INIT_DONE | \ + VK_FWSTS_POST_KNL_INIT_DONE | \ + VK_FWSTS_INIT_DONE | \ + VK_FWSTS_APP_INIT_START | \ + VK_FWSTS_APP_INIT_DONE) +/* Deinit */ +#define VK_FWSTS_APP_DEINIT_START BIT(23) +#define VK_FWSTS_APP_DEINIT_DONE BIT(24) +#define VK_FWSTS_DRV_DEINIT_START BIT(25) +#define VK_FWSTS_DRV_DEINIT_DONE BIT(26) +#define VK_FWSTS_RESET_DONE BIT(27) +#define VK_FWSTS_DEINIT_TRIGGERED (VK_FWSTS_APP_DEINIT_START | \ + VK_FWSTS_APP_DEINIT_DONE | \ + VK_FWSTS_DRV_DEINIT_START | \ + VK_FWSTS_DRV_DEINIT_DONE) +/* Last nibble for reboot reason */ +#define VK_FWSTS_RESET_REASON_SHIFT 28 +#define VK_FWSTS_RESET_REASON_MASK (0xf << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_SYS_PWRUP (0x0 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_MBOX_DB (0x1 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_M7_WDOG (0x2 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_TEMP (0x3 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_FLR (0x4 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_HOT (0x5 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_WARM (0x6 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_COLD (0x7 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_L1 (0x8 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_L0 (0x9 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_UNKNOWN (0xf << VK_FWSTS_RESET_REASON_SHIFT) + +#endif /* __UAPI_LINUX_MISC_BCM_VK_H */
Signature · 1 line
2.17.1
Greg Kroah-Hartman
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Quoted 59 lines · Scott Branden
Add user space api for bcm-vk driver.
Signed-off-by Scott Branden <[email protected]>--- include/uapi/linux/misc/bcm_vk.h | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 include/uapi/linux/misc/bcm_vk.hinclude/uapi/linux/misc/bcm_vk.h new file +45
-0@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ +/* +* Copyright 2018-2020 Broadcom. +*/ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { + __u32 type; /* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1 /* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2 /* 2nd stage (load to DDR) */ + char filename[BCM_VK_MAX_FILENAME]; /* Filename of image */ +}; + +struct vk_reset { + __u32 arg1; + __u32 arg2; +}; + +#define VK_MAGIC 0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* + * message block - basic unit in the message where a message's size is always + * N x sizeof(basic_block) + */ +struct vk_msg_blk { + __u8 function_id; +#define VK_FID_TRANS_BUF 5 +#define VK_FID_SHUTDOWN 8 + __u8 size; + __u16 trans_id; /* transport id, queue & msg_id */ + __u32 context_id; + __u32 args[2];
include/uapi/linux/misc/bcm_vk.h line 55
Quoted 10 lines
include/uapi/linux/misc/bcm_vk.h new file +10
-0+#define VK_CMD_PLANES_MASK 0x000f/* number of planes to up/download */ +#define VK_CMD_UPLOAD 0x0400/* memory transfer to vk */ +#define VK_CMD_DOWNLOAD 0x0500/* memory transfer from vk */ +#define VK_CMD_MASK 0x0f00/* command mask */ +}; + +#define VK_BAR_FWSTS 0x41c +#define VK_BAR_COP_FWSTS 0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY BIT(0)
<snip>
I thought BIT() was not allowed in uapi .h files, this really works properly???
thanks,
greg k-h
Scott Branden
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Hi Greg,
Quoted 72 lines · Greg Kroah-Hartman
Quoted 69 lines · Scott Branden
Add user space api for bcm-vk driver.
Signed-off-by Scott Branden <[email protected]>--- include/uapi/linux/misc/bcm_vk.h | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 include/uapi/linux/misc/bcm_vk.hinclude/uapi/linux/misc/bcm_vk.h new file +55
-0@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ +/* +* Copyright 2018-2020 Broadcom. +*/ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { +__u32 type;/* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1/* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2/* 2nd stage (load to DDR) */ +char filename[BCM_VK_MAX_FILENAME ];/* Filename of image */ +}; + +struct vk_reset { +__u32 arg1; +__u32 arg2; +}; + +#define VK_MAGIC 0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* +* message block - basic unit in the message where a message's size is always +* N x sizeof(basic_block) +*/ +struct vk_msg_blk { +__u8 function_id; +#define VK_FID_TRANS_BUF 5 +#define VK_FID_SHUTDOWN 8 +__u8 size; +__u16 trans_id;/* transport id, queue & msg_id */ +__u32 context_id; +__u32 args[2 ]; +#define VK_CMD_PLANES_MASK 0x000f/* number of planes to up/download */ +#define VK_CMD_UPLOAD 0x0400/* memory transfer to vk */ +#define VK_CMD_DOWNLOAD 0x0500/* memory transfer from vk */ +#define VK_CMD_MASK 0x0f00/* command mask */ +}; + +#define VK_BAR_FWSTS 0x41c +#define VK_BAR_COP_FWSTS 0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY BIT(0)<snip>
Quoted 2 lines
I thought
BIT()was not allowed in uapi .h files, this really works properly???
I did some investigation and it looks like a few other header files in include/uapi also use the BIT() macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.htools/include/uapi/linux/pkt_sched.h
It does look like we end up defining the BIT() macro in our user space app that includes the header file.
So, what is the proper thing to be done?
1) Move the BIT() macro somewhere in include/uapi and include it in the necessary header files
2) Use the _BITUL macro in include/uapi/linux/const.h instead?
3) something else?
Quoted 3 lines
thanks,
greg k-h
Regards,
Scott
Greg Kroah-Hartman
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Quoted 75 lines · Scott Branden
Hi Greg,
Quoted 72 lines · Greg Kroah-Hartman
Quoted 69 lines · Scott Branden
Add user space api for bcm-vk driver.
Signed-off-by Scott Branden <[email protected]>--- include/uapi/linux/misc/bcm_vk.h | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 include/uapi/linux/misc/bcm_vk.hinclude/uapi/linux/misc/bcm_vk.h new file +55
-0@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ +/* +* Copyright 2018-2020 Broadcom. +*/ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { +__u32 type;/* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1/* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2/* 2nd stage (load to DDR) */ +char filename[BCM_VK_MAX_FILENAME ];/* Filename of image */ +}; + +struct vk_reset { +__u32 arg1; +__u32 arg2; +}; + +#define VK_MAGIC 0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* +* message block - basic unit in the message where a message's size is always +* N x sizeof(basic_block) +*/ +struct vk_msg_blk { +__u8 function_id; +#define VK_FID_TRANS_BUF 5 +#define VK_FID_SHUTDOWN 8 +__u8 size; +__u16 trans_id;/* transport id, queue & msg_id */ +__u32 context_id; +__u32 args[2 ]; +#define VK_CMD_PLANES_MASK 0x000f/* number of planes to up/download */ +#define VK_CMD_UPLOAD 0x0400/* memory transfer to vk */ +#define VK_CMD_DOWNLOAD 0x0500/* memory transfer from vk */ +#define VK_CMD_MASK 0x0f00/* command mask */ +}; + +#define VK_BAR_FWSTS 0x41c +#define VK_BAR_COP_FWSTS 0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY BIT(0)<snip>
Quoted 6 lines
Quoted 2 lines
I thought
BIT()was not allowed in uapi .h files, this really works properly???I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.h
Does the header install test target now fail for these?
Quoted 1 line
tools/include/uapi/linux/pkt_sched.h
That doesn't count :)
Quoted 6 lines
It does look like we end up defining the
BIT()macro in our user space app that includes the header file.So, what is the proper thing to be done?
1) Move theBIT()macro somewhere ininclude/uapiand include it in the necessary header files
2) Use the_BITULmacro ininclude/uapi/linux/const.hinstead?
3) something else?
open-code it for now please, that's the best way as I am pretty sure we can not contaminate the global C namespace with out BIT() macro, no matter how much we would like to...
thanks,
greg k-h
Scott Branden
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Quoted 76 lines · Greg Kroah-Hartman
Quoted 75 lines · Scott Branden
Hi Greg,
Quoted 72 lines · Greg Kroah-Hartman
Quoted 69 lines · Scott Branden
Add user space api for bcm-vk driver.
Signed-off-by Scott Branden <[email protected]>--- include/uapi/linux/misc/bcm_vk.h | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 include/uapi/linux/misc/bcm_vk.hinclude/uapi/linux/misc/bcm_vk.h new file +55
-0@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ +/* +* Copyright 2018-2020 Broadcom. +*/ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { +__u32 type;/* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1/* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2/* 2nd stage (load to DDR) */ +char filename[BCM_VK_MAX_FILENAME ];/* Filename of image */ +}; + +struct vk_reset { +__u32 arg1; +__u32 arg2; +}; + +#define VK_MAGIC 0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* +* message block - basic unit in the message where a message's size is always +* N x sizeof(basic_block) +*/ +struct vk_msg_blk { +__u8 function_id; +#define VK_FID_TRANS_BUF 5 +#define VK_FID_SHUTDOWN 8 +__u8 size; +__u16 trans_id;/* transport id, queue & msg_id */ +__u32 context_id; +__u32 args[2 ]; +#define VK_CMD_PLANES_MASK 0x000f/* number of planes to up/download */ +#define VK_CMD_UPLOAD 0x0400/* memory transfer to vk */ +#define VK_CMD_DOWNLOAD 0x0500/* memory transfer from vk */ +#define VK_CMD_MASK 0x0f00/* command mask */ +}; + +#define VK_BAR_FWSTS 0x41c +#define VK_BAR_COP_FWSTS 0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY BIT(0)<snip>
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
I thought
BIT()was not allowed in uapi .h files, this really works properly???I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.hDoes the header install test target now fail for these?
I do not understand the question above. make headers_install works. But I guess the above headers would have similar issue with the BIT macro.
Quoted 6 lines
Quoted 2 lines
tools/include/uapi/linux/pkt_sched.hThat doesn't count :)
Quoted 2 lines
It does look like we end up defining the
BIT()macro in our user space app that includes the header file.
Quoted 7 lines
Quoted 4 lines
So, what is the proper thing to be done?
1) Move theBIT()macro somewhere ininclude/uapiand include it in the necessary header files
2) Use the_BITULmacro ininclude/uapi/linux/const.hinstead?
3) something else?open-code it for now please, that's the best way as I am pretty sure we can not contaminate the global C namespace with out
BIT()macro, no matter how much we would like to...
OK, I will open-code it instead.
Quoted 4 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Quoted 81 lines · Scott Branden
Quoted 78 lines · Greg Kroah-Hartman
Quoted 77 lines · Scott Branden
Hi Greg,
Quoted 74 lines · Greg Kroah-Hartman
Quoted 59 lines · Scott Branden
Add user space api for bcm-vk driver.
Signed-off-by Scott Branden <[email protected]>--- include/uapi/linux/misc/bcm_vk.h | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 include/uapi/linux/misc/bcm_vk.hinclude/uapi/linux/misc/bcm_vk.h new file +45
-0@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ +/* +* Copyright 2018-2020 Broadcom. +*/ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { + __u32 type; /* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1 /* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2 /* 2nd stage (load to DDR) */ + char filename[BCM_VK_MAX_FILENAME]; /* Filename of image */ +}; + +struct vk_reset { + __u32 arg1; + __u32 arg2; +}; + +#define VK_MAGIC 0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* + * message block - basic unit in the message where a message's size is always + * N x sizeof(basic_block) + */ +struct vk_msg_blk { + __u8 function_id; +#define VK_FID_TRANS_BUF 5 +#define VK_FID_SHUTDOWN 8 + __u8 size; + __u16 trans_id; /* transport id, queue & msg_id */ + __u32 context_id; + __u32 args[2];include/uapi/linux/misc/bcm_vk.h line 55
Quoted 10 lines
include/uapi/linux/misc/bcm_vk.h new file +10
-0+#define VK_CMD_PLANES_MASK 0x000f/* number of planes to up/download */ +#define VK_CMD_UPLOAD 0x0400/* memory transfer to vk */ +#define VK_CMD_DOWNLOAD 0x0500/* memory transfer from vk */ +#define VK_CMD_MASK 0x0f00/* command mask */ +}; + +#define VK_BAR_FWSTS 0x41c +#define VK_BAR_COP_FWSTS 0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY BIT(0)<snip>
I thought
BIT()was not allowed in uapi .h files, this really works properly???
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.hDoes the header install test target now fail for these?
I do not understand the question above. make
headers_installworks. But I guess the above headers would have similar issue with the BIT macro.
Try enabling CONFIG_UAPI_HEADER_TEST and see what happens :)
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
tools/include/uapi/linux/pkt_sched.hThat doesn't count :)
Quoted 2 lines
It does look like we end up defining the
BIT()macro in our user space app that includes the header file.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
So, what is the proper thing to be done?
1) Move theBIT()macro somewhere ininclude/uapiand include it in the necessary header files
2) Use the_BITULmacro ininclude/uapi/linux/const.hinstead?
3) something else?open-code it for now please, that's the best way as I am pretty sure we can not contaminate the global C namespace with out
BIT()macro, no matter how much we would like to...OK, I will open-code it instead.
Great!
greg k-h
Scott Branden
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Hi Greg,
Quoted 81 lines · Greg Kroah-Hartman
Quoted 80 lines · Scott Branden
Quoted 78 lines · Greg Kroah-Hartman
Quoted 77 lines · Scott Branden
Hi Greg,
Quoted 74 lines · Greg Kroah-Hartman
Quoted 59 lines · Scott Branden
Add user space api for bcm-vk driver.
Signed-off-by Scott Branden <[email protected]>--- include/uapi/linux/misc/bcm_vk.h | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 include/uapi/linux/misc/bcm_vk.hinclude/uapi/linux/misc/bcm_vk.h new file +45
-0@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ +/* +* Copyright 2018-2020 Broadcom. +*/ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { + __u32 type; /* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1 /* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2 /* 2nd stage (load to DDR) */ + char filename[BCM_VK_MAX_FILENAME]; /* Filename of image */ +}; + +struct vk_reset { + __u32 arg1; + __u32 arg2; +}; + +#define VK_MAGIC 0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* + * message block - basic unit in the message where a message's size is always + * N x sizeof(basic_block) + */ +struct vk_msg_blk { + __u8 function_id; +#define VK_FID_TRANS_BUF 5 +#define VK_FID_SHUTDOWN 8 + __u8 size; + __u16 trans_id; /* transport id, queue & msg_id */ + __u32 context_id; + __u32 args[2];include/uapi/linux/misc/bcm_vk.h line 55
Quoted 10 lines
include/uapi/linux/misc/bcm_vk.h new file +10
-0+#define VK_CMD_PLANES_MASK 0x000f/* number of planes to up/download */ +#define VK_CMD_UPLOAD 0x0400/* memory transfer to vk */ +#define VK_CMD_DOWNLOAD 0x0500/* memory transfer from vk */ +#define VK_CMD_MASK 0x0f00/* command mask */ +}; + +#define VK_BAR_FWSTS 0x41c +#define VK_BAR_COP_FWSTS 0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY BIT(0)<snip>
I thought
BIT()was not allowed in uapi .h files, this really works properly???
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.hDoes the header install test target now fail for these?
I do not understand the question above. make
headers_installworks. But I guess the above headers would have similar issue with the BIT macro.Try enabling
CONFIG_UAPI_HEADER_TESTand see what happens :)
I enabled CONFIG_UAPI_HEADER_TEST and then
built using "make" and "make headers_install".
There didn't appear to be any issue with the BIT macro in the headers.
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
tools/include/uapi/linux/pkt_sched.hThat doesn't count :)
Quoted 2 lines
It does look like we end up defining the
BIT()macro in our user space app that includes the header file.Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
So, what is the proper thing to be done?
1) Move theBIT()macro somewhere ininclude/uapiand include it in the necessary header files
2) Use the_BITULmacro ininclude/uapi/linux/const.hinstead?
3) something else?open-code it for now please, that's the best way as I am pretty sure we can not contaminate the global C namespace with out
BIT()macro, no matter how much we would like to...OK, I will open-code it instead.
Great!
greg k-h
Re: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Quoted 14 lines · Scott Branden
Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Scott Branden
Quoted 10 lines · Greg Kroah-Hartman
Quoted 9 lines · Scott Branden
Quoted 5 lines
Quoted 1 line
+#define
VK_FWSTS_RELOCATION_ENTRYBIT(0)<snip>
I thought
BIT()was not allowed in uapi .h files, this really works properly???I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.h
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Does the header install test target now fail for these?
I do not understand the question above. make
headers_installworks. But I guess the above headers would have similar issue with the BIT macro.Try enabling
CONFIG_UAPI_HEADER_TESTand see what happens :)I enabled
CONFIG_UAPI_HEADER_TESTand then
built using "make" and "makeheaders_install".There didn't appear to be any issue with the BIT macro in the headers.
FWIW, other subsystems have not been so lucky:
https://git.kernel.org/linus/23b2c96fad21886c53f5e1a4ffedd45ddd2e85ba
It may just be better to avoid BIT(), even if it works "by accident"(?) for some header combinations...
Signature · 1 line
Kees Cook
Re: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Quoted 22 lines · Kees Cook
Quoted 21 lines · Scott Branden
Quoted 9 lines · Greg Kroah-Hartman
Quoted 8 lines · Scott Branden
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Scott Branden
Quoted 5 lines
Quoted 1 line
+#define
VK_FWSTS_RELOCATION_ENTRYBIT(0)<snip>
I thought
BIT()was not allowed in uapi .h files, this really works properly???Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.hDoes the header install test target now fail for these?
I do not understand the question above. make
headers_installworks. But I guess the above headers would have similar issue with the BIT macro.Try enabling
CONFIG_UAPI_HEADER_TESTand see what happens :)I enabled
CONFIG_UAPI_HEADER_TESTand then
built using "make" and "makeheaders_install".
Quoted 8 lines
Quoted 1 line
There didn't appear to be any issue with the BIT macro in the headers.
FWIW, other subsystems have not been so lucky:
https://git.kernel.org/linus/23b2c96fad21886c53f5e1a4ffedd45ddd2e85ba
It may just be better to avoid
BIT(), even if it works "by accident"(?) for some header combinations...
Since we ship a copy of unifdef.c in tree, we could certainly teach it to undo the BIT() definition and replace it with an appropriate constant definition.
Signature · 1 line
Florian
Scott Branden
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
Quoted 25 lines · Florian Fainelli
Quoted 24 lines · Kees Cook
Quoted 13 lines · Scott Branden
Quoted 12 lines · Greg Kroah-Hartman
Quoted 11 lines · Scott Branden
Quoted 10 lines · Greg Kroah-Hartman
Quoted 9 lines · Scott Branden
Quoted 5 lines
Quoted 1 line
+#define
VK_FWSTS_RELOCATION_ENTRYBIT(0)<snip>
I thought
BIT()was not allowed in uapi .h files, this really works properly???I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.hQuoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Does the header install test target now fail for these?
I do not understand the question above. make
headers_installworks. But I guess the above headers would have similar issue with the BIT macro.Try enabling
CONFIG_UAPI_HEADER_TESTand see what happens :)I enabled
CONFIG_UAPI_HEADER_TESTand then
built using "make" and "makeheaders_install".There didn't appear to be any issue with the BIT macro in the headers.
FWIW, other subsystems have not been so lucky:
Quoted 7 lines
Quoted 4 lines
https://git.kernel.org/linus/23b2c96fad21886c53f5e1a4ffedd45ddd2e85ba
It may just be better to avoid
BIT(), even if it works "by accident"(?) for some header combinations...Since we ship a copy of
unifdef.cin tree, we could certainly teach it to undo theBIT()definition and replace it with an appropriate constant definition.
That sounds appealing given the rest of the code wants us to use the BIT macro.
Scott Branden
maintainerRe: [PATCH v2 1/3] bcm-vk: add bcm_vk UAPI
In reply to Kees CookQuoted 21 lines · Kees Cook
Quoted 20 lines · Scott Branden
Quoted 8 lines · Greg Kroah-Hartman
Quoted 7 lines · Scott Branden
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Scott Branden
Quoted 5 lines
Quoted 1 line
+#define
VK_FWSTS_RELOCATION_ENTRYBIT(0)<snip>
I thought
BIT()was not allowed in uapi .h files, this really works properly???Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
I did some investigation and it looks like a few other header files in
include/uapialso use theBIT()macro:include/uapi/misc/uacce/uacce.hinclude/uapi/linux/psci.hinclude/uapi/linux/v4l2-subdev.hDoes the header install test target now fail for these?
I do not understand the question above. make
headers_installworks. But I guess the above headers would have similar issue with the BIT macro.Try enabling
CONFIG_UAPI_HEADER_TESTand see what happens :)I enabled
CONFIG_UAPI_HEADER_TESTand then
built using "make" and "makeheaders_install".
Quoted 8 lines
Quoted 1 line
There didn't appear to be any issue with the BIT macro in the headers.
FWIW, other subsystems have not been so lucky:
https://git.kernel.org/linus/23b2c96fad21886c53f5e1a4ffedd45ddd2e85ba
It may just be better to avoid
BIT(), even if it works "by accident"(?) for some header combinations...
Yes, I was going to avoid the BIT macro but was just testing what Greg asked me too. It would be nice if checkpatch reported the BIT macro shouldn't be used in the uapi headers....
Scott Branden
maintainerPATCH v2 2/3 misc: bcm-vk: add Broadcom VK driver
In reply to Scott BrandenAdd Broadcom VK driver offload engine.
This driver interfaces to the VK PCIe offload engine to perform should offload functions as video transcoding on multiple streams in parallel. VK device is booted from files loaded using request_firmware_into_buf mechanism. After booted card status is updated and messages can then be sent to the card.
Such messages contain scatter gather list of addresses
to pull data from the host to perform operations on.
--- drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/bcm-vk/Kconfig | 29 + drivers/misc/bcm-vk/Makefile | 11 + drivers/misc/bcm-vk/bcm_vk.h | 424 +++++++++ drivers/misc/bcm-vk/bcm_vk_dev.c | 1369 +++++++++++++++++++++++++++ drivers/misc/bcm-vk/bcm_vk_msg.c | 1514 ++++++++++++++++++++++++++++++ drivers/misc/bcm-vk/bcm_vk_msg.h | 211 +++++ drivers/misc/bcm-vk/bcm_vk_sg.c | 275 ++++++ drivers/misc/bcm-vk/bcm_vk_sg.h | 61 ++ drivers/misc/bcm-vk/bcm_vk_tty.c | 365 +++++++ 11 files changed, 4261 insertions(+) create mode 100644 drivers/misc/bcm-vk/Kconfig create mode 100644 drivers/misc/bcm-vk/Makefile create mode 100644 drivers/misc/bcm-vk/bcm_vk.h create mode 100644 drivers/misc/bcm-vk/bcm_vk_dev.c create mode 100644 drivers/misc/bcm-vk/bcm_vk_msg.c create mode 100644 drivers/misc/bcm-vk/bcm_vk_msg.h create mode 100644 drivers/misc/bcm-vk/bcm_vk_sg.c create mode 100644 drivers/misc/bcm-vk/bcm_vk_sg.h create mode 100644 drivers/misc/bcm-vk/bcm_vk_tty.c
drivers/misc/Kconfig +1 -0
@@ -469,6 +469,7 @@ source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" source "drivers/misc/cxl/Kconfig" source "drivers/misc/ocxl/Kconfig" +source "drivers/misc/bcm-vk/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig"
drivers/misc/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o obj-$(CONFIG_OCXL) += ocxl/ +obj-$(CONFIG_BCM_VK) += bcm-vk/ obj-y += cardreader/ obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_HABANA_AI) += habanalabs/
drivers/misc/bcm-vk/Kconfig new file +29 -0
@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Broadcom VK device +# +config BCM_VK + tristate "Support for Broadcom VK Accelerators" + depends on PCI_MSI + help + Select this option to enable support for Broadcom + VK Accelerators. VK is used for performing + specific offload processing. + This driver enables userspace programs to access these + accelerators via /dev/bcm-vk.N devices. + + If unsure, say N. + +if BCM_VK + +config BCM_VK_QSTATS + bool "VK Queue Statistics" + help + Turn on to enable Queue Statistics. + These are useful for debugging purposes. + Some performance loss by enabling this debug config. + For properly operating PCIe hardware no need to enable this. + + If unsure, say N. + +endif
drivers/misc/bcm-vk/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for Broadcom VK driver +# + +obj-$(CONFIG_BCM_VK) += bcm_vk.o +bcm_vk-objs := \ + bcm_vk_dev.o \ + bcm_vk_msg.o \ + bcm_vk_sg.o \ + bcm_vk_tty.o
drivers/misc/bcm-vk/bcm_vk.h new file +424 -0
424 lines not on this page · raw message
drivers/misc/bcm-vk/bcm_vk_dev.c new file +1369 -0
1,369 lines not on this page · raw message
drivers/misc/bcm-vk/bcm_vk_msg.c new file +1514 -0
1,153 lines not on this page · raw message
drivers/misc/bcm-vk/bcm_vk_msg.h new file +211 -0
211 lines not on this page · raw message
drivers/misc/bcm-vk/bcm_vk_sg.c new file +275 -0
275 lines not on this page · raw message
drivers/misc/bcm-vk/bcm_vk_sg.h new file +61 -0
61 lines not on this page · raw message
drivers/misc/bcm-vk/bcm_vk_tty.c new file +365 -0
365 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
Scott Branden
maintainerPATCH v2 3/3 MAINTAINERS: bcm-vk: add maintainer for Broadcom VK Driver
In reply to Scott BrandenAdd maintainer entry for new Broadcom VK Driver
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -3657,6 +3657,13 @@ L: [email protected] S: Supported F: drivers/net/ethernet/broadcom/tg3.* +BROADCOM VK DRIVER +M: Scott Branden <[email protected]> +L: [email protected] +S: Supported +F: drivers/misc/bcm-vk/ +F: include/uapi/linux/misc/bcm_vk.h + BROCADE BFA FC SCSI DRIVER M: Anil Gurumurthy <[email protected]> M: Sudarsana Kalluru <[email protected]>
Signature · 1 line
2.17.1
Quoted 4 lines · Scott Branden
This patch series drops previous patches in [1] that were incorporated by Kees Cook into patch series "Introduce partial
kernel_read_file()support" [2].
Quoted 8 lines
Remaining patches are contained in this series to add Broadcom VK driver. (which depends on
request_firmware_into_bufAPI addition in other patch series [2] being applied first).Please note this patch series will not compile without [2].
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
Greg, is your intention to take [2] into your tree? AFAICT, it's got the appropriate Acks, etc.
Signature · 1 line
Kees Cook
Greg Kroah-Hartman
maintainerQuoted 9 lines · Kees Cook
Quoted 8 lines · Scott Branden
This patch series drops previous patches in [1] that were incorporated by Kees Cook into patch series "Introduce partial
kernel_read_file()support" [2].Remaining patches are contained in this series to add Broadcom VK driver. (which depends on
request_firmware_into_bufAPI addition in other patch series [2] being applied first).
Quoted 7 lines
Quoted 4 lines
Please note this patch series will not compile without [2].
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/Greg, is your intention to take [2] into your tree? AFAICT, it's got the appropriate Acks, etc.
Yes, it is in my queue to do so, hopefully soon, digging out now from the big -rc1 patch-submission-pile...
greg k-h