Habana Labs kernel driver
Subsystems (7)
Re: [PATCH 11/15] habanalabs: add command submission module
In reply to Mike RapoportQuoted 124 lines · Mike Rapoport
Quoted 72 lines · Oded Gabbay
This patch adds the main flow for the user to submit work to the device.
Each work is described by a command submission object (CS). The CS contains 3 arrays of command buffers: One for execution, and two for context-switch (store and restore).
For each CB, the user specifies on which queue to put that CB. In case of an internal queue, the entry doesn't contain a pointer to the CB but the address in the on-chip memory that the CB resides at.
The driver parses some of the CBs to enforce security restrictions.
The user receives a sequence number that represents the CS object. The user can then query the driver regarding the status of the CS, using that sequence number.
In case the CS doesn't finish before the timeout expires, the driver will perform a soft-reset of the device.
Signed-off-by Oded Gabbay <[email protected]>--- drivers/misc/habanalabs/Makefile | 3 +- drivers/misc/habanalabs/command_submission.c | 787 +++++++++++++ drivers/misc/habanalabs/context.c | 52 +- drivers/misc/habanalabs/device.c | 16 + drivers/misc/habanalabs/goya/goya.c | 1082 ++++++++++++++++++ drivers/misc/habanalabs/habanalabs.h | 274 +++++ drivers/misc/habanalabs/habanalabs_drv.c | 23 + drivers/misc/habanalabs/habanalabs_ioctl.c | 4 +- drivers/misc/habanalabs/hw_queue.c | 250 ++++ drivers/misc/habanalabs/memory.c | 200 ++++ include/uapi/misc/habanalabs.h | 158 ++- 11 files changed, 2842 insertions(+), 7 deletions(-) create mode 100644 drivers/misc/habanalabs/command_submission.c create mode 100644 drivers/misc/habanalabs/memory.cdrivers/misc/habanalabs/Makefile +2
-1@@ -5,7 +5,8 @@ obj-m := habanalabs.o habanalabs-y := habanalabs_drv.o device.o context.o asid.o habanalabs_ioctl.o \ - command_buffer.o hw_queue.o irq.o sysfs.o hwmon.o + command_buffer.o hw_queue.o irq.o sysfs.o hwmon.o memory.o \ + command_submission.o include $(src)/goya/Makefile habanalabs-y += $(HL_GOYA_FILES)drivers/misc/habanalabs/command_submission.c new file +16
-0@@ -0,0 +1,787 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* Copyright 2016-2018 HabanaLabs, Ltd. +* All Rights Reserved. +*/ + +#include <uapi/misc/habanalabs.h> +#include "habanalabs.h" + +#include <linux/sched/mm.h> +#include <linux/sched/task.h> +#include <linux/sched/signal.h> +#include <linux/wait.h> +#include <linux/mm.h> +#include <linux/highmem.h> [ ... ]
Quoted 47 lines
drivers/misc/habanalabs/command_submission.c new file +47
-0+static void cs_do_release (struct kref *ref) +{ + struct hl_cs *cs = container_of(ref, struct hl_cs, + refcount); +struct hl_device *hdev = cs->ctx->hdev; +struct hl_cs_job *job, *tmp; + + cs->completed = true; + +/* +* Although if we reached here it means that all external jobs have +* finished, because each one of them took refcnt to CS, we still +* need to go over the internal jobs and free them. Otherwise, we +* will have leaked memory and what's worse, the CS object (and +* potentially the CTX object) could be released, while the JOB +* still holds a pointer to them (but no reference). +*/ +list_for_each_entry_safe (job, tmp, &cs->job_list, cs_node) +free_job (hdev, job); + +/* We also need to update CI for internal queues */ +if (cs->submitted) { +hl_int_hw_queue_update_ci (cs); + +spin_lock (&hdev->hw_queues_mirror_lock); +/* remove CS from hw_queues mirror list */ +list_del_init (&cs->mirror_node); +spin_unlock (&hdev->hw_queues_mirror_lock); + +/* +* Don't cancel TDR in case this CS was timedout because we +* might be running from the TDR context +*/ +if ((!cs->timedout) && + (hdev->timeout_jiffies !=MAX_SCHEDULE_TIMEOUT )) { +struct hl_cs *next; + +if (cs->tdr_active) +cancel_delayed_work_sync (&cs->work_tdr); + +spin_lock (&hdev->hw_queues_mirror_lock); +/* queue TDR for next CS */ + next =list_first_entry_or_null ( + &hdev->hw_queues_mirror_list, + struct hl_cs, mirror_node); +if ((next) && (!next->tdr_active)) { + next->tdr_active = true;
Quoted 9 lines
drivers/misc/habanalabs/command_submission.c line 214
Quoted 6 lines
drivers/misc/habanalabs/command_submission.c new file +6
-0+schedule_delayed_work (&next->work_tdr, + hdev->timeout_jiffies); +spin_unlock (&hdev->hw_queues_mirror_lock); + }else { +spin_unlock (&hdev->hw_queues_mirror_lock); + }'else' can be dropped, just move
spin_unlock()outside the 'if'
Fixed
Quoted 18 lines
Quoted 15 lines
drivers/misc/habanalabs/command_submission.c new file +15
-0+ } + } + +hl_ctx_put (cs->ctx); + +if (cs->timedout) +dma_fence_set_error (cs->fence, -ETIMEDOUT ); +else if (cs->aborted) +dma_fence_set_error (cs->fence, -EIO ); + +dma_fence_signal (cs->fence); +dma_fence_put (cs->fence); + +kfree (cs); +}[ ... ]
Quoted 15 lines
drivers/misc/habanalabs/command_submission.c line 271
Quoted 11 lines
drivers/misc/habanalabs/command_submission.c new file +11
-0+static int allocate_cs (struct hl_device *hdev,struct hl_ctx *ctx, +struct hl_cs **cs_new) +{ +struct hl_dma_fence *fence; +struct dma_fence *other =NULL ; +struct hl_cs *cs; +int rc; + + cs =kzalloc (sizeof (*cs),GFP_ATOMIC ); +if (!cs) +return -ENOMEM ;Does this ever run from a context that cannot use
GFP_KERNEL? This applies to other allocations below.
It *always* runs from a context that cannot use GFP_KERNEL, because we mustn't sleep during command submission due to low latency requirements.
Quoted 4 lines
Quoted 4 lines
drivers/misc/habanalabs/command_submission.c new file +4
-0+ + cs->ctx = ctx; + cs->submitted = false; + cs->completed = false;
Quoted 8 lines
drivers/misc/habanalabs/command_submission.c line 281
Quoted 6 lines
drivers/misc/habanalabs/command_submission.c new file +6
-0+INIT_LIST_HEAD (&cs->job_list); +INIT_DELAYED_WORK (&cs->work_tdr, cs_timedout); +kref_init (&cs->refcount); +spin_lock_init (&cs->job_lock); + + fence =kmalloc (sizeof (*fence),GFP_ATOMIC );kzalloc?
Can't waste time on memset
Quoted 81 lines
Quoted 46 lines
drivers/misc/habanalabs/command_submission.c new file +45
-0+if (!fence) { + rc = -ENOMEM ; + goto free_cs; + } + + fence->hdev = hdev; +spin_lock_init (&fence->lock); + cs->fence = &fence->base_fence; + +spin_lock (&ctx->cs_lock); + + fence->cs_seq = ctx->cs_sequence; + other = ctx->cs_pending[fence->cs_seq & (HL_MAX_PENDING_CS -1 )]; +if ((other) && (!dma_fence_is_signaled (other))) { +spin_unlock (&ctx->cs_lock); + rc = -EAGAIN ; + goto free_fence; + } + +dma_fence_init (&fence->base_fence, &hl_fence_ops, &fence->lock, + ctx->asid, ctx->cs_sequence); + + cs->sequence = fence->cs_seq; + + ctx->cs_pending[fence->cs_seq & (HL_MAX_PENDING_CS -1 )] = + &fence->base_fence; + ctx->cs_sequence++; + +dma_fence_get (&fence->base_fence); + +dma_fence_put (other); + +spin_unlock (&ctx->cs_lock); + + *cs_new = cs; + +return 0 ; + +free_fence: +kfree (fence); +free_cs: +kfree (cs); +return rc; +} +[ ... ]
Quoted 19 lines
drivers/misc/habanalabs/command_submission.c new file +19
-0+ +static int goya_validate_cb (struct hl_device *hdev, +struct hl_cs_parser *parser,bool is_mmu) +{ +u32 cb_parsed_length =0 ; +int rc =0 ; + + parser->patched_cb_size =0 ; + +/* cb_user_size is more than 0 so loop will always be executed */ +while ((cb_parsed_length < parser->user_cb_size) && (!rc)) { +enum packet_id pkt_id; +u16 pkt_size; +void *user_pkt; + + user_pkt = (void *) (parser->user_cb->kernel_address + + cb_parsed_length); + + pkt_id = (enum packet_id) (((*(u64 *) user_pkt) &drivers/misc/habanalabs/command_submission.c
Quoted 10 lines
drivers/misc/habanalabs/command_submission.c new file +10
-0+ PACKET_HEADER_PACKET_ID_MASK) >> + PACKET_HEADER_PACKET_ID_SHIFT); + + pkt_size = goya_packet_sizes[pkt_id]; + cb_parsed_length += pkt_size; +if (cb_parsed_length > parser->user_cb_size) { +dev_err (hdev->dev, +"packet 0x%x is out of CB boundary\n" , pkt_id); + rc = -EINVAL ; +continue ;For me !rc in the while statement was blind. Please consider break here and
Quoted 4 lines
if (!rc) break;after the switch
Fixed
Quoted 95 lines
Quoted 68 lines
drivers/misc/habanalabs/command_submission.c new file +67
-0+ } + +switch (pkt_id) { +case PACKET_WREG_32 : +/* +* Although it is validated after copy in patch_cb(), +* need to validate here as well because patch_cb() is +* not called in MMU path while this function is called +*/ + rc =goya_validate_wreg32 (hdev, parser, user_pkt); +break ; + +case PACKET_WREG_BULK : +dev_err (hdev->dev, +"User not allowed to use WREG_BULK\n" ); + rc = -EPERM ; +break ; + +case PACKET_MSG_PROT : +dev_err (hdev->dev, +"User not allowed to use MSG_PROT\n" ); + rc = -EPERM ; +break ; + +case PACKET_CP_DMA : +dev_err (hdev->dev,"User not allowed to use CP_DMA\n" ); + rc = -EPERM ; +break ; + +case PACKET_STOP : +dev_err (hdev->dev,"User not allowed to use STOP\n" ); + rc = -EPERM ; +break ; + +case PACKET_LIN_DMA : +if (is_mmu) + rc =goya_validate_dma_pkt_mmu (hdev, parser, + user_pkt); +else + rc =goya_validate_dma_pkt_no_mmu (hdev, parser, + user_pkt); +break ; + +case PACKET_MSG_LONG : +case PACKET_MSG_SHORT : +case PACKET_FENCE : +case PACKET_NOP : + parser->patched_cb_size += pkt_size; +break ; + +default : +dev_err (hdev->dev,"Invalid packet header 0x%x\n" , + pkt_id); + rc = -EINVAL ; +break ; + } + } + +/* +* The new CB should have space at the end for two MSG_PROT packets: +* 1. A packet that will act as a completion packet +* 2. A packet that will generate MSI-X interrupt +*/ + parser->patched_cb_size +=sizeof (struct packet_msg_prot ) *2 ; + +return rc; +}[ ... ]
Quoted 24 lines
drivers/misc/habanalabs/command_submission.c new file +24
-0+static int goya_patch_cb (struct hl_device *hdev, +struct hl_cs_parser *parser) +{ +u32 cb_parsed_length =0 ; +u32 cb_patched_cur_length =0 ; +int rc =0 ; + +/* cb_user_size is more than 0 so loop will always be executed */ +while ((cb_parsed_length < parser->user_cb_size) && (!rc)) { +enum packet_id pkt_id; +u16 pkt_size; +u32 new_pkt_size =0 ; +void *user_pkt, *kernel_pkt; + + user_pkt = (void *) (parser->user_cb->kernel_address + + cb_parsed_length); + kernel_pkt = (void *) (parser->patched_cb->kernel_address + + cb_patched_cur_length); + + pkt_id = (enum packet_id ) (((*(u64 *) user_pkt) & +PACKET_HEADER_PACKET_ID_MASK ) >> +PACKET_HEADER_PACKET_ID_SHIFT ); + + pkt_size = goya_packet_sizes[pkt_id];
Quoted 8 lines
drivers/misc/habanalabs/command_submission.c
Quoted 6 lines
drivers/misc/habanalabs/command_submission.c new file +6
-0+ cb_parsed_length += pkt_size; +if (cb_parsed_length > parser->user_cb_size) { +dev_err (hdev->dev, +"packet 0x%x is out of CB boundary\n" , pkt_id); + rc = -EINVAL ; +continue ;Ditto
Fixed
Quoted 107 lines
Quoted 56 lines
drivers/misc/habanalabs/command_submission.c new file +55
-0+ } + +switch (pkt_id) { +case PACKET_LIN_DMA : + rc =goya_patch_dma_packet (hdev, parser, user_pkt, + kernel_pkt, &new_pkt_size); + cb_patched_cur_length += new_pkt_size; +break ; + +case PACKET_WREG_32 : +memcpy (kernel_pkt, user_pkt, pkt_size); + cb_patched_cur_length += pkt_size; + rc =goya_validate_wreg32 (hdev, parser, kernel_pkt); +break ; + +case PACKET_WREG_BULK : +dev_err (hdev->dev, +"User not allowed to use WREG_BULK\n" ); + rc = -EPERM ; +break ; + +case PACKET_MSG_PROT : +dev_err (hdev->dev, +"User not allowed to use MSG_PROT\n" ); + rc = -EPERM ; +break ; + +case PACKET_CP_DMA : +dev_err (hdev->dev,"User not allowed to use CP_DMA\n" ); + rc = -EPERM ; +break ; + +case PACKET_STOP : +dev_err (hdev->dev,"User not allowed to use STOP\n" ); + rc = -EPERM ; +break ; + +case PACKET_MSG_LONG : +case PACKET_MSG_SHORT : +case PACKET_FENCE : +case PACKET_NOP : +memcpy (kernel_pkt, user_pkt, pkt_size); + cb_patched_cur_length += pkt_size; +break ; + +default : +dev_err (hdev->dev,"Invalid packet header 0x%x\n" , + pkt_id); + rc = -EINVAL ; +break ; + } + } + +return rc; +}[ ... ]
Quoted 35 lines
static void goya_get_axi_name(struct
hl_device*hdev, u32agent_id,
u16event_type, char*axi_name, int len)
{drivers/misc/habanalabs/command_submission.c new file +28
-0@@ -4645,6 +5677,48 @@ static void goya_disable_clock_gating(struct hl_device *hdev) } +static bool goya_is_device_idle (struct hl_device *hdev) +{ +u64 offset, dma_qm_reg, tpc_qm_reg, tpc_cmdq_reg, tpc_cfg_reg; +bool val = true; +int i; + + offset = mmDMA_QM_1_GLBL_STS0 - mmDMA_QM_0_GLBL_STS0; + +for (i =0 ; i <DMA_MAX_NUM ; i++) { + dma_qm_reg = mmDMA_QM_0_GLBL_STS0 + i * offset; + + val = val && ((RREG32 (dma_qm_reg) &DMA_QM_IDLE_MASK ) == +DMA_QM_IDLE_MASK ); + } + + offset = mmTPC1_QM_GLBL_STS0 - mmTPC0_QM_GLBL_STS0; + +for (i =0 ; i <TPC_MAX_NUM ; i++) { + tpc_qm_reg = mmTPC0_QM_GLBL_STS0 + i * offset; + tpc_cmdq_reg = mmTPC0_CMDQ_GLBL_STS0 + i * offset; + tpc_cfg_reg = mmTPC0_CFG_STATUS + i * offset; + + val = val && ((RREG32 (tpc_qm_reg) &TPC_QM_IDLE_MASK ) == +TPC_QM_IDLE_MASK ); + val = val && ((RREG32 (tpc_cmdq_reg) &TPC_CMDQ_IDLE_MASK ) == +TPC_CMDQ_IDLE_MASK ); + val = val && ((RREG32 (tpc_cfg_reg) &TPC_CFG_IDLE_MASK ) == +TPC_CFG_IDLE_MASK );drivers/misc/habanalabs/command_submission.c static void goya_disable_clock_gating(struct hl_device *hdev) · line 5717
Quoted 10 lines
drivers/misc/habanalabs/command_submission.c new file +10
-0+ } + + val = val && ((RREG32 (mmMME_QM_GLBL_STS0) &MME_QM_IDLE_MASK ) == +MME_QM_IDLE_MASK ); + val = val && ((RREG32 (mmMME_CMDQ_GLBL_STS0) &MME_CMDQ_IDLE_MASK ) == +MME_CMDQ_IDLE_MASK ); + val = val && ((RREG32 (mmMME_ARCH_STATUS) &MME_ARCH_IDLE_MASK ) == +MME_ARCH_IDLE_MASK ); + val = val && ((RREG32 (mmMME_SHADOW_0_STATUS) &MME_SHADOW_IDLE_MASK ) == +0 );Huh, these are neat, but IMHO plain
Quoted 5 lines
if ((RREG(reg) & mask) != mask) return false;are more readable...
Fixed
Quoted 11 lines
drivers/misc/habanalabs/command_submission.c static void goya_disable_clock_gating(struct hl_device *hdev) · line 5721
Quoted 4 lines
drivers/misc/habanalabs/command_submission.c new file +4
-0+ +return val; +} +[ ... ]
--
Sincerely yours,
Mike.
PATCH 12/15 habanalabs: add virtual memory and MMU modules
In reply to Oded GabbayFrom: Omer Shpigelman <[email protected]>
This patch adds the Virtual Memory and MMU modules.
Goya has an internal MMU which provides process isolation on the internal DDR. The internal MMU also performs translations for transactions that go from Goya to the Host.
The driver is responsible for allocating and freeing memory on the DDR upon user request. It also provides an interface to map and unmap DDR and Host memory to the device address space.
--- drivers/misc/habanalabs/Makefile | 2 +- drivers/misc/habanalabs/context.c | 19 +- drivers/misc/habanalabs/device.c | 20 +- drivers/misc/habanalabs/goya/goya.c | 391 +++++ drivers/misc/habanalabs/habanalabs.h | 195 +++ drivers/misc/habanalabs/habanalabs_drv.c | 2 +- drivers/misc/habanalabs/habanalabs_ioctl.c | 3 +- drivers/misc/habanalabs/include/goya/goya.h | 6 +- .../include/hw_ip/mmu/mmu_general.h | 45 + .../habanalabs/include/hw_ip/mmu/mmu_v1_0.h | 15 + drivers/misc/habanalabs/memory.c | 1506 +++++++++++++++++ drivers/misc/habanalabs/mmu.c | 604 +++++++ include/uapi/misc/habanalabs.h | 122 +- 13 files changed, 2922 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_v1_0.h create mode 100644 drivers/misc/habanalabs/mmu.c
drivers/misc/habanalabs/Makefile +1 -1
@@ -6,7 +6,7 @@ obj-m := habanalabs.o habanalabs-y := habanalabs_drv.o device.o context.o asid.o habanalabs_ioctl.o \ command_buffer.o hw_queue.o irq.o sysfs.o hwmon.o memory.o \ - command_submission.o + command_submission.o mmu.o include $(src)/goya/Makefile habanalabs-y += $(HL_GOYA_FILES)
drivers/misc/habanalabs/context.c +18 -1
@@ -26,8 +26,10 @@ static void hl_ctx_fini(struct hl_ctx *ctx)for (i =0 ; i <HL_MAX_PENDING_CS ; i++)dma_fence_put (ctx->cs_pending[i]); -if (ctx->asid !=HL_KERNEL_ASID_ID ) +if (ctx->asid !=HL_KERNEL_ASID_ID ) { +hl_vm_ctx_fini (ctx);hl_asid_free (hdev, ctx->asid); + } }void hl_ctx_do_release (struct kref *ref)
@@ -97,6 +99,8 @@ void hl_ctx_free(struct hl_device *hdev, struct hl_ctx *ctx)int hl_ctx_init (struct hl_device *hdev,struct hl_ctx *ctx,bool is_kernel_ctx) { +int rc =0 ; + ctx->hdev = hdev;kref_init (&ctx->refcount);
@@ -114,9 +118,22 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)dev_err (hdev->dev,"No free ASID, failed to create context\n" );return -ENOMEM ; } + + rc =hl_vm_ctx_init (ctx); +if (rc) { +dev_err (hdev->dev,"Failed to init mem ctx module\n" ); + rc = -ENOMEM ; + goto mem_ctx_err; + } }return 0 ; + +mem_ctx_err: +if (ctx->asid !=HL_KERNEL_ASID_ID ) +hl_asid_free (hdev, ctx->asid); + +return rc; }void hl_ctx_get (struct hl_device *hdev,struct hl_ctx *ctx)
drivers/misc/habanalabs/device.c +19 -1
@@ -585,8 +585,10 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,/* Reset the H/W. It will be in idle state after this returns */ hdev->asic_funcs->hw_fini (hdev, hard_reset); -if (hard_reset) +if (hard_reset) { +hl_vm_fini (hdev);hl_eq_reset (hdev, &hdev->event_queue); + }/* Re-initialize PI,CI to 0 in all queues (hw queue, cq) */ hl_hw_queue_reset (hdev, hard_reset);
@@ -647,6 +649,13 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset, goto out_err; } + rc =hl_vm_init (hdev); +if (rc) { +dev_err (hdev->dev, +"Failed to init memory module after hard reset\n" ); + goto out_err; + } +hl_set_max_power (hdev, hdev->max_power); hdev->hard_reset_pending = false;
@@ -828,6 +837,13 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass) hdev->asic_name, hdev->asic_prop.dram_size / 1024 / 1024 / 1024); + rc =hl_vm_init (hdev); +if (rc) { +dev_err (hdev->dev,"Failed to initialize memory module\n" ); + rc =0 ; + goto out_disabled; + } + rc =hl_hwmon_init (hdev);if (rc) {dev_err (hdev->dev,"Failed to initialize hwmon\n" );
@@ -941,6 +957,8 @@ void hl_device_fini(struct hl_device *hdev)/* Reset the H/W. It will be in idle state after this returns */ hdev->asic_funcs->hw_fini (hdev, true); +hl_vm_fini (hdev); +hl_eq_fini (hdev, &hdev->event_queue);for (i =0 ; i < hdev->asic_prop.completion_queues_count ; i++)
drivers/misc/habanalabs/goya/goya.c +391 -0
464 lines not on this page · raw message
drivers/misc/habanalabs/habanalabs.h +195 -0
319 lines not on this page · raw message
drivers/misc/habanalabs/habanalabs_drv.c +1 -1
@@ -202,7 +202,7 @@ int create_hdev(struct hl_device **dev, struct pci_dev *pdev, hdev->reset_on_lockup = reset_on_lockup;/* Parameters for bring-up - set them to defaults */ - hdev->mmu_enable =0 ; + hdev->mmu_enable =1 ; hdev->cpu_enable =1 ; hdev->reset_pcilink =0 ; hdev->config_pll =0 ;
drivers/misc/habanalabs/habanalabs_ioctl.c +2 -1
@@ -18,7 +18,8 @@static const struct hl_ioctl_desc hl_ioctls[] = {HL_IOCTL_DEF (HL_IOCTL_CB , hl_cb_ioctl),HL_IOCTL_DEF (HL_IOCTL_CS , hl_cs_ioctl), -HL_IOCTL_DEF (HL_IOCTL_WAIT_CS , hl_cs_wait_ioctl) +HL_IOCTL_DEF (HL_IOCTL_WAIT_CS , hl_cs_wait_ioctl), +HL_IOCTL_DEF (HL_IOCTL_MEMORY , hl_mem_ioctl) };#define HL_CORE_IOCTL_COUNT ARRAY_SIZE(hl_ioctls)
drivers/misc/habanalabs/include/goya/goya.h +4 -2
@@ -36,12 +36,14 @@#define CPU_FW_IMAGE_SIZE 0x10000000/* 256MB */ #define MMU_PAGE_TABLES_SIZE 0x0E000000/* 224MB */ +#define MMU_CACHE_MNG_SIZE 0x00001000/* 4KB */ #define CPU_PQ_PKT_SIZE 0x00001000/* 4KB */ -#define CPU_PQ_DATA_SIZE 0x01FFF000/* 32MB - 4KB */ +#define CPU_PQ_DATA_SIZE 0x01FFE000/* 32MB - 8KB */ #define CPU_FW_IMAGE_ADDR DRAM_PHYS_BASE#define MMU_PAGE_TABLES_ADDR (CPU_FW_IMAGE_ADDR + CPU_FW_IMAGE_SIZE) -#define CPU_PQ_PKT_ADDR (MMU_PAGE_TABLES_ADDR + MMU_PAGE_TABLES_SIZE) +#define MMU_CACHE_MNG_ADDR (MMU_PAGE_TABLES_ADDR + MMU_PAGE_TABLES_SIZE) +#define CPU_PQ_PKT_ADDR (MMU_CACHE_MNG_ADDR + MMU_CACHE_MNG_SIZE)#define CPU_PQ_DATA_ADDR (CPU_PQ_PKT_ADDR + CPU_PQ_PKT_SIZE)#define DRAM_BASE_ADDR_USER (CPU_PQ_DATA_ADDR + CPU_PQ_DATA_SIZE)
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h new file +45 -0
45 lines not on this page · raw message
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_v1_0.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright 2016-2018 HabanaLabs, Ltd. +* All Rights Reserved. +* +*/ + +#ifndef INCLUDE_MMU_V1_0_H_ +#define INCLUDE_MMU_V1_0_H_ + +#define MMU_HOP0_PA43_12 0x490004 +#define MMU_HOP0_PA49_44 0x490008 +#define MMU_ASID_BUSY 0x490000 + +#endif /* INCLUDE_MMU_V1_0_H_ */
drivers/misc/habanalabs/memory.c +1506 -0
1,521 lines not on this page · raw message
drivers/misc/habanalabs/mmu.c new file +604 -0
509 lines not on this page · raw message
include/uapi/misc/habanalabs.h +121 -1
122 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.
Re: [PATCH 12/15] habanalabs: add virtual memory and MMU modules
Quoted 32 lines · Oded Gabbay
From: Omer Shpigelman <[email protected]>
This patch adds the Virtual Memory and MMU modules.
Goya has an internal MMU which provides process isolation on the internal DDR. The internal MMU also performs translations for transactions that go from Goya to the Host.
The driver is responsible for allocating and freeing memory on the DDR upon user request. It also provides an interface to map and unmap DDR and Host memory to the device address space.
Signed-off-by Omer Shpigelman <[email protected]>Signed-off-by Oded Gabbay <[email protected]>--- drivers/misc/habanalabs/Makefile | 2 +- drivers/misc/habanalabs/context.c | 19 +- drivers/misc/habanalabs/device.c | 20 +- drivers/misc/habanalabs/goya/goya.c | 391 +++++ drivers/misc/habanalabs/habanalabs.h | 195 +++ drivers/misc/habanalabs/habanalabs_drv.c | 2 +- drivers/misc/habanalabs/habanalabs_ioctl.c | 3 +- drivers/misc/habanalabs/include/goya/goya.h | 6 +- .../include/hw_ip/mmu/mmu_general.h | 45 + .../habanalabs/include/hw_ip/mmu/mmu_v1_0.h | 15 + drivers/misc/habanalabs/memory.c | 1506 +++++++++++++++++ drivers/misc/habanalabs/mmu.c | 604 +++++++ include/uapi/misc/habanalabs.h | 122 +- 13 files changed, 2922 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_v1_0.h create mode 100644 drivers/misc/habanalabs/mmu.c
[ ... ]
Quoted 4 lines
drivers/misc/habanalabs/goya/goya.c +0
-0
[ ... ]
drivers/misc/habanalabs/goya/goya.c static u32 goya_non_fatal_events[GOYA_ASYC_EVENT_GROUP_NON_FATAL_SIZE] = { · line 338
Quoted 8 lines
drivers/misc/habanalabs/goya/goya.c +4
-0@@ -265,6 +332,10 @@ static u32 goya_non_fatal_events[GOYA_ASYC_EVENT_GROUP_NON_FATAL_SIZE] = { };static int goya_armcp_info_get (struct hl_device *hdev); +static void goya_mmu_prepare (struct hl_device *hdev,u32 asid); +static int goya_mmu_clear_pgt_range (struct hl_device *hdev); +static int goya_mmu_update_asid_hop0_addr (struct hl_device *hdev,u32 asid, +u64 phys_addr);
Nit: are the static declarations are necessary? Or it's a matter of moving code around?
Quoted 20 lines
drivers/misc/habanalabs/goya/goya.c +10
-0static void goya_get_fixed_properties (struct hl_device *hdev) {@@ -303,6 +374,16 @@ static void goya_get_fixed_properties(struct hl_device *hdev) prop->sram_user_base_address = prop->sram_base_address +SRAM_USER_BASE_OFFSET ; + prop->mmu_pgt_addr =MMU_PAGE_TABLES_ADDR ; +if (hdev->pldm) + prop->mmu_pgt_size =0x800000 ;/* 8MB */ +else + prop->mmu_pgt_size =MMU_PAGE_TABLES_SIZE ; + prop->mmu_pte_size =PTE_SIZE ; + prop->mmu_hop_table_size =HOP_TABLE_SIZE ; + prop->mmu_hop0_tables_total_size =HOP0_TABLES_TOTAL_SIZE ; + prop->dram_page_size =PAGE_SIZE_2MB ; + prop->host_phys_base_address =HOST_PHYS_BASE ; prop->va_space_host_start_address =VA_HOST_SPACE_START ; prop->va_space_host_end_address =VA_HOST_SPACE_END ;
[ ... ]
Quoted 32 lines
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h new file +26
-0@@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright 2016-2018 HabanaLabs, Ltd. +* All Rights Reserved. +* +*/ + +#ifndef INCLUDE_MMU_GENERAL_H_ +#define INCLUDE_MMU_GENERAL_H_ + +#define PAGE_SHIFT_4KB 12 +#define PAGE_SHIFT_2MB 21 +#define PAGE_SIZE_2MB (_AC(1, UL) << PAGE_SHIFT_2MB) +#define PAGE_SIZE_4KB (_AC(1, UL) << PAGE_SHIFT_4KB) + +#define PAGE_PRESENT_MASK 0x0000000000001 +#define SWAP_OUT_MASK 0x0000000000004 +#define LAST_MASK 0x0000000000800 +#define PHYS_ADDR_MASK 0x3FFFFFFFFF000ull +#define HOP0_MASK 0x3000000000000ull +#define HOP1_MASK 0x0FF8000000000ull +#define HOP2_MASK 0x0007FC0000000ull +#define HOP3_MASK 0x000003FE00000 +#define HOP4_MASK 0x00000001FF000 +#define OFFSET_MASK 0x0000000000FFF +
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h line 36
Quoted 10 lines
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h new file +10
-0+#define HOP0_SHIFT 48 +#define HOP1_SHIFT 39 +#define HOP2_SHIFT 30 +#define HOP3_SHIFT 21 +#define HOP4_SHIFT 12 + +#define PTE_PHYS_ADDR_SHIFT 12 +#define PTE_PHYS_ADDR_MASK ~0xFFF + +#define PTE_SIZE sizeof(u64)
I suspect some architectures define PTE_SIZE in arch/*/include/asm Probably you'd want to namespace this.
Quoted 65 lines
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h new file +9
-0+#define HOP_TABLE_SIZE PAGE_SIZE_4KB +#define HOP0_TABLES_TOTAL_SIZE (HOP_TABLE_SIZE * MAX_ASID) + +#define MMU_HOP0_PA43_12_SHIFT 12 +#define MMU_HOP0_PA49_44_SHIFT (12 + 32) + +#define MMU_CONFIG_TIMEOUT_USEC 2000/* 2 ms */ + +#endif /* INCLUDE_MMU_GENERAL_H_ */ drivers/misc/habanalabs/memory.c +42
-0@@ -5,12 +5,1193 @@* All Rights Reserved. */ +#include <uapi/misc/habanalabs.h> #include "habanalabs.h" +#include "include/hw_ip/mmu/mmu_general.h" #include <linux/sched.h> #include <linux/uaccess.h> #include <linux/genalloc.h> +#define HL_MMU_DEBUG 0 + +/* +* The va ranges in context object contain a list with the available chunks of +* device virtual memory. +* There is one range for host allocations and one for DRAM allocations. +* +* On initialization each range contains one chunk of all of its available +* virtual range which is a half of the total device virtual range. +* +* On each mapping of physical pages, a suitable virtual range chunk (with a +* minimum size) is selected from the list. If the chunk size equals the +* requested size, the chunk is returned. Otherwise, the chunk is split into +* two chunks - one to return as result and a remainder to stay in the list. +* +* On each Unmapping of a virtual address, the relevant virtual chunk is +* returned to the list. The chunk is added to the list and if its edges match +* the edges of the adjacent chunks (means a contiguous chunk can be created), +* the chunks are merged. +* +* On finish, the list is checked to have only one chunk of all the relevant +* virtual range (which is a half of the device total virtual range). +* If not (means not all mappings were unmapped), a warning is printed. +*/ + +/** +* alloc_device_memory - allocate device memory +* +* @ctx : current context +* @args : host parameters containing the requested size +* @ret_handle : result handle +* +* This function does the following: +* - Allocate the requested size rounded up to 2MB pages +* - Return unique handle +*/ +static int alloc_device_memory (struct hl_ctx *ctx,struct hl_mem_in *args, +u32 *ret_handle) +{ +struct hl_device *hdev = ctx->hdev;
drivers/misc/habanalabs/memory.c line 65
Quoted 10 lines
drivers/misc/habanalabs/memory.c +10
-0+struct hl_vm *vm = &hdev->vm; +struct hl_vm_phys_pg_list *phys_pg_list; +struct hl_vm_phys_pg *phys_pg, *tmp; +u64 paddr =0 ; +u32 total_size, num_pgs, page_size, page_shift; +int handle, rc, i; +bool contiguous; + + page_size = hdev->asic_prop.dram_page_size; + page_shift =__ffs (page_size);
Maybe it's worth storing page_shift in the asi_prop and calculating page_size.
Quoted 20 lines
drivers/misc/habanalabs/memory.c +20
-0+ num_pgs = (args->alloc.mem_size + (page_size -1 )) >> page_shift; + total_size = num_pgs << page_shift; + + contiguous = args->flags &HL_MEM_CONTIGUOUS ; + +if (contiguous) { + paddr = (u64 )gen_pool_alloc (vm->dram_pg_pool, total_size); +if (!paddr) { +dev_err (hdev->dev, +"failed to allocate %u huge contiguous pages\n" , + num_pgs); +return -ENOMEM ; + } + } + + phys_pg_list =kzalloc (sizeof (*phys_pg_list),GFP_KERNEL ); +if (!phys_pg_list) { + rc = -ENOMEM ; + goto page_list_err; + }
drivers/misc/habanalabs/memory.c line 95
Quoted 10 lines
drivers/misc/habanalabs/memory.c +10
-0+ + phys_pg_list->vm_type =VM_TYPE_PHYS_LIST ; + phys_pg_list->asid = ctx->asid; + phys_pg_list->total_size = total_size; + phys_pg_list->flags = args->flags; + phys_pg_list->contiguous = contiguous; +INIT_LIST_HEAD (&phys_pg_list->list); + +for (i =0 ; i < num_pgs ; i++) { + phys_pg =kzalloc (sizeof (*phys_pg),GFP_KERNEL );
Consider adding *phys_pgs to phys_pg_list using kcalloc() before the loop.
Quoted 65 lines
drivers/misc/habanalabs/memory.c +65
-0+if (!phys_pg) { + rc = -ENOMEM ; + goto pb_err; + } + + phys_pg->page_size = page_size; + +if (phys_pg_list->contiguous) { + phys_pg->paddr = paddr + i * phys_pg->page_size; + }else { + phys_pg->paddr = + (u64 )gen_pool_alloc (vm->dram_pg_pool, + phys_pg->page_size); +if (!phys_pg->paddr) { +dev_err (hdev->dev,"ioctl failed to allocate page\n" ); +kfree (phys_pg); + rc = -ENOMEM ; + goto pb_err; + } + } + +list_add_tail (&phys_pg->node, &phys_pg_list->list); + } + +spin_lock (&vm->idr_lock); + handle =idr_alloc (&vm->phys_pg_list_handles, phys_pg_list,1 ,0 , +GFP_ATOMIC ); +spin_unlock (&vm->idr_lock); + +if (handle <0 ) { +dev_err (hdev->dev,"Failed to get handle for page\n" ); + rc = -EFAULT ; + goto idr_err; + } + +for (i =0 ; i < num_pgs ; i++) +kref_get (&vm->dram_pg_pool_refcount); + + phys_pg_list->handle = handle; + +atomic64_add (phys_pg_list->total_size, &ctx->dram_phys_mem); +atomic64_add (phys_pg_list->total_size, &hdev->dram_used_mem); + + *ret_handle = handle; + +return 0 ; + +idr_err: +pb_err: +list_for_each_entry_safe (phys_pg, tmp, &phys_pg_list->list, node) { +if (!phys_pg_list->contiguous) +gen_pool_free (vm->dram_pg_pool, phys_pg->paddr, + phys_pg->page_size); + +list_del (&phys_pg->node); +kfree (phys_pg); + } + +kfree (phys_pg_list); +page_list_err: +if (contiguous) +gen_pool_free (vm->dram_pg_pool, paddr, total_size); + +return rc; +}
[ ... ]
Quoted 40 lines
drivers/misc/habanalabs/memory.c +40
-0+/** +* free_phys_pg_list - free physical page list +* +* @hdev : habanalabs device structure +* @phys_pg_list : physical page list to free +* +* This function does the following: +* - Iterate over the list and free each physical block structure +* - In case of allocated memory, return the physical memory to the general pool +* - Free the hl_vm_phys_pg_list structure +*/ +static void free_phys_pg_list (struct hl_device *hdev, +struct hl_vm_phys_pg_list *phys_pg_list) +{ +struct hl_vm *vm = &hdev->vm; +struct hl_vm_phys_pg *phys_pg, *tmp; +u32 num_pgs; +bool first = true; +int i; + +list_for_each_entry_safe (phys_pg, tmp, &phys_pg_list->list, node) { +/* +* this if statement is relevant only when called from +* hl_vm_ctx_fini() and free_device_memory() +*/ +if (!phys_pg_list->created_from_userptr) { +if ((phys_pg_list->contiguous) && (first)) { + first = false; +gen_pool_free (vm->dram_pg_pool, + phys_pg->paddr, + phys_pg_list->total_size); + + num_pgs = phys_pg_list->total_size >> +__ffs (hdev->asic_prop.dram_page_size); + +for (i =0 ; i < num_pgs ; i++) +kref_put (&vm->dram_pg_pool_refcount, + dram_pg_pool_do_release); + + }else if (!phys_pg_list->contiguous) {
drivers/misc/habanalabs/memory.c line 305
Quoted 10 lines
drivers/misc/habanalabs/memory.c +10
-0+gen_pool_free (vm->dram_pg_pool, phys_pg->paddr, + phys_pg->page_size); +kref_put (&vm->dram_pg_pool_refcount, + dram_pg_pool_do_release); + } + } + +list_del (&phys_pg->node); +kfree (phys_pg); + }
Unless I'm missing something this can be simplified a bit:
if (!phys_pg_list->created_from_userptr) {
for (i = 0; i < num_pgs ; i++)
kref_put(&vm->dram_pg_pool_refcount,
dram_pg_pool_do_release);
if (phys_pg_list->contiguous)
gen_pool_free(vm->dram_pg_pool, phys_pg->paddr,
phys_pg_list->total_size);
}list_for_each_entry_safe(phys_pg, tmp, &phys_pg_list->list, node) {
if (!phys_pg_list->created_from_userptr &&
!phys_pg_list->contiguous)
gen_pool_free(vm->dram_pg_pool, phys_pg->paddr,
phys_pg->page_size);
list_del(&phys_pg->node);
kfree(phys_pg);
}nd with phys_pg's array hanging from phys_pg_list it would be even simpler ;-)
Quoted 4 lines
drivers/misc/habanalabs/memory.c +4
-0+ +kfree (phys_pg_list); +} +
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 12/15] habanalabs: add virtual memory and MMU modules
Quoted 47 lines · Mike Rapoport
Quoted 32 lines · Oded Gabbay
From: Omer Shpigelman <[email protected]>
This patch adds the Virtual Memory and MMU modules.
Goya has an internal MMU which provides process isolation on the internal DDR. The internal MMU also performs translations for transactions that go from Goya to the Host.
The driver is responsible for allocating and freeing memory on the DDR upon user request. It also provides an interface to map and unmap DDR and Host memory to the device address space.
Signed-off-by Omer Shpigelman <[email protected]>Signed-off-by Oded Gabbay <[email protected]>--- drivers/misc/habanalabs/Makefile | 2 +- drivers/misc/habanalabs/context.c | 19 +- drivers/misc/habanalabs/device.c | 20 +- drivers/misc/habanalabs/goya/goya.c | 391 +++++ drivers/misc/habanalabs/habanalabs.h | 195 +++ drivers/misc/habanalabs/habanalabs_drv.c | 2 +- drivers/misc/habanalabs/habanalabs_ioctl.c | 3 +- drivers/misc/habanalabs/include/goya/goya.h | 6 +- .../include/hw_ip/mmu/mmu_general.h | 45 + .../habanalabs/include/hw_ip/mmu/mmu_v1_0.h | 15 + drivers/misc/habanalabs/memory.c | 1506 +++++++++++++++++ drivers/misc/habanalabs/mmu.c | 604 +++++++ include/uapi/misc/habanalabs.h | 122 +- 13 files changed, 2922 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_v1_0.h create mode 100644 drivers/misc/habanalabs/mmu.c[ ... ]
Quoted 4 lines
drivers/misc/habanalabs/goya/goya.c +0
-0[ ... ]
Quoted 3 lines
drivers/misc/habanalabs/goya/goya.c +0
-0@@ -265,6 +332,10 @@ static u32 goya_non_fatal_events[GOYA_ASYC_EVENT_GROUP_NON_FATAL_SIZE] = { };
Quoted 8 lines
drivers/misc/habanalabs/goya/goya.c static u32 goya_non_fatal_events[GOYA_ASYC_EVENT_GROUP_NON_FATAL_SIZE] = { · line 338
Quoted 5 lines
drivers/misc/habanalabs/goya/goya.c +4
-0static int goya_armcp_info_get (struct hl_device *hdev); +static void goya_mmu_prepare (struct hl_device *hdev,u32 asid); +static int goya_mmu_clear_pgt_range (struct hl_device *hdev); +static int goya_mmu_update_asid_hop0_addr (struct hl_device *hdev,u32 asid, +u64 phys_addr);Nit: are the static declarations are necessary? Or it's a matter of moving code around?
Honestly, it's a bit of an issue moving them now. Those function call other functions and if I will need to move the first ones I will need to move the others as well and may end in some circular dependency.
Quoted 61 lines
Quoted 21 lines
drivers/misc/habanalabs/goya/goya.c +10
-0static void goya_get_fixed_properties (struct hl_device *hdev) {@@ -303,6 +374,16 @@ static void goya_get_fixed_properties(struct hl_device *hdev) prop->sram_user_base_address = prop->sram_base_address +SRAM_USER_BASE_OFFSET ; + prop->mmu_pgt_addr =MMU_PAGE_TABLES_ADDR ; +if (hdev->pldm) + prop->mmu_pgt_size =0x800000 ;/* 8MB */ +else + prop->mmu_pgt_size =MMU_PAGE_TABLES_SIZE ; + prop->mmu_pte_size =PTE_SIZE ; + prop->mmu_hop_table_size =HOP_TABLE_SIZE ; + prop->mmu_hop0_tables_total_size =HOP0_TABLES_TOTAL_SIZE ; + prop->dram_page_size =PAGE_SIZE_2MB ; + prop->host_phys_base_address =HOST_PHYS_BASE ; prop->va_space_host_start_address =VA_HOST_SPACE_START ; prop->va_space_host_end_address =VA_HOST_SPACE_END ;[ ... ]
Quoted 37 lines
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h new file +31
-0@@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright 2016-2018 HabanaLabs, Ltd. +* All Rights Reserved. +* +*/ + +#ifndef INCLUDE_MMU_GENERAL_H_ +#define INCLUDE_MMU_GENERAL_H_ + +#define PAGE_SHIFT_4KB 12 +#define PAGE_SHIFT_2MB 21 +#define PAGE_SIZE_2MB (_AC(1, UL) << PAGE_SHIFT_2MB) +#define PAGE_SIZE_4KB (_AC(1, UL) << PAGE_SHIFT_4KB) + +#define PAGE_PRESENT_MASK 0x0000000000001 +#define SWAP_OUT_MASK 0x0000000000004 +#define LAST_MASK 0x0000000000800 +#define PHYS_ADDR_MASK 0x3FFFFFFFFF000ull +#define HOP0_MASK 0x3000000000000ull +#define HOP1_MASK 0x0FF8000000000ull +#define HOP2_MASK 0x0007FC0000000ull +#define HOP3_MASK 0x000003FE00000 +#define HOP4_MASK 0x00000001FF000 +#define OFFSET_MASK 0x0000000000FFF + +#define HOP0_SHIFT 48 +#define HOP1_SHIFT 39 +#define HOP2_SHIFT 30 +#define HOP3_SHIFT 21 +#define HOP4_SHIFT 12
Quoted 9 lines
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h line 36
Quoted 5 lines
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h new file +5
-0+ +#define PTE_PHYS_ADDR_SHIFT 12 +#define PTE_PHYS_ADDR_MASK ~0xFFF + +#define PTE_SIZE sizeof(u64)I suspect some architectures define
PTE_SIZEinarch/*/include/asmProbably you'd want to namespace this.
Fixed
Quoted 103 lines
Quoted 65 lines
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h new file +9
-0+#define HOP_TABLE_SIZE PAGE_SIZE_4KB +#define HOP0_TABLES_TOTAL_SIZE (HOP_TABLE_SIZE * MAX_ASID) + +#define MMU_HOP0_PA43_12_SHIFT 12 +#define MMU_HOP0_PA49_44_SHIFT (12 + 32) + +#define MMU_CONFIG_TIMEOUT_USEC 2000/* 2 ms */ + +#endif /* INCLUDE_MMU_GENERAL_H_ */ drivers/misc/habanalabs/memory.c +42
-0@@ -5,12 +5,1193 @@* All Rights Reserved. */ +#include <uapi/misc/habanalabs.h> #include "habanalabs.h" +#include "include/hw_ip/mmu/mmu_general.h" #include <linux/sched.h> #include <linux/uaccess.h> #include <linux/genalloc.h> +#define HL_MMU_DEBUG 0 + +/* +* The va ranges in context object contain a list with the available chunks of +* device virtual memory. +* There is one range for host allocations and one for DRAM allocations. +* +* On initialization each range contains one chunk of all of its available +* virtual range which is a half of the total device virtual range. +* +* On each mapping of physical pages, a suitable virtual range chunk (with a +* minimum size) is selected from the list. If the chunk size equals the +* requested size, the chunk is returned. Otherwise, the chunk is split into +* two chunks - one to return as result and a remainder to stay in the list. +* +* On each Unmapping of a virtual address, the relevant virtual chunk is +* returned to the list. The chunk is added to the list and if its edges match +* the edges of the adjacent chunks (means a contiguous chunk can be created), +* the chunks are merged. +* +* On finish, the list is checked to have only one chunk of all the relevant +* virtual range (which is a half of the device total virtual range). +* If not (means not all mappings were unmapped), a warning is printed. +*/ + +/** +* alloc_device_memory - allocate device memory +* +* @ctx : current context +* @args : host parameters containing the requested size +* @ret_handle : result handle +* +* This function does the following: +* - Allocate the requested size rounded up to 2MB pages +* - Return unique handle +*/ +static int alloc_device_memory (struct hl_ctx *ctx,struct hl_mem_in *args, +u32 *ret_handle) +{ +struct hl_device *hdev = ctx->hdev;drivers/misc/habanalabs/memory.c line 65
Quoted 10 lines
drivers/misc/habanalabs/memory.c +10
-0+struct hl_vm *vm = &hdev->vm; +struct hl_vm_phys_pg_list *phys_pg_list; +struct hl_vm_phys_pg *phys_pg, *tmp; +u64 paddr =0 ; +u32 total_size, num_pgs, page_size, page_shift; +int handle, rc, i; +bool contiguous; + + page_size = hdev->asic_prop.dram_page_size; + page_shift =__ffs (page_size);Maybe it's worth storing
page_shiftin theasi_propand calculatingpage_size.Quoted 24 lines
drivers/misc/habanalabs/memory.c +24
-0+ num_pgs = (args->alloc.mem_size + (page_size -1 )) >> page_shift; + total_size = num_pgs << page_shift; + + contiguous = args->flags &HL_MEM_CONTIGUOUS ; + +if (contiguous) { + paddr = (u64 )gen_pool_alloc (vm->dram_pg_pool, total_size); +if (!paddr) { +dev_err (hdev->dev, +"failed to allocate %u huge contiguous pages\n" , + num_pgs); +return -ENOMEM ; + } + } + + phys_pg_list =kzalloc (sizeof (*phys_pg_list),GFP_KERNEL ); +if (!phys_pg_list) { + rc = -ENOMEM ; + goto page_list_err; + } + + phys_pg_list->vm_type =VM_TYPE_PHYS_LIST ; + phys_pg_list->asid = ctx->asid; + phys_pg_list->total_size = total_size;
Quoted 8 lines
drivers/misc/habanalabs/memory.c line 95
Quoted 6 lines
drivers/misc/habanalabs/memory.c +6
-0+ phys_pg_list->flags = args->flags; + phys_pg_list->contiguous = contiguous; +INIT_LIST_HEAD (&phys_pg_list->list); + +for (i =0 ; i < num_pgs ; i++) { + phys_pg =kzalloc (sizeof (*phys_pg),GFP_KERNEL );Consider adding
*phys_pgstophys_pg_listusingkcalloc()before the loop.
Fixed in a re-factor to make it array
Quoted 140 lines
Quoted 66 lines
drivers/misc/habanalabs/memory.c +65
-0+if (!phys_pg) { + rc = -ENOMEM ; + goto pb_err; + } + + phys_pg->page_size = page_size; + +if (phys_pg_list->contiguous) { + phys_pg->paddr = paddr + i * phys_pg->page_size; + }else { + phys_pg->paddr = + (u64 )gen_pool_alloc (vm->dram_pg_pool, + phys_pg->page_size); +if (!phys_pg->paddr) { +dev_err (hdev->dev,"ioctl failed to allocate page\n" ); +kfree (phys_pg); + rc = -ENOMEM ; + goto pb_err; + } + } + +list_add_tail (&phys_pg->node, &phys_pg_list->list); + } + +spin_lock (&vm->idr_lock); + handle =idr_alloc (&vm->phys_pg_list_handles, phys_pg_list,1 ,0 , +GFP_ATOMIC ); +spin_unlock (&vm->idr_lock); + +if (handle <0 ) { +dev_err (hdev->dev,"Failed to get handle for page\n" ); + rc = -EFAULT ; + goto idr_err; + } + +for (i =0 ; i < num_pgs ; i++) +kref_get (&vm->dram_pg_pool_refcount); + + phys_pg_list->handle = handle; + +atomic64_add (phys_pg_list->total_size, &ctx->dram_phys_mem); +atomic64_add (phys_pg_list->total_size, &hdev->dram_used_mem); + + *ret_handle = handle; + +return 0 ; + +idr_err: +pb_err: +list_for_each_entry_safe (phys_pg, tmp, &phys_pg_list->list, node) { +if (!phys_pg_list->contiguous) +gen_pool_free (vm->dram_pg_pool, phys_pg->paddr, + phys_pg->page_size); + +list_del (&phys_pg->node); +kfree (phys_pg); + } + +kfree (phys_pg_list); +page_list_err: +if (contiguous) +gen_pool_free (vm->dram_pg_pool, paddr, total_size); + +return rc; +}[ ... ]
Quoted 40 lines
drivers/misc/habanalabs/memory.c +40
-0+/** +* free_phys_pg_list - free physical page list +* +* @hdev : habanalabs device structure +* @phys_pg_list : physical page list to free +* +* This function does the following: +* - Iterate over the list and free each physical block structure +* - In case of allocated memory, return the physical memory to the general pool +* - Free the hl_vm_phys_pg_list structure +*/ +static void free_phys_pg_list (struct hl_device *hdev, +struct hl_vm_phys_pg_list *phys_pg_list) +{ +struct hl_vm *vm = &hdev->vm; +struct hl_vm_phys_pg *phys_pg, *tmp; +u32 num_pgs; +bool first = true; +int i; + +list_for_each_entry_safe (phys_pg, tmp, &phys_pg_list->list, node) { +/* +* this if statement is relevant only when called from +* hl_vm_ctx_fini() and free_device_memory() +*/ +if (!phys_pg_list->created_from_userptr) { +if ((phys_pg_list->contiguous) && (first)) { + first = false; +gen_pool_free (vm->dram_pg_pool, + phys_pg->paddr, + phys_pg_list->total_size); + + num_pgs = phys_pg_list->total_size >> +__ffs (hdev->asic_prop.dram_page_size); + +for (i =0 ; i < num_pgs ; i++) +kref_put (&vm->dram_pg_pool_refcount, + dram_pg_pool_do_release); + + }else if (!phys_pg_list->contiguous) {drivers/misc/habanalabs/memory.c line 305
Quoted 10 lines
drivers/misc/habanalabs/memory.c +10
-0+gen_pool_free (vm->dram_pg_pool, phys_pg->paddr, + phys_pg->page_size); +kref_put (&vm->dram_pg_pool_refcount, + dram_pg_pool_do_release); + } + } + +list_del (&phys_pg->node); +kfree (phys_pg); + }Unless I'm missing something this can be simplified a bit:
if (!phys_pg_list->created_from_userptr) { for (i = 0; i < num_pgs ; i++) kref_put(&vm->dram_pg_pool_refcount, dram_pg_pool_do_release); if (phys_pg_list->contiguous) gen_pool_free(vm->dram_pg_pool, phys_pg->paddr, phys_pg_list->total_size); }list_for_each_entry_safe(phys_pg, tmp, &phys_pg_list->list, node) { if (!phys_pg_list->created_from_userptr && !phys_pg_list->contiguous) gen_pool_free(vm->dram_pg_pool, phys_pg->paddr, phys_pg->page_size); list_del(&phys_pg->node); kfree(phys_pg); }
Quoted 2 lines
nd with phys_pg's array hanging from
phys_pg_listit would be even simpler ;-)
Definitely agree. Fixed with a refactor to make it array instead of list, as there is no real need for list here.
Quoted 10 lines
drivers/misc/habanalabs/memory.c line 161
Quoted 5 lines
drivers/misc/habanalabs/memory.c +4
-0+ +kfree (phys_pg_list); +} +--
Sincerely yours,
Mike.
PATCH 13/15 habanalabs: implement INFO IOCTL
In reply to Oded GabbayThis patch implements the INFO IOCTL. That IOCTL is used by the user to query information that is relevant/needed by the user in order to submit deep learning jobs to Goya.
The information is divided into several categories, such as H/W IP, Events that happened, DDR usage and more.
--- drivers/misc/habanalabs/goya/goya.c | 6 + drivers/misc/habanalabs/habanalabs.h | 2 + drivers/misc/habanalabs/habanalabs_ioctl.c | 132 +++++++++++++++++++++ include/uapi/misc/habanalabs.h | 76 +++++++++++- 4 files changed, 215 insertions(+), 1 deletion(-)
drivers/misc/habanalabs/goya/goya.c +6 -0
@@ -6120,6 +6120,11 @@ static void goya_hw_queues_unlock(struct hl_device *hdev)spin_unlock (&goya->hw_queues_lock); } +static u32 goya_get_pci_id (struct hl_device *hdev) +{ +return hdev->pdev->device; +} +int goya_get_eeprom_data (struct hl_device *hdev,void *data,size_t max_size) {struct goya_device *goya = hdev->asic_specific;
@@ -6217,6 +6222,7 @@ static const struct hl_asic_funcs goya_funcs = { .soft_reset_late_init = goya_soft_reset_late_init, .hw_queues_lock = goya_hw_queues_lock, .hw_queues_unlock = goya_hw_queues_unlock, + .get_pci_id = goya_get_pci_id, .get_eeprom_data = goya_get_eeprom_data, .send_cpu_message = goya_send_cpu_message };
drivers/misc/habanalabs/habanalabs.h +2 -0
@@ -462,6 +462,7 @@ enum hl_pll_frequency {* @soft_reset_late_init: perform certain actions needed after soft reset. * @hw_queues_lock: acquire H/W queues lock. * @hw_queues_unlock: release H/W queues lock. +* @get_pci_id: retrieve PCI ID. * @get_eeprom_data: retrieve EEPROM data from F/W. * @send_cpu_message: send buffer to ArmCP. */
@@ -530,6 +531,7 @@ struct hl_asic_funcs {int (*soft_reset_late_init)(struct hl_device *hdev);void (*hw_queues_lock)(struct hl_device *hdev);void (*hw_queues_unlock)(struct hl_device *hdev); +u32 (*get_pci_id)(struct hl_device *hdev);int (*get_eeprom_data)(struct hl_device *hdev,void *data,size_t max_size); int (*send_cpu_message)(struct hl_device *hdev, u32 *msg,
drivers/misc/habanalabs/habanalabs_ioctl.c +132 -0
142 lines not on this page · raw message
include/uapi/misc/habanalabs.h +75 -1
94 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 14/15 habanalabs: add debugfs support
In reply to Oded GabbayThis patch adds debugfs support to the driver. It allows the user-space to display information that is contained in the internal structures of the driver, such as:
- active command submissions
- active user virtual memory mappings
- number of allocated command buffers
It also enables the user to perform reads and writes through Goya's PCI bars.
--- .../ABI/testing/debugfs-driver-habanalabs | 127 ++ drivers/misc/habanalabs/Makefile | 2 + drivers/misc/habanalabs/command_buffer.c | 4 + drivers/misc/habanalabs/command_submission.c | 12 + drivers/misc/habanalabs/debugfs.c | 1069 +++++++++++++++++ drivers/misc/habanalabs/device.c | 6 + drivers/misc/habanalabs/goya/goya.c | 108 ++ drivers/misc/habanalabs/goya/goyaP.h | 5 + drivers/misc/habanalabs/habanalabs.h | 191 +++ drivers/misc/habanalabs/habanalabs_drv.c | 16 +- drivers/misc/habanalabs/memory.c | 8 + 11 files changed, 1546 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/debugfs-driver-habanalabs create mode 100644 drivers/misc/habanalabs/debugfs.c
Documentation/ABI/testing/debugfs-driver-habanalabs new file +127 -0
@@ -0,0 +1,127 @@ +What: /sys/kernel/debug/habanalabs/hl<n>/addr +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets the device address to be used for read or write through + PCI bar. The acceptable value is a string that starts with "0x" + +What: /sys/kernel/debug/habanalabs/hl<n>/command_buffers +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Displays a list with information about the currently allocated + command buffers + +What: /sys/kernel/debug/habanalabs/hl<n>/command_submission +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Displays a list with information about the currently active + command submissions + +What: /sys/kernel/debug/habanalabs/hl<n>/command_submission_jobs +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Displays a list with detailed information about each JOB (CB) of + each active command submission + +What: /sys/kernel/debug/habanalabs/hl<n>/data32 +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Allows the root user to read or write directly through the + device's PCI bar. Writing to this file generates a write + transaction while reading from the file generates a read + transcation. This custom interface is needed (instead of using + the generic Linux user-space PCI mapping) because the DDR bar + is very small compared to the DDR memory and only the driver can + move the bar before and after the transaction + +What: /sys/kernel/debug/habanalabs/hl<n>/device +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Enables the root user to set the device to specific state. + Valid values are "disable", "enable", "suspend", "resume". + User can read this property to see the valid values + +What: /sys/kernel/debug/habanalabs/hl<n>/i2c_addr +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets I2C device address for I2C transaction that is generated + by the device's CPU + +What: /sys/kernel/debug/habanalabs/hl<n>/i2c_bus +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets I2C bus address for I2C transaction that is generated by + the device's CPU + +What: /sys/kernel/debug/habanalabs/hl<n>/i2c_data +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Triggers an I2C transaction that is generated by the device's + CPU. Writing to this file generates a write transaction while + reading from the file generates a read transcation + +What: /sys/kernel/debug/habanalabs/hl<n>/i2c_reg +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets I2C register id for I2C transaction that is generated by + the device's CPU + +What: /sys/kernel/debug/habanalabs/hl<n>/led0 +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets the state of the first S/W led on the device + +What: /sys/kernel/debug/habanalabs/hl<n>/led1 +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets the state of the second S/W led on the device + +What: /sys/kernel/debug/habanalabs/hl<n>/led2 +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets the state of the third S/W led on the device + +What: /sys/kernel/debug/habanalabs/hl<n>/mmu +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Displays the hop values and physical address for a given ASID + and virtual address. The user should write the ASID and VA into + the file and then read the file to get the result. + e.g. to display info about VA 0x1000 for ASID 1 you need to do: + echo "1 0x1000" > /sys/kernel/debug/habanalabs/hl0/mmu + +What: /sys/kernel/debug/habanalabs/hl<n>/set_power_state +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Sets the PCI power state. Valid values are "1" for D0 and "2" + for D3Hot + +What: /sys/kernel/debug/habanalabs/hl<n>/userptr +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Displays a list with information about the currently user + pointers (user virtual addresses) that are pinned and mapped + to DMA addresses + +What: /sys/kernel/debug/habanalabs/hl<n>/vm +Date: Jan 2019 +KernelVersion: 5.1 +Contact: [email protected] +Description: Displays a list with information about all the active virtual + address mappings per ASID +
drivers/misc/habanalabs/Makefile +2 -0
@@ -8,5 +8,7 @@ habanalabs-y := habanalabs_drv.o device.o context.o asid.o habanalabs_ioctl.o \ command_buffer.o hw_queue.o irq.o sysfs.o hwmon.o memory.o \ command_submission.o mmu.o +habanalabs-$(CONFIG_DEBUG_FS) += debugfs.o + include $(src)/goya/Makefile habanalabs-y += $(HL_GOYA_FILES)
drivers/misc/habanalabs/command_buffer.c +4 -0
@@ -36,6 +36,8 @@ static void cb_release(struct kref *ref) cb = container_of(ref, struct hl_cb, refcount); hdev = cb->hdev; +hl_debugfs_remove_cb (cb); +cb_do_release (hdev, cb); }
@@ -141,6 +143,8 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr, *handle = cb->id |HL_MMAP_CB_MASK ; *handle <<=PAGE_SHIFT ; +hl_debugfs_add_cb (cb); +return 0 ; release_cb:
drivers/misc/habanalabs/command_submission.c +12 -0
@@ -153,6 +153,8 @@ static void free_job(struct hl_device *hdev, struct hl_cs_job *job)list_del (&job->cs_node);spin_unlock (&cs->job_lock); +hl_debugfs_remove_job (hdev, job); +if (job->ext_queue)cs_put (cs);
@@ -215,6 +217,12 @@ static void cs_do_release(struct kref *ref) } } +/* +* Must be called before hl_ctx_put because inside we use ctx to get +* the device +*/ +hl_debugfs_remove_cs (cs); +hl_ctx_put (cs->ctx);if (cs->timedout)
@@ -483,6 +491,8 @@ static int _hl_cs_ioctl(struct hl_fpriv *hpriv, void __user *chunks, *cs_seq = cs->sequence; +hl_debugfs_add_cs (cs); +/* Validate ALL the CS chunks before submitting the CS */ for (i =0 , parse_cnt =0 ; i < num_chunks ; i++, parse_cnt++) {struct hl_cs_chunk *chunk = &cs_chunk_array[i];
@@ -531,6 +541,8 @@ static int _hl_cs_ioctl(struct hl_fpriv *hpriv, void __user *chunks,if (job->ext_queue)cs_get (cs); +hl_debugfs_add_job (hdev, job); + rc =cs_parser (hpriv, job);if (rc) { dev_err(hdev->dev,
drivers/misc/habanalabs/debugfs.c new file +1069 -0
1,069 lines not on this page · raw message
drivers/misc/habanalabs/device.c +6 -0
@@ -22,6 +22,8 @@ static void hpriv_release(struct kref *ref)put_pid (hpriv->taskpid); +hl_debugfs_remove_file (hpriv); +mutex_destroy (&hpriv->restore_phase_mutex);kfree (hpriv);
@@ -807,6 +809,8 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass) goto free_cb_pool; } +hl_debugfs_add_device (hdev); + rc = hdev->asic_funcs->hw_init (hdev);if (rc) {dev_err (hdev->dev,"failed to initialize the H/W\n" );
@@ -936,6 +940,8 @@ void hl_device_fini(struct hl_device *hdev)device_late_fini (hdev); +hl_debugfs_remove_device (hdev); +hl_sysfs_fini (hdev);/*
drivers/misc/habanalabs/goya/goya.c +108 -0
144 lines not on this page · raw message
drivers/misc/habanalabs/goya/goyaP.h +5 -0
@@ -136,6 +136,10 @@ struct goya_device {u32 hw_cap_initialized; }; +int goya_debugfs_i2c_read (struct hl_device *hdev,u8 i2c_bus, +u8 i2c_addr,u8 i2c_reg,u32 *val); +int goya_debugfs_i2c_write (struct hl_device *hdev,u8 i2c_bus, +u8 i2c_addr,u8 i2c_reg,u32 val);int goya_test_cpu_queue (struct hl_device *hdev);int goya_send_cpu_message (struct hl_device *hdev,u32 *msg,u16 len,u32 timeout,long *result);
@@ -146,6 +150,7 @@ long goya_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr);long goya_get_pwm_info (struct hl_device *hdev,int sensor_index,u32 attr);void goya_set_pwm_info (struct hl_device *hdev,int sensor_index,u32 attr,long value); +void goya_debugfs_led_set (struct hl_device *hdev,u8 led,u8 state);void goya_set_pll_profile (struct hl_device *hdev,enum hl_pll_frequency freq);int goya_add_device_attr (struct hl_device *hdev);void goya_remove_device_attr (struct hl_device *hdev);
drivers/misc/habanalabs/habanalabs.h +191 -0
287 lines not on this page · raw message
drivers/misc/habanalabs/habanalabs_drv.c +14 -2
@@ -153,6 +153,8 @@ int hl_device_open(struct inode *inode, struct file *filp)*/ hl_device_set_frequency (hdev,PLL_HIGH ); +hl_debugfs_add_file (hpriv); +return 0 ; out_err:
@@ -425,17 +427,20 @@ static int __init hl_init(void) goto remove_major; } +hl_debugfs_init (); + rc =pci_register_driver (&hl_pci_driver);if (rc) {pr_err ("habanalabs: failed to register pci device\n" ); - goto remove_class; + goto remove_debugfs; }pr_debug ("habanalabs: driver loaded\n" );return 0 ; -remove_class: +remove_debugfs: +hl_debugfs_fini ();class_destroy (hl_class); remove_major:unregister_chrdev_region (MKDEV (hl_major,0 ),HL_MAX_MINORS );
@@ -450,6 +455,13 @@ static void __exit hl_exit(void) {pci_unregister_driver (&hl_pci_driver); +/* +* Removing debugfs must be after all devices or simulator devices +* have been removed because otherwise we get a bug in the +* debugfs module for referencing NULL objects +*/ +hl_debugfs_fini (); +class_destroy (hl_class);unregister_chrdev_region (MKDEV (hl_major,0 ),HL_MAX_MINORS );
drivers/misc/habanalabs/memory.c +8 -0
@@ -1284,6 +1284,8 @@ int hl_pin_host_memory(struct hl_device *hdev, u64 addr, u32 size, goto free_sgt; } +hl_debugfs_add_userptr (hdev, userptr); +return 0 ; free_sgt:
@@ -1309,6 +1311,8 @@ int hl_unpin_host_memory(struct hl_device *hdev, struct hl_userptr *userptr) {struct page **pages; +hl_debugfs_remove_userptr (hdev, userptr); +if (userptr->dma_mapped) hdev->asic_funcs->hl_dma_unmap_sg(hdev, userptr->sgt->sgl,
@@ -1470,6 +1474,8 @@ int hl_vm_ctx_init_with_ranges(struct hl_ctx *ctx, u64 host_range_start, goto dram_vm_err; } +hl_debugfs_add_ctx_mem_hash (hdev, ctx); +return 0 ; dram_vm_err:
@@ -1590,6 +1596,8 @@ void hl_vm_ctx_fini(struct hl_ctx *ctx)struct hlist_node *tmp_node;int i; +hl_debugfs_remove_ctx_mem_hash (hdev, ctx); +if (!hash_empty (ctx->mem_hash))dev_notice (hdev->dev,"ctx is freed while it has va in use\n" );
Signature · 1 line
2.17.1
PATCH 15/15 Update MAINTAINERS and CREDITS with habanalabs info
In reply to Oded GabbayThe habanalabs driver was written from scratch from the very first days of Habana and is maintained by Oded Gabbay.
--- CREDITS | 2 +- MAINTAINERS | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
CREDITS +1 -1
@@ -1222,7 +1222,7 @@ S: Brazil N: Oded Gabbay E: [email protected] -D: AMD KFD maintainer +D: HabanaLabs and AMD KFD maintainer S: 12 Shraga Raphaeli S: Petah-Tikva, 4906418 S: Israel
MAINTAINERS +9 -0
@@ -6641,6 +6641,15 @@ F: drivers/clocksource/h8300_*.c F: drivers/clk/h8300/ F: drivers/irqchip/irq-renesas-h8*.c +HABANALABS PCI DRIVER +M: Oded Gabbay <[email protected]> +T: git https://github.com/HabanaAI/linux.git +S: Supported +F: drivers/misc/habanalabs/ +F: include/uapi/misc/habanalabs.h +F: Documentation/ABI/testing/sysfs-driver-habanalabs +F: Documentation/ABI/testing/debugfs-driver-habanalabs + HACKRF MEDIA DRIVER M: Antti Palosaari <[email protected]> L: [email protected]
Signature · 1 line
2.17.1
Hi,
Quoted 23 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Habana is a leading startup in the emerging AI processor space and we have already started production of our first Goya inference processor PCIe card and delivered it to customers. The Goya processor silicon has been tested since June of 2018 and is production-qualified by now. The Gaudi training processor solution is slated to sample in the second quarter of 2019.
This patch-set contains the kernel driver for Habana's AI Processors (AIP) that are designed to accelerate Deep Learning inference and training workloads. The current version supports only the Goya processor and support for Gaudi will be upstreamed after the ASIC will be available to customers.
The Goya processor has been designed from the ground up for deep learning inference workloads. It comprises a cluster of eight fully programmable Tensor Processing Cores (TPC). The TPC core is a VLIW SIMD vector processor with ISA and hardware that was tailored to serve deep learning workloads efficiently.
[ ... ]
Quoted 1 line
I would appricate any feedback, question and/or review.
I've looked at the patches 1,3-5 for now, it seems patch 2 still didn't make it to lore.kernel.org.
FWIW, I think it's a good solid work, unless you spoil it in patches 6-14 ;-)
As a general note, maybe drivers/misc is not the most appropriate place for such a complex beast. How about drivers/accelerator/ai?
Quoted 318 lines
p.s. for those who prefer to clone the tree instead of looking at the emails, you can grab a copy from our company's page in GitHub:
https://github.com/HabanaAI/linux/releases/tag/hl_patchset_v1
Thanks,
OdedOded Gabbay (14):
habanalabs: add skeleton driver
habanalabs: add Goya registers header files
habanalabs: add basic Goya support
habanalabs: add context and ASID modules
habanalabs: add command buffer module
habanalabs: add basic Goya h/w initialization
habanalabs: add h/w queues module
habanalabs: add event queue and interrupts
habanalabs: add sysfs and hwmon support
habanalabs: add device reset support
habanalabs: add command submission module
habanalabs: implement INFO IOCTL
habanalabs: add debugfs support
UpdateMAINTAINERSand CREDITS with habanalabs infoOmer Shpigelman (1):
habanalabs: add virtual memory and MMU modulesCREDITS | 2 +- .../ABI/testing/debugfs-driver-habanalabs | 127 + .../ABI/testing/sysfs-driver-habanalabs | 190 + MAINTAINERS | 9 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/habanalabs/Kconfig | 22 + drivers/misc/habanalabs/Makefile | 14 + drivers/misc/habanalabs/asid.c | 58 + drivers/misc/habanalabs/command_buffer.c | 425 + drivers/misc/habanalabs/command_submission.c | 799 ++ drivers/misc/habanalabs/context.c | 216 + drivers/misc/habanalabs/debugfs.c | 1069 ++ drivers/misc/habanalabs/device.c | 1097 ++ drivers/misc/habanalabs/goya/Makefile | 3 + drivers/misc/habanalabs/goya/goya.c | 6347 ++++++++++++ drivers/misc/habanalabs/goya/goyaP.h | 161 + drivers/misc/habanalabs/goya/goya_hwmgr.c | 306 + drivers/misc/habanalabs/goya/goya_security.c | 2999 ++++++ drivers/misc/habanalabs/habanalabs.h | 1464 +++ drivers/misc/habanalabs/habanalabs_drv.c | 474 + drivers/misc/habanalabs/habanalabs_ioctl.c | 237 + drivers/misc/habanalabs/hw_queue.c | 654 ++ drivers/misc/habanalabs/hwmon.c | 449 + .../include/goya/asic_reg/cpu_ca53_cfg_regs.h | 213 + .../include/goya/asic_reg/cpu_if_regs.h | 110 + .../include/goya/asic_reg/cpu_pll_regs.h | 186 + .../include/goya/asic_reg/ddr_mc_ch0_regs.h | 1158 +++ .../include/goya/asic_reg/ddr_mc_ch1_regs.h | 1158 +++ .../include/goya/asic_reg/ddr_misc_ch0_regs.h | 156 + .../include/goya/asic_reg/ddr_misc_ch1_regs.h | 156 + .../include/goya/asic_reg/dma_ch_0_regs.h | 512 + .../include/goya/asic_reg/dma_ch_1_regs.h | 512 + .../include/goya/asic_reg/dma_ch_2_regs.h | 512 + .../include/goya/asic_reg/dma_ch_3_regs.h | 512 + .../include/goya/asic_reg/dma_ch_4_regs.h | 512 + .../include/goya/asic_reg/dma_macro_regs.h | 242 + .../include/goya/asic_reg/dma_nrtr_regs.h | 380 + .../include/goya/asic_reg/dma_qm_0_regs.h | 543 + .../include/goya/asic_reg/dma_qm_1_regs.h | 543 + .../include/goya/asic_reg/dma_qm_2_regs.h | 543 + .../include/goya/asic_reg/dma_qm_3_regs.h | 543 + .../include/goya/asic_reg/dma_qm_4_regs.h | 543 + .../include/goya/asic_reg/gic_regs.h | 9079 +++++++++++++++++ .../include/goya/asic_reg/goya_blocks.h | 1372 +++ .../include/goya/asic_reg/goya_masks.h | 262 + .../include/goya/asic_reg/goya_regs.h | 119 + .../include/goya/asic_reg/ic_pll_regs.h | 186 + .../include/goya/asic_reg/mc_pll_regs.h | 186 + .../include/goya/asic_reg/mme1_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme2_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme3_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme4_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme5_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme6_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme_cmdq_regs.h | 431 + .../include/goya/asic_reg/mme_qm_regs.h | 543 + .../include/goya/asic_reg/mme_regs.h | 2422 +++++ .../include/goya/asic_reg/mmu_regs.h | 158 + .../include/goya/asic_reg/pci_nrtr_regs.h | 380 + .../include/goya/asic_reg/pcie_aux_regs.h | 476 + .../include/goya/asic_reg/pcie_dbi_regs.h | 2909 ++++++ .../goya/asic_reg/psoc_emmc_pll_regs.h | 186 + .../goya/asic_reg/psoc_global_conf_regs.h | 1119 ++ .../include/goya/asic_reg/psoc_mme_pll_regs.h | 186 + .../include/goya/asic_reg/psoc_pci_pll_regs.h | 186 + .../include/goya/asic_reg/psoc_spi_regs.h | 427 + .../goya/asic_reg/sram_y0_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x4_rtr_regs.h | 215 + .../include/goya/asic_reg/stlb_regs.h | 133 + .../include/goya/asic_reg/sync_mngr_regs.h | 4930 +++++++++ .../include/goya/asic_reg/tpc0_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc0_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc0_eml_cfg_regs.h | 580 ++ .../include/goya/asic_reg/tpc0_nrtr_regs.h | 380 + .../include/goya/asic_reg/tpc0_qm_regs.h | 543 + .../include/goya/asic_reg/tpc1_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc1_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc1_qm_regs.h | 543 + .../include/goya/asic_reg/tpc1_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc2_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc2_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc2_qm_regs.h | 543 + .../include/goya/asic_reg/tpc2_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc3_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc3_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc3_qm_regs.h | 543 + .../include/goya/asic_reg/tpc3_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc4_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc4_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc4_qm_regs.h | 543 + .../include/goya/asic_reg/tpc4_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc5_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc5_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc5_qm_regs.h | 543 + .../include/goya/asic_reg/tpc5_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc6_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc6_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc6_qm_regs.h | 543 + .../include/goya/asic_reg/tpc6_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc7_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc7_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc7_nrtr_regs.h | 380 + .../include/goya/asic_reg/tpc7_qm_regs.h | 543 + .../include/goya/asic_reg/tpc_pll_regs.h | 186 + drivers/misc/habanalabs/include/goya/goya.h | 117 + .../include/goya/goya_async_events.h | 186 + .../habanalabs/include/goya/goya_boot_if.h | 32 + .../habanalabs/include/goya/goya_packets.h | 234 + .../habanalabs/include/habanalabs_device_if.h | 397 + .../include/hw_ip/mmu/mmu_general.h | 45 + .../habanalabs/include/hw_ip/mmu/mmu_v1_0.h | 15 + drivers/misc/habanalabs/irq.c | 325 + drivers/misc/habanalabs/memory.c | 1714 ++++ drivers/misc/habanalabs/mmu.c | 604 ++ drivers/misc/habanalabs/sysfs.c | 690 ++ include/uapi/misc/habanalabs.h | 412 + 145 files changed, 99610 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/debugfs-driver-habanalabs create mode 100644 Documentation/ABI/testing/sysfs-driver-habanalabs create mode 100644 drivers/misc/habanalabs/Kconfig create mode 100644 drivers/misc/habanalabs/Makefile create mode 100644 drivers/misc/habanalabs/asid.c create mode 100644 drivers/misc/habanalabs/command_buffer.c create mode 100644 drivers/misc/habanalabs/command_submission.c create mode 100644 drivers/misc/habanalabs/context.c create mode 100644 drivers/misc/habanalabs/debugfs.c create mode 100644 drivers/misc/habanalabs/device.c create mode 100644 drivers/misc/habanalabs/goya/Makefile create mode 100644 drivers/misc/habanalabs/goya/goya.c create mode 100644 drivers/misc/habanalabs/goya/goyaP.h create mode 100644 drivers/misc/habanalabs/goya/goya_hwmgr.c create mode 100644 drivers/misc/habanalabs/goya/goya_security.c create mode 100644 drivers/misc/habanalabs/habanalabs.h create mode 100644 drivers/misc/habanalabs/habanalabs_drv.c create mode 100644 drivers/misc/habanalabs/habanalabs_ioctl.c create mode 100644 drivers/misc/habanalabs/hw_queue.c create mode 100644 drivers/misc/habanalabs/hwmon.c create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/cpu_ca53_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/cpu_if_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/cpu_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_mc_ch0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_mc_ch1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_misc_ch0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_misc_ch1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_2_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_3_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_4_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_macro_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_2_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_3_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_4_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/gic_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/goya_blocks.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/goya_masks.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/goya_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ic_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mc_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme5_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme6_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mmu_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/pci_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/pcie_aux_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/pcie_dbi_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_emmc_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_global_conf_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_mme_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_pci_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_spi_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/stlb_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sync_mngr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_eml_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/goya.h create mode 100644 drivers/misc/habanalabs/include/goya/goya_async_events.h create mode 100644 drivers/misc/habanalabs/include/goya/goya_boot_if.h create mode 100644 drivers/misc/habanalabs/include/goya/goya_packets.h create mode 100644 drivers/misc/habanalabs/include/habanalabs_device_if.h create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_v1_0.h create mode 100644 drivers/misc/habanalabs/irq.c create mode 100644 drivers/misc/habanalabs/memory.c create mode 100644 drivers/misc/habanalabs/mmu.c create mode 100644 drivers/misc/habanalabs/sysfs.c create mode 100644 include/uapi/misc/habanalabs.hSignature · 1 line
2.17.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 30 lines · Mike Rapoport
Hi,
Quoted 23 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Habana is a leading startup in the emerging AI processor space and we have already started production of our first Goya inference processor PCIe card and delivered it to customers. The Goya processor silicon has been tested since June of 2018 and is production-qualified by now. The Gaudi training processor solution is slated to sample in the second quarter of 2019.
This patch-set contains the kernel driver for Habana's AI Processors (AIP) that are designed to accelerate Deep Learning inference and training workloads. The current version supports only the Goya processor and support for Gaudi will be upstreamed after the ASIC will be available to customers.
The Goya processor has been designed from the ground up for deep learning inference workloads. It comprises a cluster of eight fully programmable Tensor Processing Cores (TPC). The TPC core is a VLIW SIMD vector processor with ISA and hardware that was tailored to serve deep learning workloads efficiently.
[ ... ]
Quoted 7 lines
Quoted 1 line
I would appricate any feedback, question and/or review.
I've looked at the patches 1,3-5 for now, it seems patch 2 still didn't make it to lore.kernel.org.
FWIW, I think it's a good solid work, unless you spoil it in patches 6-14 ;-)
Thanks! I will go over your comments in the next few days.
Quoted 3 lines
As a general note, maybe
drivers/miscis not the most appropriate place for such a complex beast. How aboutdrivers/accelerator/ai?
I talked to Greg about it a couple of weeks ago and we both agreed that drivers/misc is the correct place for this driver, at this point in time.
I don't see any reason why it couldn't be moved later on, when there will be other drivers, but for now I just don't see the need to open a new subsystem in the kernel.
Oded
Quoted 324 lines
Quoted 316 lines
p.s. for those who prefer to clone the tree instead of looking at the emails, you can grab a copy from our company's page in GitHub:
https://github.com/HabanaAI/linux/releases/tag/hl_patchset_v1
Thanks,
OdedOded Gabbay (14):
habanalabs: add skeleton driver
habanalabs: add Goya registers header files
habanalabs: add basic Goya support
habanalabs: add context and ASID modules
habanalabs: add command buffer module
habanalabs: add basic Goya h/w initialization
habanalabs: add h/w queues module
habanalabs: add event queue and interrupts
habanalabs: add sysfs and hwmon support
habanalabs: add device reset support
habanalabs: add command submission module
habanalabs: implement INFO IOCTL
habanalabs: add debugfs support
UpdateMAINTAINERSand CREDITS with habanalabs infoOmer Shpigelman (1):
habanalabs: add virtual memory and MMU modulesCREDITS | 2 +- .../ABI/testing/debugfs-driver-habanalabs | 127 + .../ABI/testing/sysfs-driver-habanalabs | 190 + MAINTAINERS | 9 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/habanalabs/Kconfig | 22 + drivers/misc/habanalabs/Makefile | 14 + drivers/misc/habanalabs/asid.c | 58 + drivers/misc/habanalabs/command_buffer.c | 425 + drivers/misc/habanalabs/command_submission.c | 799 ++ drivers/misc/habanalabs/context.c | 216 + drivers/misc/habanalabs/debugfs.c | 1069 ++ drivers/misc/habanalabs/device.c | 1097 ++ drivers/misc/habanalabs/goya/Makefile | 3 + drivers/misc/habanalabs/goya/goya.c | 6347 ++++++++++++ drivers/misc/habanalabs/goya/goyaP.h | 161 + drivers/misc/habanalabs/goya/goya_hwmgr.c | 306 + drivers/misc/habanalabs/goya/goya_security.c | 2999 ++++++ drivers/misc/habanalabs/habanalabs.h | 1464 +++ drivers/misc/habanalabs/habanalabs_drv.c | 474 + drivers/misc/habanalabs/habanalabs_ioctl.c | 237 + drivers/misc/habanalabs/hw_queue.c | 654 ++ drivers/misc/habanalabs/hwmon.c | 449 + .../include/goya/asic_reg/cpu_ca53_cfg_regs.h | 213 + .../include/goya/asic_reg/cpu_if_regs.h | 110 + .../include/goya/asic_reg/cpu_pll_regs.h | 186 + .../include/goya/asic_reg/ddr_mc_ch0_regs.h | 1158 +++ .../include/goya/asic_reg/ddr_mc_ch1_regs.h | 1158 +++ .../include/goya/asic_reg/ddr_misc_ch0_regs.h | 156 + .../include/goya/asic_reg/ddr_misc_ch1_regs.h | 156 + .../include/goya/asic_reg/dma_ch_0_regs.h | 512 + .../include/goya/asic_reg/dma_ch_1_regs.h | 512 + .../include/goya/asic_reg/dma_ch_2_regs.h | 512 + .../include/goya/asic_reg/dma_ch_3_regs.h | 512 + .../include/goya/asic_reg/dma_ch_4_regs.h | 512 + .../include/goya/asic_reg/dma_macro_regs.h | 242 + .../include/goya/asic_reg/dma_nrtr_regs.h | 380 + .../include/goya/asic_reg/dma_qm_0_regs.h | 543 + .../include/goya/asic_reg/dma_qm_1_regs.h | 543 + .../include/goya/asic_reg/dma_qm_2_regs.h | 543 + .../include/goya/asic_reg/dma_qm_3_regs.h | 543 + .../include/goya/asic_reg/dma_qm_4_regs.h | 543 + .../include/goya/asic_reg/gic_regs.h | 9079 +++++++++++++++++ .../include/goya/asic_reg/goya_blocks.h | 1372 +++ .../include/goya/asic_reg/goya_masks.h | 262 + .../include/goya/asic_reg/goya_regs.h | 119 + .../include/goya/asic_reg/ic_pll_regs.h | 186 + .../include/goya/asic_reg/mc_pll_regs.h | 186 + .../include/goya/asic_reg/mme1_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme2_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme3_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme4_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme5_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme6_rtr_regs.h | 876 ++ .../include/goya/asic_reg/mme_cmdq_regs.h | 431 + .../include/goya/asic_reg/mme_qm_regs.h | 543 + .../include/goya/asic_reg/mme_regs.h | 2422 +++++ .../include/goya/asic_reg/mmu_regs.h | 158 + .../include/goya/asic_reg/pci_nrtr_regs.h | 380 + .../include/goya/asic_reg/pcie_aux_regs.h | 476 + .../include/goya/asic_reg/pcie_dbi_regs.h | 2909 ++++++ .../goya/asic_reg/psoc_emmc_pll_regs.h | 186 + .../goya/asic_reg/psoc_global_conf_regs.h | 1119 ++ .../include/goya/asic_reg/psoc_mme_pll_regs.h | 186 + .../include/goya/asic_reg/psoc_pci_pll_regs.h | 186 + .../include/goya/asic_reg/psoc_spi_regs.h | 427 + .../goya/asic_reg/sram_y0_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y0_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y1_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y2_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y3_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y4_x4_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x0_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x1_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x2_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x3_rtr_regs.h | 215 + .../goya/asic_reg/sram_y5_x4_rtr_regs.h | 215 + .../include/goya/asic_reg/stlb_regs.h | 133 + .../include/goya/asic_reg/sync_mngr_regs.h | 4930 +++++++++ .../include/goya/asic_reg/tpc0_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc0_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc0_eml_cfg_regs.h | 580 ++ .../include/goya/asic_reg/tpc0_nrtr_regs.h | 380 + .../include/goya/asic_reg/tpc0_qm_regs.h | 543 + .../include/goya/asic_reg/tpc1_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc1_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc1_qm_regs.h | 543 + .../include/goya/asic_reg/tpc1_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc2_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc2_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc2_qm_regs.h | 543 + .../include/goya/asic_reg/tpc2_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc3_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc3_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc3_qm_regs.h | 543 + .../include/goya/asic_reg/tpc3_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc4_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc4_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc4_qm_regs.h | 543 + .../include/goya/asic_reg/tpc4_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc5_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc5_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc5_qm_regs.h | 543 + .../include/goya/asic_reg/tpc5_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc6_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc6_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc6_qm_regs.h | 543 + .../include/goya/asic_reg/tpc6_rtr_regs.h | 848 ++ .../include/goya/asic_reg/tpc7_cfg_regs.h | 2110 ++++ .../include/goya/asic_reg/tpc7_cmdq_regs.h | 431 + .../include/goya/asic_reg/tpc7_nrtr_regs.h | 380 + .../include/goya/asic_reg/tpc7_qm_regs.h | 543 + .../include/goya/asic_reg/tpc_pll_regs.h | 186 + drivers/misc/habanalabs/include/goya/goya.h | 117 + .../include/goya/goya_async_events.h | 186 + .../habanalabs/include/goya/goya_boot_if.h | 32 + .../habanalabs/include/goya/goya_packets.h | 234 + .../habanalabs/include/habanalabs_device_if.h | 397 + .../include/hw_ip/mmu/mmu_general.h | 45 + .../habanalabs/include/hw_ip/mmu/mmu_v1_0.h | 15 + drivers/misc/habanalabs/irq.c | 325 + drivers/misc/habanalabs/memory.c | 1714 ++++ drivers/misc/habanalabs/mmu.c | 604 ++ drivers/misc/habanalabs/sysfs.c | 690 ++ include/uapi/misc/habanalabs.h | 412 + 145 files changed, 99610 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/debugfs-driver-habanalabs create mode 100644 Documentation/ABI/testing/sysfs-driver-habanalabs create mode 100644 drivers/misc/habanalabs/Kconfig create mode 100644 drivers/misc/habanalabs/Makefile create mode 100644 drivers/misc/habanalabs/asid.c create mode 100644 drivers/misc/habanalabs/command_buffer.c create mode 100644 drivers/misc/habanalabs/command_submission.c create mode 100644 drivers/misc/habanalabs/context.c create mode 100644 drivers/misc/habanalabs/debugfs.c create mode 100644 drivers/misc/habanalabs/device.c create mode 100644 drivers/misc/habanalabs/goya/Makefile create mode 100644 drivers/misc/habanalabs/goya/goya.c create mode 100644 drivers/misc/habanalabs/goya/goyaP.h create mode 100644 drivers/misc/habanalabs/goya/goya_hwmgr.c create mode 100644 drivers/misc/habanalabs/goya/goya_security.c create mode 100644 drivers/misc/habanalabs/habanalabs.h create mode 100644 drivers/misc/habanalabs/habanalabs_drv.c create mode 100644 drivers/misc/habanalabs/habanalabs_ioctl.c create mode 100644 drivers/misc/habanalabs/hw_queue.c create mode 100644 drivers/misc/habanalabs/hwmon.c create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/cpu_ca53_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/cpu_if_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/cpu_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_mc_ch0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_mc_ch1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_misc_ch0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ddr_misc_ch1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_2_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_3_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_ch_4_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_macro_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_0_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_1_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_2_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_3_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/dma_qm_4_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/gic_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/goya_blocks.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/goya_masks.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/goya_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/ic_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mc_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme5_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme6_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mme_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/mmu_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/pci_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/pcie_aux_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/pcie_dbi_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_emmc_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_global_conf_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_mme_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_pci_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_spi_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y0_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y1_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y2_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y3_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y4_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x0_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sram_y5_x4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/stlb_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/sync_mngr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_eml_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc0_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc1_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc2_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc3_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc4_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc5_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc6_rtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_cfg_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_cmdq_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_nrtr_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc7_qm_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/tpc_pll_regs.h create mode 100644 drivers/misc/habanalabs/include/goya/goya.h create mode 100644 drivers/misc/habanalabs/include/goya/goya_async_events.h create mode 100644 drivers/misc/habanalabs/include/goya/goya_boot_if.h create mode 100644 drivers/misc/habanalabs/include/goya/goya_packets.h create mode 100644 drivers/misc/habanalabs/include/habanalabs_device_if.h create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h create mode 100644 drivers/misc/habanalabs/include/hw_ip/mmu/mmu_v1_0.h create mode 100644 drivers/misc/habanalabs/irq.c create mode 100644 drivers/misc/habanalabs/memory.c create mode 100644 drivers/misc/habanalabs/mmu.c create mode 100644 drivers/misc/habanalabs/sysfs.c create mode 100644 include/uapi/misc/habanalabs.hQuoted 3 lines
--
2.17.1--
Sincerely yours,
Mike.
Hi,
Quoted 13 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Habana is a leading startup in the emerging AI processor space and we have already started production of our first Goya inference processor PCIe card and delivered it to customers. The Goya processor silicon has been tested since June of 2018 and is production-qualified by now. The Gaudi training processor solution is slated to sample in the second quarter of 2019.
Quoted 5 lines
This patch-set contains the kernel driver for Habana's AI Processors (AIP) that are designed to accelerate Deep Learning inference and training workloads. The current version supports only the Goya processor and support for Gaudi will be upstreamed after the ASIC will be available to customers.
[...]
As others have mentioned, thanks for the amount of background and information in this patch set, it's great to see.
Some have pointed out style and formatting issues, I'm not going to do that here but I do have some higher-level comments:
- There's a whole bunch of register definition headers. Outside of
GPUs, traditionally we don't include the full sets unless they're needed in the driver since they tend to be very verbose.
- I see a good amount of HW setup code that's mostly just writing
hardcoded values to a large number of registers. I don't have any specific recommendation on how to do it better, but doing as much as possible of this through on-device firmware tends to be a little cleaner (or rather, hides it from the kernel. :). I don't know if that fits your design though.
- Are there any pointers to the userspace pieces that are used to run
on this card, or any kind of test suites that can be used when someone has the hardware and is looking to change the driver?
But, I think the largest question I have (for a broader audience) is:
I predict that we will see a handful of these kind of devices over the upcoming future -- definitely from ML accelerators but maybe also for other kinds of processing, where there's a command-based, buffer-based setup sending workloads to an offload engine and getting results back. While the first waves will all look different due to design trade-offs made in isolation, I think it makes sense to group them in one bucket instead of merging them through drivers/misc, if nothing else to encourage more cross-collaboration over time. First steps in figuring out long-term suitable frameworks is to get a survey of a few non-shared implementations.
So, I'd like to propose a drivers/accel drivers subtree, and I'd be happy to bootstrap it with a small group (@Dave Airlie: I think your input from GPU land be very useful, want to join in?). Individual drivers maintained by existing maintainers, of course.
I think it might make sense to move the CAPI/OpenCAPI drivers over as well -- not necessarily to change those drivers, but to group them with the rest as more show up.
-Olof
-Olof
Quoted 27 lines · Olof Johansson
Hi,
Quoted 13 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Habana is a leading startup in the emerging AI processor space and we have already started production of our first Goya inference processor PCIe card and delivered it to customers. The Goya processor silicon has been tested since June of 2018 and is production-qualified by now. The Gaudi training processor solution is slated to sample in the second quarter of 2019.
Quoted 5 lines
This patch-set contains the kernel driver for Habana's AI Processors (AIP) that are designed to accelerate Deep Learning inference and training workloads. The current version supports only the Goya processor and support for Gaudi will be upstreamed after the ASIC will be available to customers.
[...]
As others have mentioned, thanks for the amount of background and information in this patch set, it's great to see.
Quoted 6 lines
Some have pointed out style and formatting issues, I'm not going to do that here but I do have some higher-level comments:
- There's a whole bunch of register definition headers. Outside of
GPUs, traditionally we don't include the full sets unless they're needed in the driver since they tend to be very verbose.
And it is not the entire list :)
I trimmed down the files to only the files I actually use registers from. I didn't went into those files and removed from them the registers I don't use.
I hope this isn't a hard requirement because that's really a dirty work.
Quoted 6 lines
- I see a good amount of HW setup code that's mostly just writing
hardcoded values to a large number of registers. I don't have any specific recommendation on how to do it better, but doing as much as possible of this through on-device firmware tends to be a little cleaner (or rather, hides it from the kernel. :). I don't know if that fits your design though.
This is actually not according to our design. In our design, the host driver is the "king" of the device and we prefer to have all initializations which can be done from the host to be done from the host.
I know its not a "technical" hard reason, but on the other hand, I don't think that's really something so terrible that it can't be done from the driver.
Quoted 3 lines
- Are there any pointers to the userspace pieces that are used to run
on this card, or any kind of test suites that can be used when someone has the hardware and is looking to change the driver?
Not right now. I do hope we can release a package with some pre-compiled libraries and binaries that can be used to work vs. the driver, but I don't believe it will be open-source. At least, not in 2019.
Quoted 14 lines
But, I think the largest question I have (for a broader audience) is:
I predict that we will see a handful of these kind of devices over the upcoming future -- definitely from ML accelerators but maybe also for other kinds of processing, where there's a command-based, buffer-based setup sending workloads to an offload engine and getting results back. While the first waves will all look different due to design trade-offs made in isolation, I think it makes sense to group them in one bucket instead of merging them through
drivers/misc, if nothing else to encourage more cross-collaboration over time. First steps in figuring out long-term suitable frameworks is to get a survey of a few non-shared implementations.
Quoted 8 lines
So, I'd like to propose a
drivers/acceldrivers subtree, and I'd be happy to bootstrap it with a small group (@Dave Airlie: I think your input from GPU land be very useful, want to join in?). Individual drivers maintained by existing maintainers, of course.I think it might make sense to move the CAPI/OpenCAPI drivers over as well -- not necessarily to change those drivers, but to group them with the rest as more show up.
I actually prefer not going down that path, at least not from the start. AFAIK, there is no other device driver in the kernel for AI acceleration and I don't want to presume I know all the answers for such devices.
You have said it yourself: there will be many devices and they won't be similar, at least not in the next few years. So I think that trying to setup a subsystem for this now would be a premature optimization.
Oded
Quoted 7 lines
(quoted diff) +0
-2-Olof -Olof
Quoted 36 lines · Oded Gabbay
Quoted 27 lines · Olof Johansson
Hi,
Quoted 13 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Habana is a leading startup in the emerging AI processor space and we have already started production of our first Goya inference processor PCIe card and delivered it to customers. The Goya processor silicon has been tested since June of 2018 and is production-qualified by now. The Gaudi training processor solution is slated to sample in the second quarter of 2019.
Quoted 5 lines
This patch-set contains the kernel driver for Habana's AI Processors (AIP) that are designed to accelerate Deep Learning inference and training workloads. The current version supports only the Goya processor and support for Gaudi will be upstreamed after the ASIC will be available to customers.
[...]
As others have mentioned, thanks for the amount of background and information in this patch set, it's great to see.
Quoted 6 lines
Some have pointed out style and formatting issues, I'm not going to do that here but I do have some higher-level comments:
- There's a whole bunch of register definition headers. Outside of
GPUs, traditionally we don't include the full sets unless they're needed in the driver since they tend to be very verbose.
Quoted 5 lines
And it is not the entire list :)
I trimmed down the files to only the files I actually use registers from. I didn't went into those files and removed from them the registers I don't use.
I hope this isn't a hard requirement because that's really a dirty work.
Yeah, it's always awkward to do this kind of cleanup. drivers/staging was created in part for allowing a driver to go through this while in-tree, if that helps.
Quoted 7 lines
Quoted 6 lines
- I see a good amount of HW setup code that's mostly just writing
hardcoded values to a large number of registers. I don't have any specific recommendation on how to do it better, but doing as much as possible of this through on-device firmware tends to be a little cleaner (or rather, hides it from the kernel. :). I don't know if that fits your design though.
Quoted 7 lines
This is actually not according to our design. In our design, the host driver is the "king" of the device and we prefer to have all initializations which can be done from the host to be done from the host.
I know its not a "technical" hard reason, but on the other hand, I don't think that's really something so terrible that it can't be done from the driver.
This is why I was asking. It makes for a lot of boilerplate in the driver, all with magic constants. They usually end up in some other layer, but they're often constants no matter what.
Quoted 8 lines
Quoted 3 lines
- Are there any pointers to the userspace pieces that are used to run
on this card, or any kind of test suites that can be used when someone has the hardware and is looking to change the driver?Not right now. I do hope we can release a package with some pre-compiled libraries and binaries that can be used to work vs. the driver, but I don't believe it will be open-source. At least, not in 2019.
See my other reply, having the lowest layer of the interface from userspace open might be an approach worth exploring.
Quoted 18 lines
Quoted 18 lines
But, I think the largest question I have (for a broader audience) is:
I predict that we will see a handful of these kind of devices over the upcoming future -- definitely from ML accelerators but maybe also for other kinds of processing, where there's a command-based, buffer-based setup sending workloads to an offload engine and getting results back. While the first waves will all look different due to design trade-offs made in isolation, I think it makes sense to group them in one bucket instead of merging them through
drivers/misc, if nothing else to encourage more cross-collaboration over time. First steps in figuring out long-term suitable frameworks is to get a survey of a few non-shared implementations.So, I'd like to propose a
drivers/acceldrivers subtree, and I'd be happy to bootstrap it with a small group (@Dave Airlie: I think your input from GPU land be very useful, want to join in?). Individual drivers maintained by existing maintainers, of course.
Quoted 8 lines
Quoted 3 lines
I think it might make sense to move the CAPI/OpenCAPI drivers over as well -- not necessarily to change those drivers, but to group them with the rest as more show up.
I actually prefer not going down that path, at least not from the start. AFAIK, there is no other device driver in the kernel for AI acceleration and I don't want to presume I know all the answers for such devices.
I'm not saying you have to have those answers, I'm just saying let's start grouping them now so we at least have one place to look at them, especially since we now have more than 2.
Quoted 3 lines
You have said it yourself: there will be many devices and they won't be similar, at least not in the next few years. So I think that trying to setup a subsystem for this now would be a premature optimization.
It is initially not about building the shared subsystem as much as grouping the general type of devices together, get someone to keep an overall view across them, and encouraging more work between vendors such as cross-review, etc.
-Olof
Quoted 13 lines · Olof Johansson
But, I think the largest question I have (for a broader audience) is:
I predict that we will see a handful of these kind of devices over the upcoming future -- definitely from ML accelerators but maybe also for other kinds of processing, where there's a command-based, buffer-based setup sending workloads to an offload engine and getting results back. While the first waves will all look different due to design trade-offs made in isolation, I think it makes sense to group them in one bucket instead of merging them through
drivers/misc, if nothing else to encourage more cross-collaboration over time. First steps in figuring out long-term suitable frameworks is to get a survey of a few non-shared implementations.
Quoted 8 lines
So, I'd like to propose a
drivers/acceldrivers subtree, and I'd be happy to bootstrap it with a small group (@Dave Airlie: I think your input from GPU land be very useful, want to join in?). Individual drivers maintained by existing maintainers, of course.I think it might make sense to move the CAPI/OpenCAPI drivers over as well -- not necessarily to change those drivers, but to group them with the rest as more show up.
For cxl/ocxl, I have no objection to moving to this new subtree if that's what we all agree to do. (what do people do about UAPI headers in this situation? keep them where they are in misc/?)
If we do go ahead and set up this new subtree, perhaps we can use the mailing list I set up at [email protected] but we haven't really started using...
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Quoted 23 lines · On Thu, 24 Jan 2019 12:03:06 +1100 Andrew Donnellan…
Quoted 13 lines · Olof Johansson
But, I think the largest question I have (for a broader audience) is:
I predict that we will see a handful of these kind of devices over the upcoming future -- definitely from ML accelerators but maybe also for other kinds of processing, where there's a command-based, buffer-based setup sending workloads to an offload engine and getting results back. While the first waves will all look different due to design trade-offs made in isolation, I think it makes sense to group them in one bucket instead of merging them through
drivers/misc, if nothing else to encourage more cross-collaboration over time. First steps in figuring out long-term suitable frameworks is to get a survey of a few non-shared implementations.Quoted 8 lines
So, I'd like to propose a
drivers/acceldrivers subtree, and I'd be happy to bootstrap it with a small group (@Dave Airlie: I think your input from GPU land be very useful, want to join in?). Individual drivers maintained by existing maintainers, of course.I think it might make sense to move the CAPI/OpenCAPI drivers over as well -- not necessarily to change those drivers, but to group them with the rest as more show up.
Quoted 8 lines
For cxl/ocxl, I have no objection to moving to this new subtree if that's what we all agree to do. (what do people do about UAPI headers in this situation? keep them where they are in misc/?)
If we do go ahead and set up this new subtree, perhaps we can use the mailing list I set up at [email protected] but we haven't really started using...
Assuming the concensus falls behind this...
I'll push this for the CCIX drivers as well as those start to turn up.
This particularly driver had passed me by until this email so great to get the heads up via that list!
Sounds like a good plan in general to me.
Jonathan
Quoted 20 lines · Andrew Donnellan
Quoted 18 lines · Olof Johansson
But, I think the largest question I have (for a broader audience) is:
I predict that we will see a handful of these kind of devices over the upcoming future -- definitely from ML accelerators but maybe also for other kinds of processing, where there's a command-based, buffer-based setup sending workloads to an offload engine and getting results back. While the first waves will all look different due to design trade-offs made in isolation, I think it makes sense to group them in one bucket instead of merging them through
drivers/misc, if nothing else to encourage more cross-collaboration over time. First steps in figuring out long-term suitable frameworks is to get a survey of a few non-shared implementations.So, I'd like to propose a
drivers/acceldrivers subtree, and I'd be happy to bootstrap it with a small group (@Dave Airlie: I think your input from GPU land be very useful, want to join in?). Individual drivers maintained by existing maintainers, of course.
Quoted 7 lines
Quoted 3 lines
I think it might make sense to move the CAPI/OpenCAPI drivers over as well -- not necessarily to change those drivers, but to group them with the rest as more show up.
For cxl/ocxl, I have no objection to moving to this new subtree if that's what we all agree to do. (what do people do about UAPI headers in this situation? keep them where they are in misc/?)
How about moving them but keeping a stub in misc that just includes the moved file?
Quoted 3 lines
If we do go ahead and set up this new subtree, perhaps we can use the mailing list I set up at [email protected] but we haven't really started using...
I've lost all lists.ozlabs.org muscle memory these days, but that seems reasonable to me.
-Olof
Hi!
Quoted 4 lines
So, I'd like to propose a
drivers/acceldrivers subtree, and I'd be happy to bootstrap it with a small group (@Dave Airlie: I think your input from GPU land be very useful, want to join in?). Individual drivers maintained by existing maintainers, of course.
Does this sound similar?
menu "Remoteproc drivers"
config REMOTEPROC
tristate "Support for Remote Processor subsystem"
depends on HAS_DMA
select CRC32
select FW_LOADER
select VIRTIO
select
WANT_DEV_COREDUMP
help
Support for remote processors (such as DSP
coprocessors). These
are mainly used on embedded systems.
...we already have that in tree...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
Second, I talked to Greg a couple of weeks ago about this driver and I definitely didn't get any such requirement from him. Had I gotten such a requirement, I would have planned this differently.
Third, I think this requirement, while maybe valid for drivers that are inside an established framework with common userspace library, such as drm, doesn't apply to a standalone driver which is not part of any subsystem. There is no way that "someone" will create a userspace for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Thanks,
Oded
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.
Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.
So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
Dave.
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
-Olof
Quoted 114 lines · Olof Johansson
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 5 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
Yes and to exercise the userspace API you need at very least to know the ISA so that you can write program for the accelerator. You also need to know the set of commands the hardware has. The ioctl and how to create a userspace that interact with the kernel is the easy part, the hard part is the compiler.
So if we want any kind of freedom to play with the UAPI, enhance it or change it in anyway we must be free to build program for the device ourself.
I believe that the GPU sub-system requirement are a good guideline to follow and the only exception with drivers/ that i am aware of is the fpga. Everything else in driver as either an open source userspace, expose a common API (like network) or is so simple that anyone can write a userspace for it.
For any complex device that execute program we should really enforce the open source userspace so that we can properly audit the driver as otherwise we only have half of the story with no idea what the other half might implies.
Cheers,
Jérôme
Quoted 122 lines · Jerome Glisse
Quoted 114 lines · Olof Johansson
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 5 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
Quoted 5 lines
Yes and to exercise the userspace API you need at very least to know the ISA so that you can write program for the accelerator. You also need to know the set of commands the hardware has. The ioctl and how to create a userspace that interact with the kernel is the easy part, the hard part is the compiler.
So actually in my case in order to exercise the IOCTL API, you can give "work" to the device that will not trigger the compute parts, but only the different queues and the DMA engines.
I think that is enough to validate that the IOCTLs won't break. All the "commands" that you can give to the queue logic (QMAN) is exposed in one of the files in the driver (goya_packets.h).
I want to stress this - To validate the IOCTLs, it is enough to do DMA work. You will use ALL the 5 IOCTLs to do just that - give work to the DMA engines.
And as I wrote to Dave, I can explain my security architecture in detail and how I make sure the programmable cores can't be used by malicious users.
And nice to hear from you Jerome :) I missed you!
Thanks,
Oded
Quoted 21 lines
So if we want any kind of freedom to play with the UAPI, enhance it or change it in anyway we must be free to build program for the device ourself.
I believe that the GPU sub-system requirement are a good guideline to follow and the only exception with
drivers/that i am aware of is the fpga. Everything else in driver as either an open source userspace, expose a common API (like network) or is so simple that anyone can write a userspace for it.For any complex device that execute program we should really enforce the open source userspace so that we can properly audit the driver as otherwise we only have half of the story with no idea what the other half might implies.
Cheers,
Jérôme
Quoted 137 lines · Oded Gabbay
Quoted 122 lines · Jerome Glisse
Quoted 114 lines · Olof Johansson
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 5 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
Quoted 5 lines
Yes and to exercise the userspace API you need at very least to know the ISA so that you can write program for the accelerator. You also need to know the set of commands the hardware has. The ioctl and how to create a userspace that interact with the kernel is the easy part, the hard part is the compiler.
So actually in my case in order to exercise the IOCTL API, you can give "work" to the device that will not trigger the compute parts, but only the different queues and the DMA engines.
I think that is enough to validate that the IOCTLs won't break. All the "commands" that you can give to the queue logic (QMAN) is exposed in one of the files in the driver (goya_packets.h).
Quoted 3 lines
I want to stress this - To validate the IOCTLs, it is enough to do DMA work. You will use ALL the 5 IOCTLs to do just that - give work to the DMA engines.
I personally think this is a reasonable trade-off, given that you have a communication layer between. For hardware that doesn't have that, and where device behavior and data movement depends on execution on the compute parts, more would need to be open.
-Olof
Quoted 132 lines · Jerome Glisse
Quoted 114 lines · Olof Johansson
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 5 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
Yes and to exercise the userspace API you need at very least to know the ISA so that you can write program for the accelerator. You also need to know the set of commands the hardware has. The ioctl and how to create a userspace that interact with the kernel is the easy part, the hard part is the compiler.
So if we want any kind of freedom to play with the UAPI, enhance it or change it in anyway we must be free to build program for the device ourself.
Quoted 5 lines
I believe that the GPU sub-system requirement are a good guideline to follow and the only exception with
drivers/that i am aware of is the fpga. Everything else in driver as either an open source userspace, expose a common API (like network) or is so simple that anyone can write a userspace for it.
Once we have a common framework I agree that we need enough tools to exercise everything needed. I don't agree that this includes full sources to everything. We don't expect this for most PCIe cards today either.
If the GPU subsystem is to be followed, I fear that we will end up with Nvidia-equivalent vendors from day 1, where they will just build a bigger and bigger software stack on the side instead of joining in, and someone will need to best-effort bridge the gap by reverse engineering. I don't want that situation long-term, which is why I think it's reasonable to be more relaxed during the early days with upfront, clear, expectations for the longer term that hardware/kernel interfaces need to be exercisable.
Quoted 4 lines
For any complex device that execute program we should really enforce the open source userspace so that we can properly audit the driver as otherwise we only have half of the story with no idea what the other half might implies.
What you're demanding is open userspace _and_ firmware. Since without firmware sources, you can't audit any on-chip behavior either (in reality, most commands passed down are likely parsed by said firmware).
-Olof
Quoted 139 lines · Olof Johansson
Quoted 132 lines · Jerome Glisse
Quoted 114 lines · Olof Johansson
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 5 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
Yes and to exercise the userspace API you need at very least to know the ISA so that you can write program for the accelerator. You also need to know the set of commands the hardware has. The ioctl and how to create a userspace that interact with the kernel is the easy part, the hard part is the compiler.
So if we want any kind of freedom to play with the UAPI, enhance it or change it in anyway we must be free to build program for the device ourself.
Quoted 5 lines
I believe that the GPU sub-system requirement are a good guideline to follow and the only exception with
drivers/that i am aware of is the fpga. Everything else in driver as either an open source userspace, expose a common API (like network) or is so simple that anyone can write a userspace for it.
Quoted 4 lines
Once we have a common framework I agree that we need enough tools to exercise everything needed. I don't agree that this includes full sources to everything. We don't expect this for most PCIe cards today either.
We do expected this today except for FPGA, i do not know any single pcie device with upstream driver that we do not know how to program. Biggest chunk of PCIE devices are straightforward (network, sound, media, ...).
So in effect today the lowest common denominator is open source user space or device API is so simple that user space is obvious (various media device).
Quoted 9 lines
If the GPU subsystem is to be followed, I fear that we will end up with Nvidia-equivalent vendors from day 1, where they will just build a bigger and bigger software stack on the side instead of joining in, and someone will need to best-effort bridge the gap by reverse engineering. I don't want that situation long-term, which is why I think it's reasonable to be more relaxed during the early days with upfront, clear, expectations for the longer term that hardware/kernel interfaces need to be exercisable.
I think the other way around, allowing people to push upstream driver with no open source user space and people loose any motivation to work on open sourcing their userspace. Not being upstream is painful enough that they will get pressure to go upstream and if upstream means open source userspace then they have to comply.
Quoted 10 lines
Quoted 5 lines
For any complex device that execute program we should really enforce the open source userspace so that we can properly audit the driver as otherwise we only have half of the story with no idea what the other half might implies.
What you're demanding is open userspace _and_ firmware. Since without firmware sources, you can't audit any on-chip behavior either (in reality, most commands passed down are likely parsed by said firmware).
No i do not ask for firmware. If we have any doubt about what the firm- ware can let through then we can lock down the ioctl ie parse commands from userspace and only allow kernel to write sanitize command to command queue. By auditing here i mean being able to understand the overall flow that is expected from program so from that program flow we can work on what is the best UAPI with minimum overhead to achieve that program flow the most efficiently. Sorry if that was not clear.
Cheers,
Jérôme
Hi all,
Top post, because new argument.
There's lots of really good technical arguments for having the userspace component of a driver stack that spans both kernel and userspace open too. For me, that's not really the important argument.
I care about open source, I'm not interested in blobs (beyond that they're useful for reverse engineering). I think the upstream community should care about open source, and by and large it very much
does: We haven't merged ndiswrapper, or the nvidia shim, or anything like that to make running blobs in the kernel easier. And at least in the case of the one traditional driver subsystem where 90% of the driver lives in userspace, we also care about that part being open.
Anything else is imo just a long-term dis-service to the community of customers, other vendors, ... Adapting a famous quote: If you're ok with throwing away some long term software freedom for a bit of short term hardware support you'll get neither.
So if someone propose to merge some open source kernel driver that requires piles of closed source userspace to be any use at all, I'm just not interested. And if the fpga folks have merged fpga drivers without at least a basic (non-optimizing) RTL compiler, then that was a grave mistake. That doing this is also technically a bad idea (for all the reasons already discussed) is just the icing on the top for me.
And to tie this back to the technical discussion, here's a scenario that's bound to happen:
1. vendor crams their open source driver into upstream, with full blob userspace
2. vendor gets bored (runs low on money, accidentally fired the entire old team, needs to do more value add, whatever, ...) rewrites the entire stack
3. vendor crams their new&completely incompatible open source stack into upstream
4. upstream is now unvoluntarily stuck maintaining 2 drivers for the exact same thing, and we can't fix anything of that because if you touch one side of the stack without undertstanding the other part you're guaranteed to create regressions (yes this is how this works with gpu drivers, we've learned this the hard way)
5. repeat
Hence for these technical reasons you'll then end up with a subsystem that only the vendor can touch, and hence also the vendor can abandon at will. Not like drivers/gpu, where customers, consulting shops, students, ... routinely can&do add new features to existing drivers.
This is not a winning move.
Cheers, Daniel
Quoted 192 lines · Jerome Glisse
Quoted 139 lines · Olof Johansson
Quoted 132 lines · Jerome Glisse
Quoted 114 lines · Olof Johansson
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 5 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
Yes and to exercise the userspace API you need at very least to know the ISA so that you can write program for the accelerator. You also need to know the set of commands the hardware has. The ioctl and how to create a userspace that interact with the kernel is the easy part, the hard part is the compiler.
So if we want any kind of freedom to play with the UAPI, enhance it or change it in anyway we must be free to build program for the device ourself.
Quoted 5 lines
I believe that the GPU sub-system requirement are a good guideline to follow and the only exception with
drivers/that i am aware of is the fpga. Everything else in driver as either an open source userspace, expose a common API (like network) or is so simple that anyone can write a userspace for it.Quoted 4 lines
Once we have a common framework I agree that we need enough tools to exercise everything needed. I don't agree that this includes full sources to everything. We don't expect this for most PCIe cards today either.
We do expected this today except for FPGA, i do not know any single pcie device with upstream driver that we do not know how to program. Biggest chunk of PCIE devices are straightforward (network, sound, media, ...).
So in effect today the lowest common denominator is open source user space or device API is so simple that user space is obvious (various media device).
Quoted 9 lines
If the GPU subsystem is to be followed, I fear that we will end up with Nvidia-equivalent vendors from day 1, where they will just build a bigger and bigger software stack on the side instead of joining in, and someone will need to best-effort bridge the gap by reverse engineering. I don't want that situation long-term, which is why I think it's reasonable to be more relaxed during the early days with upfront, clear, expectations for the longer term that hardware/kernel interfaces need to be exercisable.
I think the other way around, allowing people to push upstream driver with no open source user space and people loose any motivation to work on open sourcing their userspace. Not being upstream is painful enough that they will get pressure to go upstream and if upstream means open source userspace then they have to comply.
Quoted 10 lines
Quoted 5 lines
For any complex device that execute program we should really enforce the open source userspace so that we can properly audit the driver as otherwise we only have half of the story with no idea what the other half might implies.
What you're demanding is open userspace _and_ firmware. Since without firmware sources, you can't audit any on-chip behavior either (in reality, most commands passed down are likely parsed by said firmware).
No i do not ask for firmware. If we have any doubt about what the firm- ware can let through then we can lock down the ioctl ie parse commands from userspace and only allow kernel to write sanitize command to command queue. By auditing here i mean being able to understand the overall flow that is expected from program so from that program flow we can work on what is the best UAPI with minimum overhead to achieve that program flow the most efficiently. Sorry if that was not clear.
Cheers,
Jérôme
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Hi Daniel and Jerome,
I know I won't be able to convince you but I want to say that I think your arguments for full userspace open source are not really technical.
IMHO, an open-source, thin runtime that provides code to operate ALL the uAPI the driver exports + commitment to only using this library as the interface to the driver is good enough for the issue of uAPI breakage. And that thing I can provide.
If at a later time habana will decide to throw it all away (not going to happen while I'm here), then its habana's problem. Not the kernel. In that case, I would argue that the kernel shouldn't accept a new driver from habana. But as long as we keep API compatibility, I don't see any harm.
I'm not convinced by your request to open the ISA of the programmable cores. How is that relevant to the kernel driver. I don't even do anything with those cores. The uAPI I export isn't related whatsoever to those cores.
I honestly think that if your position is accepted by the Linux kernel community, companies building AI accelerators won't go near the kernel. They will simply go down the path Nvidia has gone, which is to have an out-of-tree kernel driver + big closed userspace. That's a totally sustainable path from business POV (see Nvidia's dominance in GPU and deep learning). I don't see how that will serve any of us. I would think we want to lure companies into open sourcing their code, and you don't do that by saying: "if you don't open your entire code base, don't bother to open any part of it".
Thanks,
Oded
Quoted 254 lines · Daniel Vetter
Hi all,
Top post, because new argument.
There's lots of really good technical arguments for having the userspace component of a driver stack that spans both kernel and userspace open too. For me, that's not really the important argument.
I care about open source, I'm not interested in blobs (beyond that they're useful for reverse engineering). I think the upstream community should care about open source, and by and large it very much
does: We haven't merged ndiswrapper, or the nvidia shim, or anything like that to make running blobs in the kernel easier. And at least in the case of the one traditional driver subsystem where 90% of the driver lives in userspace, we also care about that part being open.Anything else is imo just a long-term dis-service to the community of customers, other vendors, ... Adapting a famous quote: If you're ok with throwing away some long term software freedom for a bit of short term hardware support you'll get neither.
So if someone propose to merge some open source kernel driver that requires piles of closed source userspace to be any use at all, I'm just not interested. And if the fpga folks have merged fpga drivers without at least a basic (non-optimizing) RTL compiler, then that was a grave mistake. That doing this is also technically a bad idea (for all the reasons already discussed) is just the icing on the top for me.
And to tie this back to the technical discussion, here's a scenario that's bound to happen:
1. vendor crams their open source driver into upstream, with full blob userspace
2. vendor gets bored (runs low on money, accidentally fired the entire old team, needs to do more value add, whatever, ...) rewrites the entire stack
3. vendor crams their new&completely incompatible open source stack into upstream
4. upstream is now unvoluntarily stuck maintaining 2 drivers for the exact same thing, and we can't fix anything of that because if you touch one side of the stack without undertstanding the other part you're guaranteed to create regressions (yes this is how this works with gpu drivers, we've learned this the hard way)
5. repeatHence for these technical reasons you'll then end up with a subsystem that only the vendor can touch, and hence also the vendor can abandon at will. Not like
drivers/gpu, where customers, consulting shops, students, ... routinely can&do add new features to existing drivers.This is not a winning move.
Cheers, Daniel
Quoted 190 lines · Jerome Glisse
Quoted 139 lines · Olof Johansson
Quoted 132 lines · Jerome Glisse
Quoted 114 lines · Olof Johansson
Quoted 84 lines · Dave Airlie
Quoted 41 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.Quoted 8 lines
First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
Quoted 4 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 5 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
Yes and to exercise the userspace API you need at very least to know the ISA so that you can write program for the accelerator. You also need to know the set of commands the hardware has. The ioctl and how to create a userspace that interact with the kernel is the easy part, the hard part is the compiler.
So if we want any kind of freedom to play with the UAPI, enhance it or change it in anyway we must be free to build program for the device ourself.
Quoted 5 lines
I believe that the GPU sub-system requirement are a good guideline to follow and the only exception with
drivers/that i am aware of is the fpga. Everything else in driver as either an open source userspace, expose a common API (like network) or is so simple that anyone can write a userspace for it.Quoted 4 lines
Once we have a common framework I agree that we need enough tools to exercise everything needed. I don't agree that this includes full sources to everything. We don't expect this for most PCIe cards today either.
We do expected this today except for FPGA, i do not know any single pcie device with upstream driver that we do not know how to program. Biggest chunk of PCIE devices are straightforward (network, sound, media, ...).
So in effect today the lowest common denominator is open source user space or device API is so simple that user space is obvious (various media device).
Quoted 9 lines
If the GPU subsystem is to be followed, I fear that we will end up with Nvidia-equivalent vendors from day 1, where they will just build a bigger and bigger software stack on the side instead of joining in, and someone will need to best-effort bridge the gap by reverse engineering. I don't want that situation long-term, which is why I think it's reasonable to be more relaxed during the early days with upfront, clear, expectations for the longer term that hardware/kernel interfaces need to be exercisable.
I think the other way around, allowing people to push upstream driver with no open source user space and people loose any motivation to work on open sourcing their userspace. Not being upstream is painful enough that they will get pressure to go upstream and if upstream means open source userspace then they have to comply.
Quoted 10 lines
Quoted 5 lines
For any complex device that execute program we should really enforce the open source userspace so that we can properly audit the driver as otherwise we only have half of the story with no idea what the other half might implies.
What you're demanding is open userspace _and_ firmware. Since without firmware sources, you can't audit any on-chip behavior either (in reality, most commands passed down are likely parsed by said firmware).
No i do not ask for firmware. If we have any doubt about what the firm- ware can let through then we can lock down the ioctl ie parse commands from userspace and only allow kernel to write sanitize command to command queue. By auditing here i mean being able to understand the overall flow that is expected from program so from that program flow we can work on what is the best UAPI with minimum overhead to achieve that program flow the most efficiently. Sorry if that was not clear.
Quoted 2 lines
Cheers,
Jérôme--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 3 lines
I know I won't be able to convince you but I want to say that I think your arguments for full userspace open source are not really technical.
There is more to keeping a kernel going than technical argument unfortunately.
I guess the question for Greg, Olof etc, is do we care about Linux the kernel, or Linux the open source ecosystem, if the former, these sort of accelerator shim drivers are fine, useless to anyone who doesn't have all the magic hidden userspace, and impossible to support for anyone else, if the latter, we should leave the cost of maintenance to the company benefiting from it and leave maintaining it out of tree.
Simple question like If I plug your accelerator into Power or ARM64, where do I get the port of your userspace to use it?
I'm not the final arbiter on this sort of thing, but I'm definitely going to make sure that anyone who lands this code is explicit in ignoring any experience we've had in this area and in the future will gladly accept "I told you so" :-)
Dave.
Quoted 5 lines · Dave Airlie
Quoted 4 lines
I know I won't be able to convince you but I want to say that I think your arguments for full userspace open source are not really technical.
Quoted 8 lines
There is more to keeping a kernel going than technical argument unfortunately.
I guess the question for Greg, Olof etc, is do we care about Linux the kernel, or Linux the open source ecosystem, if the former, these sort of accelerator shim drivers are fine, useless to anyone who doesn't have all the magic hidden userspace, and impossible to support for anyone else, if the latter, we should leave the cost of maintenance to the company benefiting from it and leave maintaining it out of tree.
As mentioned in my reply to Daniel, I think we've got a history of being pragmatic and finding reasonable trade-offs of what can be open and what can be closed. For example, if truly care about open source ecosystem, drivers that require closed firmware should also be refused.
Quoted 2 lines
Simple question like If I plug your accelerator into Power or ARM64, where do I get the port of your userspace to use it?
Does demanding complete open userspace get us closer to that goal in reality? By refusing to work with people to enable their hardware, they will still ship their platforms out of tree, using DKMS and all the other ways of getting kernel modules installed to talk to the hardware. And we'd be no closer.
In the end, they'd open up their userspace when there's business reasons to do so. It's well-known how to work around refusal from us to merge drivers by now, so it's not much leverage in that area.
Quoted 4 lines
I'm not the final arbiter on this sort of thing, but I'm definitely going to make sure that anyone who lands this code is explicit in ignoring any experience we've had in this area and in the future will gladly accept "I told you so" :-)
There's only one final arbiter on any inclusion to code to the kernel, but we tend to sort out most disagreements without going all the way there.
I still think engaging has a better chance of success than rejecting the contributions, especially with clear expectations w.r.t. continued engagement and no second implementations over time. In all honestly, either approach might fail miserably.
-Olof
Quoted 16 lines · Olof Johansson
Quoted 5 lines · Dave Airlie
Quoted 4 lines
I know I won't be able to convince you but I want to say that I think your arguments for full userspace open source are not really technical.
Quoted 8 lines
There is more to keeping a kernel going than technical argument unfortunately.
I guess the question for Greg, Olof etc, is do we care about Linux the kernel, or Linux the open source ecosystem, if the former, these sort of accelerator shim drivers are fine, useless to anyone who doesn't have all the magic hidden userspace, and impossible to support for anyone else, if the latter, we should leave the cost of maintenance to the company benefiting from it and leave maintaining it out of tree.
Quoted 5 lines
As mentioned in my reply to Daniel, I think we've got a history of being pragmatic and finding reasonable trade-offs of what can be open and what can be closed. For example, if truly care about open source ecosystem, drivers that require closed firmware should also be refused.
Firmware has traditionally been different since usually it's looked down, doesn't do much wrt functionality (dumb fifo scheduling at best, not really power management) and so could be reasonably shrugged off as "it's part of hw". If you care about the open graphics ecosystem, i.e. your ability to port the stack to new cpu architectures, new window systems (e.g. android -> xorg, or xorg -> android, or something entirely new like wayland), new, more efficient client interface (vulkan is a very new fad), then having a closed firmware is not going to be a problem. Closed compiler, closed runtime, closed anything else otoh is a serious practical pain.
Unfortunately hw vendors seem to have realized that we (overall community of customers, distro, upstream) are not insisting on open firmware, so they're moving a lot of "valuable sauce" (no really, it's not) into the firmware. PM governors, cpu scheduling algorithms, that kind of stuff. We're not pleased, and there's lots of people doing the behind the scenes work to fix it. One practical problem is that even if we've demonstrated that r/e'ing a uc is no bigger challenge than anything, there's usually this pesky issue with signatures. So we can't force the vendors like we can with the userspace side. Otherwise nouveau would have completely open firmware even for latest chips (like it has for olders).
Quoted 9 lines
Quoted 2 lines
Simple question like If I plug your accelerator into Power or ARM64, where do I get the port of your userspace to use it?
Does demanding complete open userspace get us closer to that goal in reality? By refusing to work with people to enable their hardware, they will still ship their platforms out of tree, using DKMS and all the other ways of getting kernel modules installed to talk to the hardware. And we'd be no closer.
Quoted 3 lines
In the end, they'd open up their userspace when there's business reasons to do so. It's well-known how to work around refusal from us to merge drivers by now, so it's not much leverage in that area.
Correct. None of the hw vendors had a business reason to open source anything unforunately. Yes, eventually customers started demanding open source and treatening to buy the competition, but this only works if you have multiple reasonably performant & conformant stacks for different vendors. The only way to get these is to reverse engineer them.
Now reverse-engineering is a major pain in itself (despite all the great tooling gpu folks developed over the past 10 years to convert it from a black art to a repeatable engineering excercise), but if you additionally prefer the vendors closed stack (which you do by allowing to get them to get merged) the r/e'd stack has no chance. And there is not other way to get your open source stack. I can't really go into all the details of the past 15+ of open source gpus, but without the pressure of other r/e'ed stacks and the pressure of having stacks for competitiors (all made possible through aggressive code sharing) we would have 0 open source gfx stacks. All the ones we have either got started with r/e first (and eventually the vendor jumped on board) or survived through r/e and customer efforts (because the vendor planned to abandon it). Another part of this is that we accept userspace only when it's the common upstream (if there is one), to prevent vendors closing down their stacks gradually.
So yeah I think by not clearly preferring open source over stacks-with-blobs (how radically you do that is a bit a balance act in the end, I think we've maxed out in drivers/gpu on what's practically possible) you'll just make sure that there's never going to be a serious open source stack.
Quoted 5 lines
Quoted 4 lines
I'm not the final arbiter on this sort of thing, but I'm definitely going to make sure that anyone who lands this code is explicit in ignoring any experience we've had in this area and in the future will gladly accept "I told you so" :-)
Quoted 8 lines
There's only one final arbiter on any inclusion to code to the kernel, but we tend to sort out most disagreements without going all the way there.
I still think engaging has a better chance of success than rejecting the contributions, especially with clear expectations w.r.t. continued engagement and no second implementations over time. In all honestly, either approach might fail miserably.
This is maybe not clear, but we still work together with the blob folks as much as possible, for demonstration: nvidia sponsored XDC this year, and nvidia engineers have been regularly presenting there. Collaboration happens around the driver interfaces, like loaders (in userspace), buffer sharing, synchronization, negotiation of buffer formats and all that stuff. Do as much enganging as possible, but if you give preferrential treatment to the closed stacks over the open ones (and by default the vendor _always_ gives you a closed stack, or as closed as possible, there's just no business case for them to open up without a customer demanding it and competition providing it too), you will end up with a closed stack for a very long time, maybe forever.
Even if you insist on an open stack it's going to take years, since the only way to get there is lots of r/e, and you need to have at least 2 stacks or otherwise the customers can't walk away from the negotiation table. So again from gfx experience: The only way to get open stacks is solid competition by open stacks, and customers/distros investing ridiculous amounts of money to r/e the chips and write these open&cross vendor stacks. The business case for vendors to open source their stacks is just not there. Not until they can't sell their chips any other way anymore (nvidia will embrace open stacks as soon as their margins evaporate, not a second earlier, like all the others before them). Maybe at the next hallway track we need to go through a few examples of what all happened and is still happening in the background (here's maybe not a good idea).
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 60 lines · Daniel Vetter
Quoted 16 lines · Olof Johansson
Quoted 5 lines · Dave Airlie
Quoted 4 lines
I know I won't be able to convince you but I want to say that I think your arguments for full userspace open source are not really technical.
Quoted 8 lines
There is more to keeping a kernel going than technical argument unfortunately.
I guess the question for Greg, Olof etc, is do we care about Linux the kernel, or Linux the open source ecosystem, if the former, these sort of accelerator shim drivers are fine, useless to anyone who doesn't have all the magic hidden userspace, and impossible to support for anyone else, if the latter, we should leave the cost of maintenance to the company benefiting from it and leave maintaining it out of tree.
Quoted 5 lines
As mentioned in my reply to Daniel, I think we've got a history of being pragmatic and finding reasonable trade-offs of what can be open and what can be closed. For example, if truly care about open source ecosystem, drivers that require closed firmware should also be refused.
Firmware has traditionally been different since usually it's looked down, doesn't do much wrt functionality (dumb fifo scheduling at best, not really power management) and so could be reasonably shrugged off as "it's part of hw". If you care about the open graphics ecosystem, i.e. your ability to port the stack to new cpu architectures, new window systems (e.g. android -> xorg, or xorg -> android, or something entirely new like wayland), new, more efficient client interface (vulkan is a very new fad), then having a closed firmware is not going to be a problem. Closed compiler, closed runtime, closed anything else otoh is a serious practical pain.
Unfortunately hw vendors seem to have realized that we (overall community of customers, distro, upstream) are not insisting on open firmware, so they're moving a lot of "valuable sauce" (no really, it's not) into the firmware. PM governors, cpu scheduling algorithms, that kind of stuff. We're not pleased, and there's lots of people doing the behind the scenes work to fix it. One practical problem is that even if we've demonstrated that r/e'ing a uc is no bigger challenge than anything, there's usually this pesky issue with signatures. So we can't force the vendors like we can with the userspace side. Otherwise nouveau would have completely open firmware even for latest chips (like it has for olders).
Quoted 9 lines
Quoted 2 lines
Simple question like If I plug your accelerator into Power or ARM64, where do I get the port of your userspace to use it?
Does demanding complete open userspace get us closer to that goal in reality? By refusing to work with people to enable their hardware, they will still ship their platforms out of tree, using DKMS and all the other ways of getting kernel modules installed to talk to the hardware. And we'd be no closer.
Quoted 3 lines
In the end, they'd open up their userspace when there's business reasons to do so. It's well-known how to work around refusal from us to merge drivers by now, so it's not much leverage in that area.
Quoted 6 lines
Correct. None of the hw vendors had a business reason to open source anything unforunately. Yes, eventually customers started demanding open source and treatening to buy the competition, but this only works if you have multiple reasonably performant & conformant stacks for different vendors. The only way to get these is to reverse engineer them.
That's the grass-roots version of it, and it is indeed a lot of work. What _has_ proven to have success is when companies that would drive real revenue for the vendors have requirements for them to open up, contribute, and participate. In the graphics world it hasn't gotten things all the way to the right spot, but I know first hand that for example Chrome OS's insistence on upstream participation has made significant differences in how several companies interact with our communities.
It's not something that's easy to do when the target is consumer-oriented hardware (which graphics mostly is), but at least for now, these accelerators aren't targeting end users as much as corporate environments, where we do have allies.
Quoted 16 lines
Now reverse-engineering is a major pain in itself (despite all the great tooling gpu folks developed over the past 10 years to convert it from a black art to a repeatable engineering excercise), but if you additionally prefer the vendors closed stack (which you do by allowing to get them to get merged) the r/e'd stack has no chance. And there is not other way to get your open source stack. I can't really go into all the details of the past 15+ of open source gpus, but without the pressure of other r/e'ed stacks and the pressure of having stacks for competitiors (all made possible through aggressive code sharing) we would have 0 open source gfx stacks. All the ones we have either got started with r/e first (and eventually the vendor jumped on board) or survived through r/e and customer efforts (because the vendor planned to abandon it). Another part of this is that we accept userspace only when it's the common upstream (if there is one), to prevent vendors closing down their stacks gradually.
Quoted 5 lines
So yeah I think by not clearly preferring open source over stacks-with-blobs (how radically you do that is a bit a balance act in the end, I think we've maxed out in
drivers/gpuon what's practically possible) you'll just make sure that there's never going to be a serious open source stack.
I can confidently say that I would myself clearly give preferential treatment to open stacks when they show up. The trick is how we get there -- do we get there quicker by refusing to work with the partially closed stacks? My viewpoint is that we don't, and that the best way to get there is to bring them in and start working with what we have instead of building separate camps that we later need to figure out how to move.
Quoted 27 lines
Quoted 5 lines
Quoted 4 lines
I'm not the final arbiter on this sort of thing, but I'm definitely going to make sure that anyone who lands this code is explicit in ignoring any experience we've had in this area and in the future will gladly accept "I told you so" :-)
Quoted 8 lines
There's only one final arbiter on any inclusion to code to the kernel, but we tend to sort out most disagreements without going all the way there.
I still think engaging has a better chance of success than rejecting the contributions, especially with clear expectations w.r.t. continued engagement and no second implementations over time. In all honestly, either approach might fail miserably.
This is maybe not clear, but we still work together with the blob folks as much as possible, for demonstration: nvidia sponsored XDC this year, and nvidia engineers have been regularly presenting there. Collaboration happens around the driver interfaces, like loaders (in userspace), buffer sharing, synchronization, negotiation of buffer formats and all that stuff. Do as much enganging as possible, but if you give preferrential treatment to the closed stacks over the open ones (and by default the vendor _always_ gives you a closed stack, or as closed as possible, there's just no business case for them to open up without a customer demanding it and competition providing it too), you will end up with a closed stack for a very long time, maybe forever.
Quoted 13 lines
Even if you insist on an open stack it's going to take years, since the only way to get there is lots of r/e, and you need to have at least 2 stacks or otherwise the customers can't walk away from the negotiation table. So again from gfx experience: The only way to get open stacks is solid competition by open stacks, and customers/distros investing ridiculous amounts of money to r/e the chips and write these open&cross vendor stacks. The business case for vendors to open source their stacks is just not there. Not until they can't sell their chips any other way anymore (nvidia will embrace open stacks as soon as their margins evaporate, not a second earlier, like all the others before them). Maybe at the next hallway track we need to go through a few examples of what all happened and is still happening in the background (here's maybe not a good idea).
Again, the graphics world is different since the volume market has traditionally been consumers, and the split got very deep. What we want to avoid here is to get into the same situation by avoiding the large split.
Look at it another way, these are roughly the options and possible outcomes:
1a. We don't merge these drivers, vendors say "okay then" and open up their whole stacks. We merge the drivers. Then we start working together on moving to a common base.
1b. We don't merge these drivers, the vendors all do their own thing and over the next 5 years, we reverse engineer and start to bring in second implementations of all their code.
2a. We merge these drivers, start close engagement with the vendors, collaborate and converge with their next-gen products (possibly move first-gen over).
2b. We merge these drivers, and vendors still go off on their own and do their own thing. We spend the next 5 years reverse engineering and move over to open, new drivers even though the first ones are in-tree.
1a/2a are successful outcomes. I put 1a at very very low probability. 2b at medium probability with the right allies in the corporate world.
1b/2b are partial failure modes with huge effort needed and a passionate volunteer base.
Both 1a/2a and 1b/2b have similar amounts of work involved. In other words, I don't see how anyone benefits from eliminating (2) as an approach, especially since 1a is an unlikely development of events.
And, guess what -- if we do get open stacks early on, and give heavy preferential treatment to these, we can push others in that direction sooner rather than later, before stacks diverge too far. I just don't see how _not_ engaging is going to help here. Even if we do engage, the worst possible outcome is still the same as not engaging but a good chance for something better.
-Olof
Quoted 78 lines · Olof Johansson
Quoted 60 lines · Daniel Vetter
Quoted 16 lines · Olof Johansson
Quoted 5 lines · Dave Airlie
Quoted 4 lines
I know I won't be able to convince you but I want to say that I think your arguments for full userspace open source are not really technical.
Quoted 8 lines
There is more to keeping a kernel going than technical argument unfortunately.
I guess the question for Greg, Olof etc, is do we care about Linux the kernel, or Linux the open source ecosystem, if the former, these sort of accelerator shim drivers are fine, useless to anyone who doesn't have all the magic hidden userspace, and impossible to support for anyone else, if the latter, we should leave the cost of maintenance to the company benefiting from it and leave maintaining it out of tree.
Quoted 5 lines
As mentioned in my reply to Daniel, I think we've got a history of being pragmatic and finding reasonable trade-offs of what can be open and what can be closed. For example, if truly care about open source ecosystem, drivers that require closed firmware should also be refused.
Firmware has traditionally been different since usually it's looked down, doesn't do much wrt functionality (dumb fifo scheduling at best, not really power management) and so could be reasonably shrugged off as "it's part of hw". If you care about the open graphics ecosystem, i.e. your ability to port the stack to new cpu architectures, new window systems (e.g. android -> xorg, or xorg -> android, or something entirely new like wayland), new, more efficient client interface (vulkan is a very new fad), then having a closed firmware is not going to be a problem. Closed compiler, closed runtime, closed anything else otoh is a serious practical pain.
Unfortunately hw vendors seem to have realized that we (overall community of customers, distro, upstream) are not insisting on open firmware, so they're moving a lot of "valuable sauce" (no really, it's not) into the firmware. PM governors, cpu scheduling algorithms, that kind of stuff. We're not pleased, and there's lots of people doing the behind the scenes work to fix it. One practical problem is that even if we've demonstrated that r/e'ing a uc is no bigger challenge than anything, there's usually this pesky issue with signatures. So we can't force the vendors like we can with the userspace side. Otherwise nouveau would have completely open firmware even for latest chips (like it has for olders).
Quoted 9 lines
Quoted 2 lines
Simple question like If I plug your accelerator into Power or ARM64, where do I get the port of your userspace to use it?
Does demanding complete open userspace get us closer to that goal in reality? By refusing to work with people to enable their hardware, they will still ship their platforms out of tree, using DKMS and all the other ways of getting kernel modules installed to talk to the hardware. And we'd be no closer.
Quoted 3 lines
In the end, they'd open up their userspace when there's business reasons to do so. It's well-known how to work around refusal from us to merge drivers by now, so it's not much leverage in that area.
Quoted 6 lines
Correct. None of the hw vendors had a business reason to open source anything unforunately. Yes, eventually customers started demanding open source and treatening to buy the competition, but this only works if you have multiple reasonably performant & conformant stacks for different vendors. The only way to get these is to reverse engineer them.
That's the grass-roots version of it, and it is indeed a lot of work. What _has_ proven to have success is when companies that would drive real revenue for the vendors have requirements for them to open up, contribute, and participate. In the graphics world it hasn't gotten things all the way to the right spot, but I know first hand that for example Chrome OS's insistence on upstream participation has made significant differences in how several companies interact with our communities.
Quoted 4 lines
It's not something that's easy to do when the target is consumer-oriented hardware (which graphics mostly is), but at least for now, these accelerators aren't targeting end users as much as corporate environments, where we do have allies.
Cros is the only reason we do have the stack we do in graphics. They've been investing ridiculous amounts of money into this, and they actually invest even more now than 1-2 years ago. I know for a fact that without cros a few of the open stacks would have substantially, if not completely, closed down again. If you don't believe that, look at how debian treats the latest intel libva driver as partially non-free (because it's become that).
Quoted 101 lines
Quoted 16 lines
Now reverse-engineering is a major pain in itself (despite all the great tooling gpu folks developed over the past 10 years to convert it from a black art to a repeatable engineering excercise), but if you additionally prefer the vendors closed stack (which you do by allowing to get them to get merged) the r/e'd stack has no chance. And there is not other way to get your open source stack. I can't really go into all the details of the past 15+ of open source gpus, but without the pressure of other r/e'ed stacks and the pressure of having stacks for competitiors (all made possible through aggressive code sharing) we would have 0 open source gfx stacks. All the ones we have either got started with r/e first (and eventually the vendor jumped on board) or survived through r/e and customer efforts (because the vendor planned to abandon it). Another part of this is that we accept userspace only when it's the common upstream (if there is one), to prevent vendors closing down their stacks gradually.
Quoted 5 lines
So yeah I think by not clearly preferring open source over stacks-with-blobs (how radically you do that is a bit a balance act in the end, I think we've maxed out in
drivers/gpuon what's practically possible) you'll just make sure that there's never going to be a serious open source stack.I can confidently say that I would myself clearly give preferential treatment to open stacks when they show up. The trick is how we get there -- do we get there quicker by refusing to work with the partially closed stacks? My viewpoint is that we don't, and that the best way to get there is to bring them in and start working with what we have instead of building separate camps that we later need to figure out how to move.
Quoted 27 lines
Quoted 5 lines
Quoted 4 lines
I'm not the final arbiter on this sort of thing, but I'm definitely going to make sure that anyone who lands this code is explicit in ignoring any experience we've had in this area and in the future will gladly accept "I told you so" :-)
Quoted 8 lines
There's only one final arbiter on any inclusion to code to the kernel, but we tend to sort out most disagreements without going all the way there.
I still think engaging has a better chance of success than rejecting the contributions, especially with clear expectations w.r.t. continued engagement and no second implementations over time. In all honestly, either approach might fail miserably.
This is maybe not clear, but we still work together with the blob folks as much as possible, for demonstration: nvidia sponsored XDC this year, and nvidia engineers have been regularly presenting there. Collaboration happens around the driver interfaces, like loaders (in userspace), buffer sharing, synchronization, negotiation of buffer formats and all that stuff. Do as much enganging as possible, but if you give preferrential treatment to the closed stacks over the open ones (and by default the vendor _always_ gives you a closed stack, or as closed as possible, there's just no business case for them to open up without a customer demanding it and competition providing it too), you will end up with a closed stack for a very long time, maybe forever.
Quoted 13 lines
Even if you insist on an open stack it's going to take years, since the only way to get there is lots of r/e, and you need to have at least 2 stacks or otherwise the customers can't walk away from the negotiation table. So again from gfx experience: The only way to get open stacks is solid competition by open stacks, and customers/distros investing ridiculous amounts of money to r/e the chips and write these open&cross vendor stacks. The business case for vendors to open source their stacks is just not there. Not until they can't sell their chips any other way anymore (nvidia will embrace open stacks as soon as their margins evaporate, not a second earlier, like all the others before them). Maybe at the next hallway track we need to go through a few examples of what all happened and is still happening in the background (here's maybe not a good idea).
Again, the graphics world is different since the volume market has traditionally been consumers, and the split got very deep. What we want to avoid here is to get into the same situation by avoiding the large split.
Look at it another way, these are roughly the options and possible outcomes:
1a. We don't merge these drivers, vendors say "okay then" and open up their whole stacks. We merge the drivers. Then we start working together on moving to a common base.
1b. We don't merge these drivers, the vendors all do their own thing and over the next 5 years, we reverse engineer and start to bring in second implementations of all their code.
2a. We merge these drivers, start close engagement with the vendors, collaborate and converge with their next-gen products (possibly move first-gen over).
2b. We merge these drivers, and vendors still go off on their own and do their own thing. We spend the next 5 years reverse engineering and move over to open, new drivers even though the first ones are in-tree.1a/2a are successful outcomes. I put 1a at very very low probability. 2b at medium probability with the right allies in the corporate world.
1b/2b are partial failure modes with huge effort needed and a passionate volunteer base.
Both 1a/2a and 1b/2b have similar amounts of work involved. In other words, I don't see how anyone benefits from eliminating (2) as an approach, especially since 1a is an unlikely development of events.
Quoted 6 lines
And, guess what -- if we do get open stacks early on, and give heavy preferential treatment to these, we can push others in that direction sooner rather than later, before stacks diverge too far. I just don't see how _not_ engaging is going to help here. Even if we do engage, the worst possible outcome is still the same as not engaging but a good chance for something better.
If you do have allies with big purses (both product buying power and the willingness & ability to just hire a driver team and create facts if the vendor doesnt cooperate), then you can directly make option 1a
happen: vendors open their stacks, you merge them (and of course you start engaging right away). If you don't have that, then you'll have 1b or 2b and will entirely depend upon students and other fools with too much time to r/e and write your open stack. And for those 1b is the substantially better option. Only cases where 2a works is if some team internally in the vendor makes it happen and somehow convinces management that there's a real market for this (or going to be). But if that real market (said customer with a big purse and an insistence on open source) does not materialize, the effort will crumble again after a few years.
Anyway I don't think we'll convince each other of anything here, so we'll just see what happens and we have a nice chat in a few years about this all :-) Maybe if you want someone else still from the graphics hippies club, perhaps chat with Keith Packard. He's got quite a bit of experience and has seen even more dumpster fires than Dave, Jerome or me.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Hi,
Quoted 4 lines · Daniel Vetter
Hi all,
Top post, because new argument.
I'm diving in and replying to this instead of other replies upthread, since I think it brings up the core of the disagreement.
Quoted 11 lines
There's lots of really good technical arguments for having the userspace component of a driver stack that spans both kernel and userspace open too. For me, that's not really the important argument.
I care about open source, I'm not interested in blobs (beyond that they're useful for reverse engineering). I think the upstream community should care about open source, and by and large it very much
does: We haven't merged ndiswrapper, or the nvidia shim, or anything like that to make running blobs in the kernel easier. And at least in the case of the one traditional driver subsystem where 90% of the driver lives in userspace, we also care about that part being open.
Nobody is talking about merging kernel blobs. I think we're all in agreement that it's absolutely out of question.
Traditionally, nearly all hardware has had closed firmware as well, and if anything affects how we are tied down on making kernel-level changes, this is a big one. What makes userspace different from that perspective? Why do we have that double standard?
The question is if we're looking to alienate vendors and create a whole new set of Nvidia-style driver stacks that will grow and grow, or if we're willing to discuss with them and get them involved now, to a point where we can come up with a reasonable, standardized/extensible interface between upper levels of device FW, through kernel and into low-level userspace. Getting them to separate out the low-level portions of their software stacks to something that is open is a medium-term good compromise in this direction (ideally they might end up sharing this layer too, but that's not on me to decide). Most of these pieces of hardware work in similar manners; a stream of commands with data, and a stream of completions/results/output data.
I'm incredibly impressed by how much of the graphics stack is open, and how much of it has been reverse engineered for the closed platforms. But if we have a chance to do it differently here, and in particular avoid the long cycle of alienating the vendors and encouraging them to build out-of-tree elaborate stacks for later reverse engineering and catch-up, I would really like to.
There's currently one large benefit between these drivers and the graphics space as far as I know; nobody's trying to do unified drivers between Linux and other OS:es, so the whole "we need a messy shim layer and a universal driver" situation should be avoidable (and to be clear, we would not accept such drivers no matter what).
Quoted 4 lines
Anything else is imo just a long-term dis-service to the community of customers, other vendors, ... Adapting a famous quote: If you're ok with throwing away some long term software freedom for a bit of short term hardware support you'll get neither.
The argument here is not "short term hardware support", since that's not what we're adding (since you need more than the kernel pieces for that). What we're able to do is collaborate instead of having all these vendors work out-of-tree on their own with absolutely no discussions with us at all, and nowhere to share their work without setting up some new organization (with all the overhead from that). I think getting people to collaborate in-tree is the best shot we have at success.
Quoted 8 lines
So if someone propose to merge some open source kernel driver that requires piles of closed source userspace to be any use at all, I'm just not interested. And if the fpga folks have merged fpga drivers without at least a basic (non-optimizing) RTL compiler, then that was a grave mistake. That doing this is also technically a bad idea (for all the reasons already discussed) is just the icing on the top for me.
Quoted 14 lines
And to tie this back to the technical discussion, here's a scenario that's bound to happen:
1. vendor crams their open source driver into upstream, with full blob userspace
2. vendor gets bored (runs low on money, accidentally fired the entire old team, needs to do more value add, whatever, ...) rewrites the entire stack
3. vendor crams their new&completely incompatible open source stack into upstream
4. upstream is now unvoluntarily stuck maintaining 2 drivers for the exact same thing, and we can't fix anything of that because if you touch one side of the stack without undertstanding the other part you're guaranteed to create regressions (yes this is how this works with gpu drivers, we've learned this the hard way)
5. repeat
This can be avoided, in that we would not allow second completely separate stacks. We should have a transition point where we don't allow one-off weird custom drivers in the future, but we don't know what the shared implementation will look like yet.
We have precedence from the wifi space, where we pushed back and got vendors to move towards shared interfaces.
Quoted 6 lines
Hence for these technical reasons you'll then end up with a subsystem that only the vendor can touch, and hence also the vendor can abandon at will. Not like
drivers/gpu, where customers, consulting shops, students, ... routinely can&do add new features to existing drivers.This is not a winning move.
It depends on what the goal is. Complete software freedom? I agree, this might not get us much closer to that (but also not further). And if that's the goal, we should refuse to merge any driver that doesn't have open device firmware as well. Why would we have double standards in this area? Why are we allowing libusb to implement proprietary userspace drivers?
So, let's loop back to the technical arguments instead.
What we want from a technical goal is to avoid broad proliferation of completely separate out-of-tree software stacks, and get people to collaborate and benefit from each others work in ways that we can still change things over time where we need to from the kernel side. Is anyone disagreeing with that (technical) goal?
Unless there's disagreement on the goal, where the views differ is on how to get there -- whether we are better of pretending that this hardware doesn't exist, and try to come up with some elaborate shared framework that nobody is using yet, with the hopes that vendors will move over from their proprietary stack once they've already been successful in shipping that. Or whether we're better off getting them engaged with us, picking up their drivers for the early hardware and we all get exposure to the stacks and keep communication channels open with clear understanding that we expect this engagement to shift over time.
Since we're starting fresh here, we can set our own expectations
upfront: No second implementations unless they're onto a shared framework, and we can even preserve the right to remove hardware support (treat it as staging drivers) if a vendor disengages and goes away, or if promises in other areas are broken (such as open low-level userspace).
-Olof
Quoted 54 lines · Olof Johansson
Quoted 52 lines · Dave Airlie
Quoted 49 lines · Oded Gabbay
Quoted 34 lines · Dave Airlie
Adding Daniel as well.
Dave.
Quoted 28 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
Having large closed userspaces that we have no insight into means we get suboptimal locked for ever uAPIs. If someone in the future creates an open source userspace, we will end up in a place where they get suboptimal behaviour because they are locked into a uAPI that we can't change.
Dave.
Hi Dave,
While I always appreciate your opinion and happy to hear it, I totally disagree with you on this point.First of all, as you said, this device is NOT a GPU. Hence, I wasn't aware that this rule might apply to this driver or to any other driver outside of drm. Has this rule been applied to all the current drivers in the kernel tree with userspace facing API via IOCTLs, which are not in the drm subsystem ? I see the logic for GPUs as they drive the display of the entire machine, but this is an accelerator for a specific purpose, not something generic as GPU. I just don't see how one can treat them in the same way.
Quoted 8 lines
Quoted 8 lines
The logic isn't there for GPUs for those reason that we have an established library or that GPUs are in laptops. They are just where we learned the lessons of merging things whose primary reason for being in the kernel is to execute stuff from misc userspace stacks, where the uAPI has to remain stable indefinitely.
a) security - without knowledge of what the accelerator can do how can we know if the API you expose isn't just a giant root hole?
I'm willing to explain the security mechanisms we have in our device and how the driver initialize them in order to protect the host, and to isolate between users.
I've done a LOT of work on that during the design of the ASIC and I believe we have a good story there. If you want, we can go over that code and explain the architecture in more detail.
Quoted 7 lines
Quoted 7 lines
b) uAPI stability. Without a userspace for this, there is no way for anyone even if in possession of the hardware to validate the uAPI you provide and are asking the kernel to commit to supporting indefinitely is optimal or secure. If an open source userspace appears is it to be limited to API the closed userspace has created. It limits the future unnecessarily.
I understand what you are saying and I think (but I can't guarantee it yet) that I may be able to provide some minimal userspace to make sure this interface won't break.
Quoted 46 lines
Quoted 17 lines
Quoted 5 lines
There is no way that "someone" will create a userspace
for our H/W without the intimate knowledge of the H/W or without the ISA of our programmable cores. Maybe for large companies this request is valid, but for startups complying to this request is not realistic.So what benefit does the Linux kernel get from having support for this feature upstream?
If users can't access the necessary code to use it, why does this require to be maintained in the kernel.
Quoted 4 lines
To conclude, I think this approach discourage other companies from open sourcing their drivers and is counter-productive. I'm not sure you are aware of how difficult it is to convince startup management to opensource the code...
Quoted 7 lines
Oh I am, but I'm also more aware how quickly startups go away and leave the kernel holding a lot of code we don't know how to validate or use.
I'm opening to being convinced but I think defining new userspace facing APIs is a task that we should take a lot more seriously going forward to avoid mistakes of the past.
I think the most important thing here is to know that things are likely to change quite a bit over the next couple of years, and that we don't know yet what we actually need. If we hold off picking up support for hardware while all of this is ironed out, we'll miss out on being exposed to it, and will have a very tall hill to climb once we try to convince vendors to come into the fold. It's also not been a requirement for the other two drivers we have merged, as far as I can tell (CAPI and OpenCAPI) so the cat's already out of the bag.
I'd rather not get stuck in a stand-off needing the longterm solution to pick up the short term contribution. That way we can move over to a _new_ API once there's been a better chance of finding common grounds and once things settle down a bit, instead of trying to bring some larger legacy codebase for devices that people might no longer care much about over to the newer APIs.
It's better to be exposed to the HW and drivers now, than having people build large elaborate out-of-tree software stacks for this. It's also better to get them to come and collaborate now, instead of pushing them away until things are perfect.
Quoted 8 lines
Having a way to validate and exercise the userspace API is important, including ability to change it if needed. Would it be possible to open up the lowest userspace pieces (driver interactions), even if some other layers might not yet be, to exercise the device/kernel/userspace interfaces without "live" workload, etc?
-Olof
As I wrote above, I do think I could provide a very low userspace piece that will contain the IOCTL facing functions and perhaps an additional test code that will show how to run some simple tests on the hardware to provide users the ability to do minimal liveness checking.
I do want to ask that it won't block the upstream process because it could take some time to provide that as I would need to split our userspace code.
I will also need to clear that internally first, but I don't see a reason why I won't be able to do that.
But before I start doing that internally, I need to have some kind of assurance I won't do that for nothing. i.e, providing this library's code will be enough to satisfy this specific requirement (I'm not talking about other stuff of course that might show up in the review).
Thanks,
Oded
Oded
Greg Kroah-Hartman
maintainerQuoted 15 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
Quoted 4 lines
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
I understand that this is your position on when you accept drivers into the DRM layer, as you need to interact with common interfaces and a massive userspace stack at the same time. And that's wonderful, it allows you to be able to move both sides of that stack forward without removing support for devices that worked on older kernels.
But, that's not really the case with this new driver at all. We add new driver subsystems, and individual drivers, with loads of new ioctls, in every new kernel release. We don't impose on all of them the "your userspace code must be open" rule, so why is this new driver somehow different from them?
Yes, there is the fun legal issue of "derivative works" when talking about a userspace program that is written to only interact with a specific kernel driver using a custom api like this one has, and how the license of the kernel side (GPLv2) affects the userspace side (whatever), but that is something that I leave up to the lawyers who like discussing and enforcing such things.
When evaluating this driver (note, I saw it for a few revisions before Oded posted it here), all I did was try to make sure that it fit in properly with the kernel apis and methods of operations. Given that there are no in-kernel drivers for this type of device, and that it really is a pretty small shim layer around the hardware, which means that userspace does a lot of the heavy lifting, it is going to be a very hardware-specific user/kernel api, and that shows.
Sidenote, this could have almost just been a UIO driver, which would have put _ALL_ of the logic in userspace. At least this way we have a chance for the kernel code to be sane and not try to inflict problems on the rest of the system.
Going forward, it would be wonderful if we could come up with a unified api for how to interact with these types of hardware accelerators, but given the newness of this industry, and the vastly different ways people are trying to solve the problem, that is going to take a few attempts, and many years before we can get there. Until then, taking drivers like this into the kernel tree makes sense as that way all of our users will be able to use that hardware, and better yet, the rest of us can learn more about how this stuff works so that we can help out with that api generation when it happens.
So for now, I have no objection to taking this type of driver into the tree. Yes, it would be wonderful if we had an open userspace program to drive it so that we could actually test and make changes to the api over time, but I think that is something that the submitting company needs to realize will be better for them to do, as for right now, all of that testing and changes are their responsibility.
As for what directory the code should live in, I suggested "misc" as there was no other universal location, and I hate to see new subsystems be created with only one driver, as that's pretty sad. But it's just a name/location, I have no dog in the fight, so I really don't care where it ends up in the tree, just as long as it gets merged somewhere :)
thanks,
greg k-h
Hi,
Quoted 41 lines · Greg Kroah-Hartman
Quoted 15 lines · Dave Airlie
Quoted 6 lines · Oded Gabbay
Hello,
For those who don't know me, my name is Oded Gabbay (Kernel Maintainer for AMD's amdkfd driver, worked at RedHat's Desktop group) and I work at Habana Labs since its inception two and a half years ago.
Hey Oded,
So this creates a driver with a userspace facing API via ioctls. Although this isn't a "GPU" driver we have a rule in the graphics drivers are for accelerators that we don't merge userspace API with an appropriate userspace user.
Quoted 4 lines
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
I see nothing in these accelerator drivers that make me think we should be treating them different.
I understand that this is your position on when you accept drivers into the DRM layer, as you need to interact with common interfaces and a massive userspace stack at the same time. And that's wonderful, it allows you to be able to move both sides of that stack forward without removing support for devices that worked on older kernels.
But, that's not really the case with this new driver at all. We add new driver subsystems, and individual drivers, with loads of new ioctls, in every new kernel release. We don't impose on all of them the "your userspace code must be open" rule, so why is this new driver somehow different from them?
Yes, there is the fun legal issue of "derivative works" when talking about a userspace program that is written to only interact with a specific kernel driver using a custom api like this one has, and how the license of the kernel side (GPLv2) affects the userspace side (whatever), but that is something that I leave up to the lawyers who like discussing and enforcing such things.
Quoted 7 lines
When evaluating this driver (note, I saw it for a few revisions before Oded posted it here), all I did was try to make sure that it fit in properly with the kernel apis and methods of operations. Given that there are no in-kernel drivers for this type of device, and that it really is a pretty small shim layer around the hardware, which means that userspace does a lot of the heavy lifting, it is going to be a very hardware-specific user/kernel api, and that shows.
I brought this up because there are sort of, if you squint, three-ish of these already (the OpenCAPI/CAPI ones and now this). Also, Jonathan's comment about CCIX pieces coming as well.
I've talked to a handful of vendors in this space and more or less all of them hope that drivers/misc is still a suitable home for their driver by the time it's ready to post, and I know that if we keep them there, it'll only be one or two more drivers until we have this discussion anyway.
That's really why I brought it up now, to get a clear stance on "Yeah, we know these are all slightly different today, and we're willing to give them a predictable home for the first while as we figure out together how things should look". Keep in mind, this space is also currently a bit of a gold rush, with many people working hard to get to market with near-zero talk between them.
Quoted 4 lines
Sidenote, this could have almost just been a UIO driver, which would have put _ALL_ of the logic in userspace. At least this way we have a chance for the kernel code to be sane and not try to inflict problems on the rest of the system.
Yeah, and sharing hardware when you have userspace drivers tends to need a bunch of synchronization and coordination which leads to taller (closed?) stacks there. Having resource arbitration and sharing assisted by the kernel is usually the right thing, and we should encourage that.
Quoted 9 lines
Going forward, it would be wonderful if we could come up with a unified api for how to interact with these types of hardware accelerators, but given the newness of this industry, and the vastly different ways people are trying to solve the problem, that is going to take a few attempts, and many years before we can get there. Until then, taking drivers like this into the kernel tree makes sense as that way all of our users will be able to use that hardware, and better yet, the rest of us can learn more about how this stuff works so that we can help out with that api generation when it happens.
Exactly my viewpoint as well, combined with not pushing vendors towards nvidia models by default even if they start out separate, and having a chance to find inroads with them on engineering levels when they come to us with the drivers.
Absolutely best chance for success is _always_ when we can engage with the vendor engineers as peers, instead of going up and down the corporate charts first (you often need to do a bit of both, but having allies in engineering makes it much easier).
Quoted 6 lines
So for now, I have no objection to taking this type of driver into the tree. Yes, it would be wonderful if we had an open userspace program to drive it so that we could actually test and make changes to the api over time, but I think that is something that the submitting company needs to realize will be better for them to do, as for right now, all of that testing and changes are their responsibility.
I do think having requirements of being able to exercise the hardware is really valuable, and we should consider what a requirement for that would look like. For the Habana case that could be a separate low-level library and a test workload on top. For FPGA cases it could be a well-known reference bitstream with the vendor reference control/communication path + similar low-level pieces.
Quoted 5 lines
As for what directory the code should live in, I suggested "misc" as there was no other universal location, and I hate to see new subsystems be created with only one driver, as that's pretty sad. But it's just a name/location, I have no dog in the fight, so I really don't care where it ends up in the tree, just as long as it gets merged somewhere :)
I'm usually one to push back against new subsystems too, especially when I see a framework proposal with just one driver. In this case, given that we all know more vendors will come along, I think it makes sense to take the discussion and establish structure now. This should give some clarity to those who are out there that we haven't seen yet, and give them a chance to prepare for things such as the low-level userspace pieces mentioned above.
So I think setting this up now is the right thing to do, we know there will be more material here and having a common aggregation of it makes sense.
-Olof
Greg Kroah-Hartman
maintainerQuoted 15 lines · Olof Johansson
On Thu, Jan 24, 2019 at 11:37 PM Greg Kroah-Hartman
Quoted 5 lines
As for what directory the code should live in, I suggested "misc" as there was no other universal location, and I hate to see new subsystems be created with only one driver, as that's pretty sad. But it's just a name/location, I have no dog in the fight, so I really don't care where it ends up in the tree, just as long as it gets merged somewhere :)
I'm usually one to push back against new subsystems too, especially when I see a framework proposal with just one driver. In this case, given that we all know more vendors will come along, I think it makes sense to take the discussion and establish structure now. This should give some clarity to those who are out there that we haven't seen yet, and give them a chance to prepare for things such as the low-level userspace pieces mentioned above.
Quoted 3 lines
So I think setting this up now is the right thing to do, we know there will be more material here and having a common aggregation of it makes sense.
Ok, how about:
drivers/deep_thought/
as a first proposal.
Let the bikeshedding begin! :)
greg k-h
Quoted 21 lines · Greg Kroah-Hartman
Quoted 15 lines · Olof Johansson
On Thu, Jan 24, 2019 at 11:37 PM Greg Kroah-Hartman
Quoted 5 lines
As for what directory the code should live in, I suggested "misc" as there was no other universal location, and I hate to see new subsystems be created with only one driver, as that's pretty sad. But it's just a name/location, I have no dog in the fight, so I really don't care where it ends up in the tree, just as long as it gets merged somewhere :)
I'm usually one to push back against new subsystems too, especially when I see a framework proposal with just one driver. In this case, given that we all know more vendors will come along, I think it makes sense to take the discussion and establish structure now. This should give some clarity to those who are out there that we haven't seen yet, and give them a chance to prepare for things such as the low-level userspace pieces mentioned above.
Quoted 3 lines
So I think setting this up now is the right thing to do, we know there will be more material here and having a common aggregation of it makes sense.
Quoted 6 lines
Ok, how about:
drivers/deep_thought/as a first proposal.
Let the bikeshedding begin! :)
My original proposal upthread was driver/accel. I'm not sure whether Dave and/or anyone else wants to participate to start though, I hope they will at least join in once things are heading in the direction they want.
I'll post patches with the proposed moves and documentation of expectations shortly, hopefully to collect acks.
-Olof
cover HW accel subsystem
Per discussion in on the Habana Labs driver submission
(https://lore.kernel.org/lkml/[email protected]/),
there seems to be time to create a separate subsystem for hw accellerators instead of letting them proliferate around the tree (and/or in misc).
There's difference in opinion on how stringent the requirements are for a fully open stack for these kind of drivers. I've documented the middle road approach in the first patch (requiring some sort of open low-level userspace for the kernel interaction, and a way to use/test it).
Comments and suggestions for better approaches are definitely welcome.
PATCH 1/5 drivers/accel: Introduce subsystem
We're starting to see more of these kind of devices, the current upcoming wave will likely be around machine learning and inference engines. A few drivers have been added to drivers/misc for this, but it's timely to make it into a separate group of drivers/subsystem, to make it easier to find them, and to encourage collaboration between contributors.
Over time, we expect to build shared frameworks that the drivers will make use of, but how that framework needs to look like to fill the needs is still unclear, and the best way to gain that knowledge is to give the disparate implementations a shared location.
There has been some controversy around expectations for userspace stacks being open. The clear preference is to see that happen, and any driver and platform stack that is delivered like that will be given preferential treatment, and at some point in the future it might become the requirement. Until then, the bare minimum we need is an open low-level userspace such that the driver and HW interfaces can be exercised if someone is modifying the driver, even if the full details of the workload are not always available.
Bootstrapping this with myself and Greg as maintainers (since the current drivers will be moving out of drivers/misc). Looking forward to expanding that group over time.
--- MAINTAINERS | 8 ++++++++ drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/accel/Kconfig | 16 ++++++++++++++++ drivers/accel/Makefile | 5 +++++ 5 files changed, 32 insertions(+) create mode 100644 drivers/accel/Kconfig create mode 100644 drivers/accel/Makefile
MAINTAINERS +8 -0
@@ -7033,6 +7033,14 @@ W: https://linuxtv.org S: Supported F: drivers/media/platform/sti/hva +HW ACCELERATOR OFFLOAD SUBSYSTEM +M: Olof Johansson <[email protected]> +M: Greg Kroah-Hartman <[email protected]> +L: [email protected] +S: Supported +F: drivers/accel/ +F: Documentation/accelerators/ + HWPOISON MEMORY FAILURE HANDLING M: Naoya Horiguchi <[email protected]> L: [email protected]
drivers/Kconfig +2 -0
@@ -228,4 +228,6 @@ source "drivers/siox/Kconfig" source "drivers/slimbus/Kconfig" +source "drivers/accel/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -186,3 +186,4 @@ obj-$(CONFIG_MULTIPLEXER) += mux/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ obj-$(CONFIG_SIOX) += siox/ obj-$(CONFIG_GNSS) += gnss/ +obj-$(CONFIG_ACCEL) += accel/
drivers/accel/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +# +# Drivers for hardware offload accelerators +# See Documentation/accel/README.rst for more details +# + +menuconfig ACCEL + bool "Hardware offload accelerator support" + help + HW offload accelerators are used for high-bandwidth workloads + where a higher-level kernel/userspace interface isn't suitable. + +if ACCEL + +comment "HW Accellerator drivers" + +endif
drivers/accel/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for accel devices +# +
Signature · 1 line
2.11.0
PATCH v2 1/5 drivers/accel: Introduce subsystem
We're starting to see more of these kind of devices, the current upcoming wave will likely be around machine learning and inference engines. A few drivers have been added to drivers/misc for this, but it's timely to make it into a separate group of drivers/subsystem, to make it easier to find them, and to encourage collaboration between contributors.
Over time, we expect to build shared frameworks that the drivers will make use of, but how that framework needs to look like to fill the needs is still unclear, and the best way to gain that knowledge is to give the disparate implementations a shared location.
There has been some controversy around expectations for userspace stacks being open. The clear preference is to see that happen, and any driver and platform stack that is delivered like that will be given preferential treatment, and at some point in the future it might become the requirement. Until then, the bare minimum we need is an open low-level userspace such that the driver and HW interfaces can be exercised if someone is modifying the driver, even if the full details of the workload are not always available.
Bootstrapping this with myself and Greg as maintainers (since the current drivers will be moving out of drivers/misc). Looking forward to expanding that group over time.
---
v2:
I had missed a git add of the Documentation/ piece, which is the most important piece of this anyway. Sigh.
Documentation/accelerators/README.rst | 42 +++++++++++++++++++++++++++++++++++ MAINTAINERS | 8 +++++++ drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/accel/Kconfig | 16 +++++++++++++ drivers/accel/Makefile | 5 +++++ 6 files changed, 74 insertions(+) create mode 100644 Documentation/accelerators/README.rst create mode 100644 drivers/accel/Kconfig create mode 100644 drivers/accel/Makefile
Documentation/accelerators/README.rst new file +42 -0
@@ -0,0 +1,42 @@ +.. _readme: + +Hardware offload accelerator subsystem +====================================== + +This is a brief overview of the subsystem (grouping) of hardware +accelerators kept under drivers/accel + +Types of hardware supported +--------------------------- + + The general types of hardware supported are hardware devices that has + general interactions of sending commands and buffers to the hardware, + returning completions and possible filled buffers back, together + with the usual driver pieces around hardware control, setup, error + handling, etc. + + Drivers that fit into other subsystems are expected to be merged + there, and use the appropriate userspace interfaces of said functional + areas. We don't expect to see drivers for network, storage, graphics + and similar hardware implemented by drivers here. + +Expectations for contributions +------------------------------ + + - Platforms and hardware that has fully open stacks, from Firmware to + Userspace, are always going to be given preferential treatment. These + platforms give the best insight for behavior and interaction of all + layers, including ability to improve implementation across the stack + over time. + + - If a platform is partially proprietary, it is still expected that the + portions that interact the driver can be shared in a form that allows + for exercising the hardware/driver and evolution of the interface over + time. This could be separated into a shared library and test/sample + programs, for example. + + - Over time, there is an expectation to converge drivers over to shared + frameworks and interfaces. Until then, the general rule is that no + more than one driver per vendor will be acceptable. For vendors that + aren't participating in the work towards shared frameworks over time, + we reserve the right to phase out support for the hardware.
MAINTAINERS +8 -0
@@ -7033,6 +7033,14 @@ W: https://linuxtv.org S: Supported F: drivers/media/platform/sti/hva +HW ACCELERATOR OFFLOAD SUBSYSTEM +M: Olof Johansson <[email protected]> +M: Greg Kroah-Hartman <[email protected]> +L: [email protected] +S: Supported +F: drivers/accel/ +F: Documentation/accelerators/ + HWPOISON MEMORY FAILURE HANDLING M: Naoya Horiguchi <[email protected]> L: [email protected]
drivers/Kconfig +2 -0
@@ -228,4 +228,6 @@ source "drivers/siox/Kconfig" source "drivers/slimbus/Kconfig" +source "drivers/accel/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -186,3 +186,4 @@ obj-$(CONFIG_MULTIPLEXER) += mux/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ obj-$(CONFIG_SIOX) += siox/ obj-$(CONFIG_GNSS) += gnss/ +obj-$(CONFIG_ACCEL) += accel/
drivers/accel/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +# +# Drivers for hardware offload accelerators +# See Documentation/accel/README.rst for more details +# + +menuconfig ACCEL + bool "Hardware offload accelerator support" + help + HW offload accelerators are used for high-bandwidth workloads + where a higher-level kernel/userspace interface isn't suitable. + +if ACCEL + +comment "HW Accellerator drivers" + +endif
drivers/accel/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for accel devices +# +
Signature · 1 line
2.11.0
Randy Dunlap
reviewerRe: [PATCH v2 1/5] drivers/accel: Introduce subsystem
Hi,
Please see a few corrections inline...
Quoted 20 lines · Olof Johansson
Documentation/accelerators/README.rst | 42 +++++++++++++++++++++++++++++++++++ MAINTAINERS | 8 +++++++ drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/accel/Kconfig | 16 +++++++++++++ drivers/accel/Makefile | 5 +++++ 6 files changed, 74 insertions(+) create mode 100644 Documentation/accelerators/README.rst create mode 100644 drivers/accel/Kconfig create mode 100644 drivers/accel/MakefileDocumentation/accelerators/README.rst new file +2
-0@@ -0,0 +1,42 @@ +.. _readme: +
Documentation/accelerators/README.rst line 12
Quoted 10 lines
Documentation/accelerators/README.rst new file +10
-0+Hardware offload accelerator subsystem +====================================== + +This is a brief overview of the subsystem (grouping) of hardware +accelerators kept under drivers/accel + +Types of hardware supported +--------------------------- + + The general types of hardware supported are hardware devices that has
that have
Quoted 4 lines
Documentation/accelerators/README.rst new file +4
-0+ general interactions of sending commands and buffers to the hardware, + returning completions and possible filled buffers back, together + with the usual driver pieces around hardware control, setup, error + handling, etc.
Documentation/accelerators/README.rst line 26
Quoted 10 lines
Documentation/accelerators/README.rst new file +10
-0+ + Drivers that fit into other subsystems are expected to be merged + there, and use the appropriate userspace interfaces of said functional + areas. We don't expect to see drivers for network, storage, graphics + and similar hardware implemented by drivers here. + +Expectations for contributions +------------------------------ + + - Platforms and hardware that has fully open stacks, from Firmware to
that have
Documentation/accelerators/README.rst line 33
Quoted 7 lines
Documentation/accelerators/README.rst new file +7
-0+ Userspace, are always going to be given preferential treatment. These + platforms give the best insight for behavior and interaction of all + layers, including ability to improve implementation across the stack + over time. + + - If a platform is partially proprietary, it is still expected that the + portions that interact the driver can be shared in a form that allows
that interact with the driver
Quoted 16 lines
Documentation/accelerators/README.rst new file +9
-0+ for exercising the hardware/driver and evolution of the interface over + time. This could be separated into a shared library and test/sample + programs, for example. + + - Over time, there is an expectation to converge drivers over to shared + frameworks and interfaces. Until then, the general rule is that no + more than one driver per vendor will be acceptable. For vendors that + aren't participating in the work towards shared frameworks over time, + we reserve the right to phase out support for the hardware.drivers/accel/Kconfig new file +0
-0
drivers/accel/Kconfig line 8
Quoted 8 lines
drivers/accel/Kconfig new file +8
-0@@ -0,0 +1,16 @@ +# +# Drivers for hardware offload accelerators +# See Documentation/accel/README.rst for more details +# + +menuconfig ACCEL + bool "Hardware offload accelerator support" + help
Use tab instead of spaces above.
Quoted 8 lines
drivers/accel/Kconfig new file +8
-0+ HW offload accelerators are used for high-bandwidth workloads + where a higher-level kernel/userspace interface isn't suitable. + +if ACCEL + +comment "HW Accellerator drivers" + +endif
Signature · 1 line
~Randy
Re: [PATCH v2 1/5] drivers/accel: Introduce subsystem
In reply to Olof Johansson[+ linuxppc-dev, because cxl/ocxl are handled through powerpc - please cc on future versions of this series]
Quoted 25 lines · Olof Johansson
We're starting to see more of these kind of devices, the current upcoming wave will likely be around machine learning and inference engines. A few drivers have been added to
drivers/miscfor this, but it's timely to make it into a separate group ofdrivers/subsystem, to make it easier to find them, and to encourage collaboration between contributors.Over time, we expect to build shared frameworks that the drivers will make use of, but how that framework needs to look like to fill the needs is still unclear, and the best way to gain that knowledge is to give the disparate implementations a shared location.
There has been some controversy around expectations for userspace stacks being open. The clear preference is to see that happen, and any driver and platform stack that is delivered like that will be given preferential treatment, and at some point in the future it might become the requirement. Until then, the bare minimum we need is an open low-level userspace such that the driver and HW interfaces can be exercised if someone is modifying the driver, even if the full details of the workload are not always available.
Bootstrapping this with myself and Greg as maintainers (since the current drivers will be moving out of
drivers/misc). Looking forward to expanding that group over time.
[snip]
Quoted 31 lines
Documentation/accelerators/README.rst new file +31
-0+ +Hardware offload accelerator subsystem +====================================== + +This is a brief overview of the subsystem (grouping) of hardware +accelerators kept under drivers/accel + +Types of hardware supported +--------------------------- + + The general types of hardware supported are hardware devices that has + general interactions of sending commands and buffers to the hardware, + returning completions and possible filled buffers back, together + with the usual driver pieces around hardware control, setup, error + handling, etc. + + Drivers that fit into other subsystems are expected to be merged + there, and use the appropriate userspace interfaces of said functional + areas. We don't expect to see drivers for network, storage, graphics + and similar hardware implemented by drivers here. + +Expectations for contributions +------------------------------ + + - Platforms and hardware that has fully open stacks, from Firmware to + Userspace, are always going to be given preferential treatment. These + platforms give the best insight for behavior and interaction of all + layers, including ability to improve implementation across the stack + over time. + + - If a platform is partially proprietary, it is still expected that the
Documentation/accelerators/README.rst line 42
Quoted 10 lines
Documentation/accelerators/README.rst new file +10
-0+ portions that interact the driver can be shared in a form that allows + for exercising the hardware/driver and evolution of the interface over + time. This could be separated into a shared library and test/sample + programs, for example. + + - Over time, there is an expectation to converge drivers over to shared + frameworks and interfaces. Until then, the general rule is that no + more than one driver per vendor will be acceptable. For vendors that + aren't participating in the work towards shared frameworks over time, + we reserve the right to phase out support for the hardware.
How exactly do generic drivers for interconnect protocols, such as cxl/ocxl, fit in here?
cxl and ocxl are not drivers for a specific device, they are generic drivers which can be used with any device implementing the CAPI or OpenCAPI protocol respectively - many of which will be FPGA boards flashed with customer-designed accelerator cores for specific workloads, some will be accelerators using ASICs or using FPGA images supplied by vendors, some will be driven from userspace, others using the cxl/ocxl kernel API, etc.
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Re: [PATCH v2 1/5] drivers/accel: Introduce subsystem
Le 27/01/2019 à 05:31, Andrew Donnellan a écrit :
Quoted 75 lines
[+ linuxppc-dev, because cxl/ocxl are handled through powerpc - please cc on future versions of this series]
Quoted 25 lines · Olof Johansson
We're starting to see more of these kind of devices, the current upcoming wave will likely be around machine learning and inference engines. A few drivers have been added to
drivers/miscfor this, but it's timely to make it into a separate group ofdrivers/subsystem, to make it easier to find them, and to encourage collaboration between contributors.Over time, we expect to build shared frameworks that the drivers will make use of, but how that framework needs to look like to fill the needs is still unclear, and the best way to gain that knowledge is to give the disparate implementations a shared location.
There has been some controversy around expectations for userspace stacks being open. The clear preference is to see that happen, and any driver and platform stack that is delivered like that will be given preferential treatment, and at some point in the future it might become the requirement. Until then, the bare minimum we need is an open low-level userspace such that the driver and HW interfaces can be exercised if someone is modifying the driver, even if the full details of the workload are not always available.
Bootstrapping this with myself and Greg as maintainers (since the current drivers will be moving out of
drivers/misc). Looking forward to expanding that group over time.[snip]
Quoted 34 lines
Documentation/accelerators/README.rst new file +33
-0+ +Hardware offload accelerator subsystem +====================================== + +This is a brief overview of the subsystem (grouping) of hardware +accelerators kept under drivers/accel + +Types of hardware supported +--------------------------- + + The general types of hardware supported are hardware devices that has + general interactions of sending commands and buffers to the hardware, + returning completions and possible filled buffers back, together + with the usual driver pieces around hardware control, setup, error + handling, etc. + + Drivers that fit into other subsystems are expected to be merged + there, and use the appropriate userspace interfaces of said functional + areas. We don't expect to see drivers for network, storage, graphics + and similar hardware implemented by drivers here. + +Expectations for contributions +------------------------------ + + - Platforms and hardware that has fully open stacks, from Firmware to + Userspace, are always going to be given preferential treatment. These + platforms give the best insight for behavior and interaction of all + layers, including ability to improve implementation across the stack + over time. + + - If a platform is partially proprietary, it is still expected that the + portions that interact the driver can be shared in a form that allows + for exercising the hardware/driver and evolution of the interfaceover
Quoted 8 lines
+ time. This could be separated into a shared library and test/sample + programs, for example.
+
+ - Over time, there is an expectation to converge drivers over to shared + frameworks and interfaces. Until then, the general rule is that no + more than one driver per vendor will be acceptable. For vendors that + aren't participating in the work towards shared frameworks over time, + we reserve the right to phase out support for the hardware.How exactly do generic drivers for interconnect protocols, such as cxl/ocxl, fit in here?
Quoted 1 line
cxl and ocxl are not drivers for a specific device, they are generic drivers which can be used with any device implementing the CAPI or OpenCAPI protocol respectively - many of which will be FPGA boards flashed with customer-designed accelerator cores for specific workloads, some will be accelerators using ASICs or using FPGA images supplied by vendors, some will be driven from userspace, others using the cxl/ocxl kernel API, etc.
I have the same reservation as Andrew. While my first reaction was to think that cxl and ocxl should be part of the accel subsystem, they hardly seem to fit the stated goals. Furthermore, there are implications there, as all the distros currently shipping cxl and ocxl as modules on powerpc would need to have their config modified to enable CONFIG_ACCEL.
Fred
Re: [PATCH 1/5] drivers/accel: Introduce subsystem
In reply to Olof JohanssonQuoted 21 lines · Olof Johansson
We're starting to see more of these kind of devices, the current upcoming wave will likely be around machine learning and inference engines. A few drivers have been added to
drivers/miscfor this, but it's timely to make it into a separate group ofdrivers/subsystem, to make it easier to find them, and to encourage collaboration between contributors.Over time, we expect to build shared frameworks that the drivers will make use of, but how that framework needs to look like to fill the needs is still unclear, and the best way to gain that knowledge is to give the disparate implementations a shared location.
There has been some controversy around expectations for userspace stacks being open. The clear preference is to see that happen, and any driver and platform stack that is delivered like that will be given preferential treatment, and at some point in the future it might become the requirement. Until then, the bare minimum we need is an open low-level userspace such that the driver and HW interfaces can be exercised if someone is modifying the driver, even if the full details of the workload are not always available.
Quoted 6 lines
Bootstrapping this with myself and Greg as maintainers (since the current drivers will be moving out of
drivers/misc). Looking forward to expanding that group over time.Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Olof Johansson <[email protected]>
I spent a bit of time reading the proposed drivers, mostly just their uapi (habanalabs and ocxl&cxl), and there's really no technical difference I think between an accelaration driver sitting in drivers/gpu and an accelaration driver sitting in drivers/accel. Except:
- drivers/gpu already has common interfaces for the things you'll probably want to standardize (buffer sharing, syncronization primitives, scheduler - right now we're working on figuring out some common tracepoints).
- Maybe even more important, drivers/gpu has the lessons learned in its codebase about what not to standardize between drivers (everything else, you'll regret it, we've been there).
- drivers/gpu is the subsystem with 20 years of experience writing tiny shim drivers in the kernel for high performance accelarators that need a pretty huge stack in userspace to make them do anything useful. 20 years ago all the rage to make faster was graphics, now it's AI. Looks exactly the same from a kernel pov - command buffers, gigabytes of DMA and a security/long term support nightmare.
- drivers/gpu requires open source. The real thing, not some demo that does a few DMA operations.
And now we have drivers/accel and someone gets to explain to nvidia (or arm or whatever) how their exact same drivers (and well run engineering orgs really only invent command submission once) can be merged when they say it's for a TPU, and will get rejected when they say it's for a GPU. Or someone gets to explain to TPU+GPU vendors why their driver is not cool (because we'd end up with two), while their startup-competition only doing a TPU is totally fine and merged into upstream. Or we just stuff all the kernel drivers for blobby userspace into drivers/accel and otherwise ignore each another.
I guess that last option would at least somewhat help me, since I wont ever have to explain anymore why we're the radical commies on dri-devel :-)
Anyway, only reason I replied here again is because I accidentally started a private thread (well was too lazy to download the mbox to properly reply), and that's not good either. But I don't think anyone's going to change their opinion here, I think this reply is just for the record.
Cheers, Daniel
PS: Seen that there's a v2 of this now with Documentation, hasn't reached my inbox (yet). I don't think that one clarifies any of the tricky questions between drivers/gpu and drivers/accel, so figured won't harm if I leave the reply on v1.
Quoted 85 lines
--- MAINTAINERS | 8 ++++++++ drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/accel/Kconfig | 16 ++++++++++++++++ drivers/accel/Makefile | 5 +++++ 5 files changed, 32 insertions(+) create mode 100644 drivers/accel/Kconfig create mode 100644 drivers/accel/MakefileMAINTAINERS +8
-0@@ -7033,6 +7033,14 @@ W: https://linuxtv.org S: Supported F: drivers/media/platform/sti/hva +HW ACCELERATOR OFFLOAD SUBSYSTEM +M: Olof Johansson <[email protected]> +M: Greg Kroah-Hartman <[email protected]> +L: [email protected] +S: Supported +F: drivers/accel/ +F: Documentation/accelerators/ + HWPOISON MEMORY FAILURE HANDLING M: Naoya Horiguchi <[email protected]> L: [email protected]drivers/Kconfig +2
-0@@ -228,4 +228,6 @@ source "drivers/siox/Kconfig" source "drivers/slimbus/Kconfig" +source "drivers/accel/Kconfig" + endmenudrivers/Makefile +1
-0@@ -186,3 +186,4 @@ obj-$(CONFIG_MULTIPLEXER) += mux/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ obj-$(CONFIG_SIOX) += siox/ obj-$(CONFIG_GNSS) += gnss/ +obj-$(CONFIG_ACCEL) += accel/drivers/accel/Kconfig new file +16
-0@@ -0,0 +1,16 @@ +# +# Drivers for hardware offload accelerators +# See Documentation/accel/README.rst for more details +# + +menuconfig ACCEL + bool "Hardware offload accelerator support" + help + HW offload accelerators are used for high-bandwidth workloads + where a higher-level kernel/userspace interface isn't suitable. + +if ACCEL + +comment "HW Accellerator drivers" + +endifdrivers/accel/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for accel devices +# +Signature · 1 line
2.11.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH 1/5] drivers/accel: Introduce subsystem
Hi Olof & Greg,
Ok I thought about what this means in practice a bit more over the w/e, and I think we need to drag this discussion on for a bit more.
Quoted 54 lines · Daniel Vetter
Quoted 21 lines · Olof Johansson
We're starting to see more of these kind of devices, the current upcoming wave will likely be around machine learning and inference engines. A few drivers have been added to
drivers/miscfor this, but it's timely to make it into a separate group ofdrivers/subsystem, to make it easier to find them, and to encourage collaboration between contributors.Over time, we expect to build shared frameworks that the drivers will make use of, but how that framework needs to look like to fill the needs is still unclear, and the best way to gain that knowledge is to give the disparate implementations a shared location.
There has been some controversy around expectations for userspace stacks being open. The clear preference is to see that happen, and any driver and platform stack that is delivered like that will be given preferential treatment, and at some point in the future it might become the requirement. Until then, the bare minimum we need is an open low-level userspace such that the driver and HW interfaces can be exercised if someone is modifying the driver, even if the full details of the workload are not always available.
Quoted 6 lines
Bootstrapping this with myself and Greg as maintainers (since the current drivers will be moving out of
drivers/misc). Looking forward to expanding that group over time.Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Olof Johansson <[email protected]>I spent a bit of time reading the proposed drivers, mostly just their uapi (habanalabs and ocxl&cxl), and there's really no technical difference I think between an accelaration driver sitting in
drivers/gpuand an accelaration driver sitting indrivers/accel. Except:-
drivers/gpualready has common interfaces for the things you'll probably want to standardize (buffer sharing, syncronization primitives, scheduler - right now we're working on figuring out some common tracepoints).- Maybe even more important,
drivers/gpuhas the lessons learned in its codebase about what not to standardize between drivers (everything else, you'll regret it, we've been there).-
drivers/gpuis the subsystem with 20 years of experience writing tiny shim drivers in the kernel for high performance accelarators that need a pretty huge stack in userspace to make them do anything useful. 20 years ago all the rage to make faster was graphics, now it's AI. Looks exactly the same from a kernel pov - command buffers, gigabytes of DMA and asecurity/longterm support nightmare.-
drivers/gpurequires open source. The real thing, not some demo that does a few DMA operations.
Quoted 9 lines
And now we have
drivers/acceland someone gets to explain to nvidia (or arm or whatever) how their exact same drivers (and well run engineering orgs really only invent command submission once) can be merged when they say it's for a TPU, and will get rejected when they say it's for a GPU. Or someone gets to explain to TPU+GPU vendors why their driver is not cool (because we'd end up with two), while their startup-competition only doing a TPU is totally fine and merged into upstream. Or we just stuff all the kernel drivers for blobby userspace intodrivers/acceland otherwise ignore each another.
One awkward scenario I've missed is the following:
1. the fully open stack for accelarating glow/tensorflow/DNN that we're planning to make happen takes off. Rough idea is llvm+spriv+clover (in mesa) + gallium backends (also mesa3d) + drm.
2. if that's the case and someone writes an r/e'ed driver for such a TPU (and the vendor supporting only their blob stack) then the reasonable thing would be to write that stack on top of the existing open source accelarator infrastructure. So a new/2nd driver in the kernel, using the drm+mesa infrastructure.
3. this means to not block r/e efforts on we need to be ok with duplicated drivers between drivers/accel and drivers/gpu - not being able to share code with all the other programmable accelarators will make it nigh impossible to have a working r/e'ed stack. We already see this on the gl/vk/cl side, where the mesa drivers tend to be 1-2 orders of magnitude smaller than the proprietary/vendor stacks (whether open or closed).
Quoted 9 lines
I guess that last option would at least somewhat help me, since I wont ever have to explain anymore why we're the radical commies on dri-devel :-)
Anyway, only reason I replied here again is because I accidentally started a private thread (well was too lazy to download the mbox to properly reply), and that's not good either. But I don't think anyone's going to change their opinion here, I think this reply is just for the record.
Quoted 6 lines
Cheers, Daniel
PS: Seen that there's a v2 of this now with Documentation, hasn't reached my inbox (yet). I don't think that one clarifies any of the tricky questions between
drivers/gpuanddrivers/accel, so figured won't harm if I leave the reply on v1.
Given the above revising my stance, and I think your item to exclude overlap between drivers/accel and drivers/gpu is actually harmful. And we instead need a line that yes, there is overlap, and we do expect the occasional duplicated driver for the same hardware. I think that's going to have the best outcome:
- It's not going to piss off the drivers/gpu people any more than drivers/accel itself does, you already scored all the sighs you'll get I think. So won't make things worse.
- It's going to be the technically sound decision, since no more "is this a tpu or gpu" non-technical tricky questions that just depend upon what you market a chip for, instead of what it is.
- I think it's going to be much quicker to prove whether drivers/gpu is too strict with merging drivers and has harmed the overall ecosystem, since you'll have many more drivers to potentially merge. One argument in your favour is clearly that we've never tried to drop the open source userspace requirement. Imo if we're going to do this experiment, we should do it right.
- There's not going to be a problem for accelarators that need to work together with atomic modeset drivers or v4l drivers for displaying their computation results - all you need for that is dma-buf import, and you'll need that sooner or later anyway in drivers/accel. dma-buf compatibility extends all gfx userspace protocols (I think we rev'ed them all to add dma-buf support). There's also not going to be coordination problems due to this with drivers/gpu, since all the dma-buf bits you'll need are already in drivers/dma-buf.
- It might actually make r/e'ing gpus easier, since currently you need to boot 2 different kernels: One with the upstream drm stack, the other with downstream vendor stack. If you actually manage to get all these drivers merged in a useable state that would become better.
- Essentially this would make drivers/accel the -staging for drivers/gpu, at least from our pov. I don't think that's going to be an issue - with Greg you already have the residential expert for maintaining dumpster fires on the team. And as long as we don't try to share code (beyond stuff in drivers/dma-buf) I don't think this will result in the coordination pains we've had with display drivers in -staging.
- This is not going to set a new precedence - there's been plenty of duplicated subsystem, especially for drivers. Occasionally you just need to burn it all down and start over.
- Like with your proposal here for drivers/accel we can always change the rules in a few years, or whenever it's clear what to do. And I think the positions between the drivers/gpu and drivers/accel folks are fundamentally opposed, there's not really a room for a both ways compromise, best seems to decide this by actually trying it out.
- Plus, I can just point people at you instead of having to explain why we insist on open source for accelarators in drivers/gpu. That wasn't meant as a joke, not entirely at least, it's kinda tiring to have this discussion at least once every year ...
tldr; If you want to do this, do it right.
All we need is to drop your paragraph about avoiding overlap with drivers/gpu, and instead acknowledge that there is an overlap with the accelarator drivers in drivers/gpu and clearly state that both subsystems are going to be ok with that overlap and duplication. I'd ack that version.
Cheers, Daniel
Quoted 90 lines
Quoted 83 lines
--- MAINTAINERS | 8 ++++++++ drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/accel/Kconfig | 16 ++++++++++++++++ drivers/accel/Makefile | 5 +++++ 5 files changed, 32 insertions(+) create mode 100644 drivers/accel/Kconfig create mode 100644 drivers/accel/MakefileMAINTAINERS +8
-0@@ -7033,6 +7033,14 @@ W: https://linuxtv.org S: Supported F: drivers/media/platform/sti/hva +HW ACCELERATOR OFFLOAD SUBSYSTEM +M: Olof Johansson <[email protected]> +M: Greg Kroah-Hartman <[email protected]> +L: [email protected] +S: Supported +F: drivers/accel/ +F: Documentation/accelerators/ + HWPOISON MEMORY FAILURE HANDLING M: Naoya Horiguchi <[email protected]> L: [email protected]drivers/Kconfig +2
-0@@ -228,4 +228,6 @@ source "drivers/siox/Kconfig" source "drivers/slimbus/Kconfig" +source "drivers/accel/Kconfig" + endmenudrivers/Makefile +1
-0@@ -186,3 +186,4 @@ obj-$(CONFIG_MULTIPLEXER) += mux/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ obj-$(CONFIG_SIOX) += siox/ obj-$(CONFIG_GNSS) += gnss/ +obj-$(CONFIG_ACCEL) += accel/drivers/accel/Kconfig new file +16
-0@@ -0,0 +1,16 @@ +# +# Drivers for hardware offload accelerators +# See Documentation/accel/README.rst for more details +# + +menuconfig ACCEL + bool "Hardware offload accelerator support" + help + HW offload accelerators are used for high-bandwidth workloads + where a higher-level kernel/userspace interface isn't suitable. + +if ACCEL + +comment "HW Accellerator drivers" + +endifdrivers/accel/Makefile new file +5
-1@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for accel devices +# + --Quoted 2 lines
2.11.0
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 2/5 cxl: Move to drivers/accel
In reply to Olof JohanssonMove include files in separate commit, so leave them alone for now.
---
MAINTAINERS | 2 +-
drivers/accel/Kconfig | 2 ++
drivers/accel/Makefile | 1 +
drivers/{misc => accel}/cxl/Kconfig | 0
drivers/{misc => accel}/cxl/Makefile | 0
drivers/{misc => accel}/cxl/api.c | 0
drivers/{misc => accel}/cxl/base.c | 0
drivers/{misc => accel}/cxl/context.c | 0
drivers/{misc => accel}/cxl/cxl.h | 0
drivers/{misc => accel}/cxl/cxllib.c | 0
drivers/{misc => accel}/cxl/debugfs.c | 0
drivers/{misc => accel}/cxl/fault.c | 0
drivers/{misc => accel}/cxl/file.c | 0
drivers/{misc => accel}/cxl/flash.c | 0
drivers/{misc => accel}/cxl/guest.c | 0
drivers/{misc => accel}/cxl/hcalls.c | 0
drivers/{misc => accel}/cxl/hcalls.h | 0
drivers/{misc => accel}/cxl/irq.c | 0
drivers/{misc => accel}/cxl/main.c | 0
drivers/{misc => accel}/cxl/native.c | 0
drivers/{misc => accel}/cxl/of.c | 0
drivers/{misc => accel}/cxl/pci.c | 0
drivers/{misc => accel}/cxl/sysfs.c | 0
drivers/{misc => accel}/cxl/trace.c | 0
drivers/{misc => accel}/cxl/trace.h | 0
drivers/{misc => accel}/cxl/vphb.c | 0
drivers/misc/Kconfig | 1 -
drivers/misc/Makefile | 1 -
28 files changed, 4 insertions(+), 3 deletions(-)
rename drivers/{misc => accel}/cxl/Kconfig (100%)
rename drivers/{misc => accel}/cxl/Makefile (100%)
rename drivers/{misc => accel}/cxl/api.c (100%)
rename drivers/{misc => accel}/cxl/base.c (100%)
rename drivers/{misc => accel}/cxl/context.c (100%)
rename drivers/{misc => accel}/cxl/cxl.h (100%)
rename drivers/{misc => accel}/cxl/cxllib.c (100%)
rename drivers/{misc => accel}/cxl/debugfs.c (100%)
rename drivers/{misc => accel}/cxl/fault.c (100%)
rename drivers/{misc => accel}/cxl/file.c (100%)
rename drivers/{misc => accel}/cxl/flash.c (100%)
rename drivers/{misc => accel}/cxl/guest.c (100%)
rename drivers/{misc => accel}/cxl/hcalls.c (100%)
rename drivers/{misc => accel}/cxl/hcalls.h (100%)
rename drivers/{misc => accel}/cxl/irq.c (100%)
rename drivers/{misc => accel}/cxl/main.c (100%)
rename drivers/{misc => accel}/cxl/native.c (100%)
rename drivers/{misc => accel}/cxl/of.c (100%)
rename drivers/{misc => accel}/cxl/pci.c (100%)
rename drivers/{misc => accel}/cxl/sysfs.c (100%)
rename drivers/{misc => accel}/cxl/trace.c (100%)
rename drivers/{misc => accel}/cxl/trace.h (100%)
rename drivers/{misc => accel}/cxl/vphb.c (100%)MAINTAINERS +1 -1
@@ -4214,7 +4214,7 @@ M: Andrew Donnellan <[email protected]> L: [email protected] S: Supported F: arch/powerpc/platforms/powernv/pci-cxl.c -F: drivers/misc/cxl/ +F: drivers/accel/cxl/ F: include/misc/cxl* F: include/uapi/misc/cxl.h F: Documentation/powerpc/cxl.txt
drivers/accel/Kconfig +2 -0
@@ -13,4 +13,6 @@ if ACCEL comment "HW Accellerator drivers" +source "drivers/accel/cxl/Kconfig" + endif
drivers/accel/Makefile +1 -0
@@ -3,3 +3,4 @@ # Makefile for accel devices # +obj-$(CONFIG_CXL_BASE) += cxl/
drivers/accel/cxl/Kconfig renamed from drivers/misc/cxl/Kconfig +0 -0
drivers/accel/cxl/Makefile renamed from drivers/misc/cxl/Makefile +0 -0
drivers/accel/cxl/api.c renamed from drivers/misc/cxl/api.c +0 -0
drivers/accel/cxl/base.c renamed from drivers/misc/cxl/base.c +0 -0
drivers/accel/cxl/context.c renamed from drivers/misc/cxl/context.c +0 -0
drivers/accel/cxl/cxl.h renamed from drivers/misc/cxl/cxl.h +0 -0
drivers/accel/cxl/cxllib.c renamed from drivers/misc/cxl/cxllib.c +0 -0
drivers/accel/cxl/debugfs.c renamed from drivers/misc/cxl/debugfs.c +0 -0
drivers/accel/cxl/fault.c renamed from drivers/misc/cxl/fault.c +0 -0
drivers/accel/cxl/file.c renamed from drivers/misc/cxl/file.c +0 -0
drivers/accel/cxl/flash.c renamed from drivers/misc/cxl/flash.c +0 -0
drivers/accel/cxl/guest.c renamed from drivers/misc/cxl/guest.c +0 -0
drivers/accel/cxl/hcalls.c renamed from drivers/misc/cxl/hcalls.c +0 -0
drivers/accel/cxl/hcalls.h renamed from drivers/misc/cxl/hcalls.h +0 -0
drivers/accel/cxl/irq.c renamed from drivers/misc/cxl/irq.c +0 -0
drivers/accel/cxl/main.c renamed from drivers/misc/cxl/main.c +0 -0
drivers/accel/cxl/native.c renamed from drivers/misc/cxl/native.c +0 -0
drivers/accel/cxl/of.c renamed from drivers/misc/cxl/of.c +0 -0
drivers/accel/cxl/pci.c renamed from drivers/misc/cxl/pci.c +0 -0
drivers/accel/cxl/sysfs.c renamed from drivers/misc/cxl/sysfs.c +0 -0
drivers/accel/cxl/trace.c renamed from drivers/misc/cxl/trace.c +0 -0
drivers/accel/cxl/trace.h renamed from drivers/misc/cxl/trace.h +0 -0
drivers/accel/cxl/vphb.c renamed from drivers/misc/cxl/vphb.c +0 -0
drivers/misc/Kconfig +0 -1
@@ -532,7 +532,6 @@ source "drivers/misc/vmw_vmci/Kconfig" source "drivers/misc/mic/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" -source "drivers/misc/cxl/Kconfig" source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" endmenu
drivers/misc/Makefile +0 -1
@@ -52,7 +52,6 @@ obj-y += mic/ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o -obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o obj-$(CONFIG_ASPEED_LPC_SNOOP) += aspeed-lpc-snoop.o obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o
Signature · 1 line
2.11.0
PATCH 3/5 drivers/accel: cxl: Move non-uapi include files
In reply to Olof JohanssonSeparate to expose the edits vs pure moves.
---
MAINTAINERS | 2 +-
arch/powerpc/include/asm/pnv-pci.h | 2 +-
arch/powerpc/mm/copro_fault.c | 2 +-
arch/powerpc/mm/hash_native_64.c | 2 +-
arch/powerpc/mm/pgtable-book3s64.c | 2 +-
arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
drivers/accel/cxl/api.c | 2 +-
drivers/accel/cxl/base.c | 2 +-
drivers/accel/cxl/cxl.h | 4 ++--
drivers/accel/cxl/cxllib.c | 2 +-
drivers/accel/cxl/irq.c | 2 +-
drivers/accel/cxl/main.c | 2 +-
drivers/accel/cxl/native.c | 2 +-
drivers/accel/cxl/pci.c | 2 +-
drivers/accel/cxl/vphb.c | 2 +-
drivers/scsi/cxlflash/cxl_hw.c | 2 +-
include/{misc => linux/accel}/cxl-base.h | 4 ++--
include/{misc => linux/accel}/cxl.h | 6 +++---
include/{misc => linux/accel}/cxllib.h | 6 +++---
19 files changed, 25 insertions(+), 25 deletions(-)
rename include/{misc => linux/accel}/cxl-base.h (94%)
rename include/{misc => linux/accel}/cxl.h (99%)
rename include/{misc => linux/accel}/cxllib.h (97%)MAINTAINERS +1 -1
@@ -4215,7 +4215,7 @@ L: [email protected] S: Supported F: arch/powerpc/platforms/powernv/pci-cxl.c F: drivers/accel/cxl/ -F: include/misc/cxl* +F: include/linux/accel/cxl* F: include/uapi/misc/cxl.h F: Documentation/powerpc/cxl.txt F: Documentation/ABI/testing/sysfs-class-cxl
arch/powerpc/include/asm/pnv-pci.h +1 -1
@@ -13,7 +13,7 @@#include <linux/pci.h> #include <linux/pci_hotplug.h> #include <linux/irq.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #include <asm/opal-api.h> #define PCI_SLOT_ID_PREFIX (1UL << 63)
arch/powerpc/mm/copro_fault.c +1 -1
@@ -26,7 +26,7 @@#include <asm/reg.h> #include <asm/copro.h> #include <asm/spu.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> /* * This ought to be kept in sync with the powerpc specific do_page_fault
arch/powerpc/mm/hash_native_64.c +1 -1
@@ -31,7 +31,7 @@#include <asm/ppc-opcode.h> #include <asm/feature-fixups.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #ifdef DEBUG_LOW #define DBG_LOW(fmt...) udbg_printf(fmt)
arch/powerpc/mm/pgtable-book3s64.c +1 -1
@@ -10,7 +10,7 @@#include <linux/sched.h> #include <linux/mm_types.h> #include <linux/memblock.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #include <asm/pgalloc.h> #include <asm/tlb.h>
arch/powerpc/platforms/powernv/pci-ioda.c +1 -1
@@ -41,7 +41,7 @@#include <asm/pnv-pci.h> #include <asm/mmzone.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #include "powernv.h" #include "pci.h"
drivers/accel/cxl/api.c +1 -1
@@ -10,7 +10,7 @@#include <linux/pci.h> #include <linux/slab.h> #include <linux/file.h> -#include <misc/cxl.h> +#include <linux/accel/cxl.h> #include <linux/module.h> #include <linux/mount.h> #include <linux/sched/mm.h>
drivers/accel/cxl/base.c +1 -1
@@ -10,7 +10,7 @@#include <linux/module.h> #include <linux/rcupdate.h> #include <asm/errno.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #include <linux/of_platform.h> #include "cxl.h"
drivers/accel/cxl/cxl.h +2 -2
@@ -22,9 +22,9 @@#include <asm/cputable.h> #include <asm/mmu.h> #include <asm/reg.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> -#include <misc/cxl.h> +#include <linux/accel/cxl.h> #include <uapi/misc/cxl.h> extern uint cxl_verbose;
drivers/accel/cxl/cxllib.c +1 -1
@@ -10,7 +10,7 @@#include <linux/hugetlb.h> #include <linux/sched/mm.h> #include <asm/pnv-pci.h> -#include <misc/cxllib.h> +#include <linux/accel/cxllib.h> #include "cxl.h"
drivers/accel/cxl/irq.c +1 -1
@@ -14,7 +14,7 @@#include <linux/slab.h> #include <linux/pid.h> #include <asm/cputable.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #include "cxl.h" #include "trace.h"
drivers/accel/cxl/main.c +1 -1
@@ -22,7 +22,7 @@#include <linux/sched/task.h> #include <asm/cputable.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #include "cxl.h" #include "trace.h"
drivers/accel/cxl/native.c +1 -1
@@ -17,7 +17,7 @@#include <linux/delay.h> #include <asm/synch.h> #include <asm/switch_to.h> -#include <misc/cxl-base.h> +#include <linux/accel/cxl-base.h> #include "cxl.h" #include "trace.h"
drivers/accel/cxl/pci.c +1 -1
@@ -24,7 +24,7 @@#include <asm/reg.h> #include "cxl.h" -#include <misc/cxl.h> +#include <linux/accel/cxl.h> #define CXL_PCI_VSEC_ID 0x1280
drivers/accel/cxl/vphb.c +1 -1
@@ -8,7 +8,7 @@*/ #include <linux/pci.h> -#include <misc/cxl.h> +#include <linux/accel/cxl.h> #include "cxl.h" static int cxl_pci_probe_mode (struct pci_bus *bus)
drivers/scsi/cxlflash/cxl_hw.c +1 -1
@@ -12,7 +12,7 @@* 2 of the License, or (at your option) any later version. */ -#include <misc/cxl.h> +#include <linux/accel/cxl.h> #include "backend.h"
include/linux/accel/cxl-base.h renamed from include/misc/cxl-base.h +2 -2
@@ -7,8 +7,8 @@* 2 of the License, or (at your option) any later version. */ -#ifndef _MISC_CXL_BASE_H -#define _MISC_CXL_BASE_H +#ifndef _LINUX_ACCEL_CXL_BASE_H +#define _LINUX_ACCEL_CXL_BASE_H#ifdef CONFIG_CXL_BASE
include/linux/accel/cxl.h renamed from include/misc/cxl.h +3 -3
@@ -7,8 +7,8 @@* 2 of the License, or (at your option) any later version. */ -#ifndef _MISC_CXL_H -#define _MISC_CXL_H +#ifndef _LINUX_ACCEL_CXL_H +#define _LINUX_ACCEL_CXL_H#include <linux/pci.h> #include <linux/poll.h>
@@ -266,4 +266,4 @@ void cxl_set_driver_ops(struct cxl_context *ctx,void cxl_context_events_pending (struct cxl_context *ctx,unsigned int new_events); -#endif /* _MISC_CXL_H */ +#endif /* _LINUX_ACCEL_CXL_H */
include/linux/accel/cxllib.h renamed from include/misc/cxllib.h +3 -3
@@ -7,8 +7,8 @@* 2 of the License, or (at your option) any later version. */ -#ifndef _MISC_CXLLIB_H -#define _MISC_CXLLIB_H +#ifndef _LINUX_ACCEL_CXLLIB_H +#define _LINUX_ACCEL_CXLLIB_H#include <linux/pci.h> #include <asm/reg.h>
@@ -130,4 +130,4 @@ int cxllib_get_PE_attributes(struct task_struct *task,int cxllib_handle_fault (struct mm_struct *mm,u64 addr,u64 size,u64 flags); -#endif /* _MISC_CXLLIB_H */ +#endif /* _LINUX_ACCEL_CXLLIB_H */
Signature · 1 line
2.11.0
PATCH 4/5 ocxl: Move to drivers/accel
In reply to Olof JohanssonMove include files in separate commit, so leave them alone for now.
---
MAINTAINERS | 2 +-
drivers/accel/Kconfig | 1 +
drivers/accel/Makefile | 1 +
drivers/{misc => accel}/ocxl/Kconfig | 0
drivers/{misc => accel}/ocxl/Makefile | 0
drivers/{misc => accel}/ocxl/afu_irq.c | 0
drivers/{misc => accel}/ocxl/config.c | 0
drivers/{misc => accel}/ocxl/context.c | 0
drivers/{misc => accel}/ocxl/file.c | 0
drivers/{misc => accel}/ocxl/link.c | 0
drivers/{misc => accel}/ocxl/main.c | 0
drivers/{misc => accel}/ocxl/ocxl_internal.h | 0
drivers/{misc => accel}/ocxl/pasid.c | 0
drivers/{misc => accel}/ocxl/pci.c | 0
drivers/{misc => accel}/ocxl/sysfs.c | 0
drivers/{misc => accel}/ocxl/trace.c | 0
drivers/{misc => accel}/ocxl/trace.h | 0
drivers/misc/Kconfig | 1 -
drivers/misc/Makefile | 1 -
19 files changed, 3 insertions(+), 3 deletions(-)
rename drivers/{misc => accel}/ocxl/Kconfig (100%)
rename drivers/{misc => accel}/ocxl/Makefile (100%)
rename drivers/{misc => accel}/ocxl/afu_irq.c (100%)
rename drivers/{misc => accel}/ocxl/config.c (100%)
rename drivers/{misc => accel}/ocxl/context.c (100%)
rename drivers/{misc => accel}/ocxl/file.c (100%)
rename drivers/{misc => accel}/ocxl/link.c (100%)
rename drivers/{misc => accel}/ocxl/main.c (100%)
rename drivers/{misc => accel}/ocxl/ocxl_internal.h (100%)
rename drivers/{misc => accel}/ocxl/pasid.c (100%)
rename drivers/{misc => accel}/ocxl/pci.c (100%)
rename drivers/{misc => accel}/ocxl/sysfs.c (100%)
rename drivers/{misc => accel}/ocxl/trace.c (100%)
rename drivers/{misc => accel}/ocxl/trace.h (100%)MAINTAINERS +1 -1
@@ -11012,7 +11012,7 @@ L: [email protected] S: Supported F: arch/powerpc/platforms/powernv/ocxl.c F: arch/powerpc/include/asm/pnv-ocxl.h -F: drivers/misc/ocxl/ +F: drivers/accel/ocxl/ F: include/misc/ocxl* F: include/uapi/misc/ocxl.h F: Documentation/accelerators/ocxl.rst
drivers/accel/Kconfig +1 -0
@@ -14,5 +14,6 @@ if ACCEL comment "HW Accellerator drivers" source "drivers/accel/cxl/Kconfig" +source "drivers/accel/ocxl/Kconfig" endif
drivers/accel/Makefile +1 -0
@@ -4,3 +4,4 @@ # obj-$(CONFIG_CXL_BASE) += cxl/ +obj-$(CONFIG_OCXL) += ocxl/
drivers/accel/ocxl/Kconfig renamed from drivers/misc/ocxl/Kconfig +0 -0
drivers/accel/ocxl/Makefile renamed from drivers/misc/ocxl/Makefile +0 -0
drivers/accel/ocxl/afu_irq.c renamed from drivers/misc/ocxl/afu_irq.c +0 -0
drivers/accel/ocxl/config.c renamed from drivers/misc/ocxl/config.c +0 -0
drivers/accel/ocxl/context.c renamed from drivers/misc/ocxl/context.c +0 -0
drivers/accel/ocxl/file.c renamed from drivers/misc/ocxl/file.c +0 -0
drivers/accel/ocxl/link.c renamed from drivers/misc/ocxl/link.c +0 -0
drivers/accel/ocxl/main.c renamed from drivers/misc/ocxl/main.c +0 -0
drivers/accel/ocxl/ocxl_internal.h renamed from drivers/misc/ocxl/ocxl_internal.h +0 -0
drivers/accel/ocxl/pasid.c renamed from drivers/misc/ocxl/pasid.c +0 -0
drivers/accel/ocxl/pci.c renamed from drivers/misc/ocxl/pci.c +0 -0
drivers/accel/ocxl/sysfs.c renamed from drivers/misc/ocxl/sysfs.c +0 -0
drivers/accel/ocxl/trace.c renamed from drivers/misc/ocxl/trace.c +0 -0
drivers/accel/ocxl/trace.h renamed from drivers/misc/ocxl/trace.h +0 -0
drivers/misc/Kconfig +0 -1
@@ -532,6 +532,5 @@ source "drivers/misc/vmw_vmci/Kconfig" source "drivers/misc/mic/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" -source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" endmenu
drivers/misc/Makefile +0 -1
@@ -55,6 +55,5 @@ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o obj-$(CONFIG_ASPEED_LPC_SNOOP) += aspeed-lpc-snoop.o obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o -obj-$(CONFIG_OCXL) += ocxl/ obj-y += cardreader/ obj-$(CONFIG_PVPANIC) += pvpanic.o
Signature · 1 line
2.11.0
PATCH 5/5 drivers/accel: ocxl: Move non-uapi include files
In reply to Olof JohanssonSeparate to expose the edits vs pure moves.
---
MAINTAINERS | 2 +-
arch/powerpc/platforms/powernv/ocxl.c | 2 +-
drivers/accel/ocxl/config.c | 4 ++--
drivers/accel/ocxl/link.c | 2 +-
drivers/accel/ocxl/ocxl_internal.h | 2 +-
drivers/scsi/cxlflash/ocxl_hw.c | 2 +-
include/{misc => linux/accel}/ocxl-config.h | 6 +++---
include/{misc => linux/accel}/ocxl.h | 6 +++---
8 files changed, 13 insertions(+), 13 deletions(-)
rename include/{misc => linux/accel}/ocxl-config.h (94%)
rename include/{misc => linux/accel}/ocxl.h (98%)MAINTAINERS +1 -1
@@ -11013,7 +11013,7 @@ S: Supported F: arch/powerpc/platforms/powernv/ocxl.c F: arch/powerpc/include/asm/pnv-ocxl.h F: drivers/accel/ocxl/ -F: include/misc/ocxl* +F: include/linux/accel/ocxl* F: include/uapi/misc/ocxl.h F: Documentation/accelerators/ocxl.rst
arch/powerpc/platforms/powernv/ocxl.c +1 -1
@@ -3,7 +3,7 @@#include <asm/pnv-ocxl.h> #include <asm/opal.h> #include <asm/xive.h> -#include <misc/ocxl-config.h> +#include <linux/accel/ocxl-config.h> #include "pci.h" #define PNV_OCXL_TL_P9_RECV_CAP 0x000000000000000Full
drivers/accel/ocxl/config.c +2 -2
@@ -2,8 +2,8 @@// Copyright 2017 IBM Corp. #include <linux/pci.h> #include <asm/pnv-ocxl.h> -#include <misc/ocxl.h> -#include <misc/ocxl-config.h> +#include <linux/accel/ocxl.h> +#include <linux/accel/ocxl-config.h> #define EXTRACT_BIT (val, bit) (!!(val & BIT(bit)))#define EXTRACT_BITS (val, s, e) ((val & GENMASK(e, s)) >> s)
drivers/accel/ocxl/link.c +1 -1
@@ -6,7 +6,7 @@#include <linux/mmu_context.h> #include <asm/copro.h> #include <asm/pnv-ocxl.h> -#include <misc/ocxl.h> +#include <linux/accel/ocxl.h> #include "ocxl_internal.h" #include "trace.h"
drivers/accel/ocxl/ocxl_internal.h +1 -1
@@ -6,7 +6,7 @@#include <linux/pci.h> #include <linux/cdev.h> #include <linux/list.h> -#include <misc/ocxl.h> +#include <linux/accel/ocxl.h> #define MAX_IRQ_PER_LINK 2000#define MAX_IRQ_PER_CONTEXT MAX_IRQ_PER_LINK
drivers/scsi/cxlflash/ocxl_hw.c +1 -1
@@ -19,7 +19,7 @@#include <linux/poll.h> #include <linux/sched/signal.h> -#include <misc/ocxl.h> +#include <linux/accel/ocxl.h> #include <uapi/misc/cxl.h>
include/linux/accel/ocxl-config.h renamed from include/misc/ocxl-config.h +3 -3
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ // Copyright 2017 IBM Corp. -#ifndef _OCXL_CONFIG_H_ -#define _OCXL_CONFIG_H_ +#ifndef _LINUX_ACCEL_OCXL_CONFIG_H_ +#define _LINUX_ACCEL_OCXL_CONFIG_H_/* * This file lists the various constants used to read the
@@ -42,4 +42,4 @@#define OCXL_DVSEC_VENDOR_TLX_VERS 0x10#define OCXL_DVSEC_VENDOR_DLX_VERS 0x20 -#endif /* _OCXL_CONFIG_H_ */ +#endif /* _LINUX_ACCEL_OCXL_CONFIG_H_ */
include/linux/accel/ocxl.h renamed from include/misc/ocxl.h +3 -3
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ // Copyright 2017 IBM Corp. -#ifndef _MISC_OCXL_H_ -#define _MISC_OCXL_H_ +#ifndef _LINUX_ACCEL_OCXL_H_ +#define _LINUX_ACCEL_OCXL_H_#include <linux/pci.h>
@@ -220,4 +220,4 @@ extern int ocxl_link_irq_alloc(void *link_handle, int *hw_irq,*/ extern void ocxl_link_free_irq (void *link_handle,int hw_irq); -#endif /* _MISC_OCXL_H_ */ +#endif /* _LINUX_ACCEL_OCXL_H_ */
Signature · 1 line
2.11.0
Greg Kroah-Hartman
maintainerRe: [PATCH 5/5] drivers/accel: ocxl: Move non-uapi include files
Quoted 1 line · Olof Johansson
Separate to expose the edits vs pure moves.
Ugh, putting the uapi files in misc/ was a mistake, sorry I never caught that before, my fault :(
greg k-h
Arnd Bergmann
maintainerRe: [PATCH/RFC 0/5] HW accel subsystem
In reply to Olof JohanssonQuoted 6 lines · Olof Johansson
Per discussion in on the Habana Labs driver submission
(https://lore.kernel.org/lkml/[email protected]/),
there seems to be time to create a separate subsystem for hw accellerators instead of letting them proliferate around the tree (and/or in misc).
Quoted 6 lines
There's difference in opinion on how stringent the requirements are for a fully open stack for these kind of drivers. I've documented the middle road approach in the first patch (requiring some sort of open low-level userspace for the kernel interaction, and a way to use/test it).
Comments and suggestions for better approaches are definitely welcome.
We probably want to move drivers/misc/mic together with the others as well. We could even move arch/powerpc/platforms/cell/spu*/ for another historic example.
Arnd
Re: [PATCH/RFC 0/5] HW accel subsystem
In reply to Olof JohanssonQuoted 16 lines · Olof Johansson
Date: Fri, 25 Jan 2019 10:16:11 -0800
From: Olof Johansson <[email protected]>
To: [email protected]
CC: [email protected], Greg Kroah-Hartman <[email protected]>,
[email protected], Andrew Donnellan <[email protected]>, Frederic Barrat <[email protected]>, [email protected], [email protected]
Subject: [PATCH/RFC 0/5] HW accel subsystem
X-Mailer: git-send-email 2.11.0
Message-ID: <[email protected]>Per discussion in on the Habana Labs driver submission
(https://lore.kernel.org/lkml/[email protected]/),
there seems to be time to create a separate subsystem for hw accellerators instead of letting them proliferate around the tree (and/or in misc).
Quoted 6 lines
There's difference in opinion on how stringent the requirements are for a fully open stack for these kind of drivers. I've documented the middle road approach in the first patch (requiring some sort of open low-level userspace for the kernel interaction, and a way to use/test it).
Comments and suggestions for better approaches are definitely welcome.
Dear Olof,
How are you? Let me introduce myself. My name is Kenenth Lee, working for Hisilicon. Our company provide server, AI, networking and terminal SoCs to the market. We tried to create an accelerator framework a year back and now we are working on the branch here (There is document in Documentation/warpdrive directory):
https://github.com/Kenneth-Lee/linux-kernel-warpdrive/tree/wdprd-v1
The user space framework is here:
https://github.com/Kenneth-Lee/warpdrive/tree/wdprd-v1
We have tried to create it on VFIO at the very beginning. The RFCv1 is here:
https://lwn.net/Articles/763990/
But it seems it is not fit. There are two major issues:
1. The VFIO framework enforces the concept of separating the resource into devices before using it. This is not an accelerator style. Accelerator is another CPU to let the others to share it.
2. The way VFIO used to pin memory in place, has some flaw. In the current kernel, if you fork a sub-rpcess after pin the dma memory, you may lost the physical pages. (You can get more detail in the threads)
So we tried RFCv2 and build the solution directly on IOMMU. We call our solution as WarpDrive and the kernel module is called uacce. Our assumption is that:
1. Most of users of the accelerator are in user space.
2. An accelerator is always another heterogeneous processor. It is waiting and processing work load sent from CPU.
3. The data structure in the CPU may be complex. It is no good to wrap the data and send it to hardware again and again. The better way is to keep the data in place and give a pointer to the accelerator, leaving it to finish the job.
So we create a pipe (we called it queue) between the user process and the hardware directly. It is presented as a file to the user space. The user process mmap the queue file to address the mmio space of the hardware, share memory and so on. With the capability of IOMMU, we can share the whole or part of process space with the hardware. This can make the software solution easier.
After the RFCv2 was sent to the lkml, we do not get much feedback. But the Infini-band guys said they did not like it. They think the solution is re-invention of ib-verbs.
But we do not think so. ib-verbs maintains semantics of "REMOTE memory". But UACCE maintains semantics of "LOCAL memory". We don't need to send, or sync memory with other parties. We share those memory with all processes who share the local bus.
But we know we need more "complete" solution to let people understand and accept our idea. So now we are working on it with our Compression and RSA accelerator on Hi1620 Server SoC. We are also planning to port our AI framework on it.
Do you think we can cooperate to create an framework in Linux together? Please feel free to ask for more information. We are happy to answer it.
Cheers
Signature · 1 line
-Kenneth(Hisilicon)
Greg Kroah-Hartman
maintainerRe: [PATCH/RFC 0/5] HW accel subsystem
Quoted 3 lines · Kenneth Lee
After the RFCv2 was sent to the lkml, we do not get much feedback. But the Infini-band guys said they did not like it. They think the solution is re-invention of ib-verbs.
No one needs to re-invent a monstrosity that is ib-verbs. If anything, that is a model that should never be recreated again, showing that we can learn from past mistakes :)
Quoted 4 lines
But we do not think so. ib-verbs maintains semantics of "REMOTE memory". But UACCE maintains semantics of "LOCAL memory". We don't need to send, or sync memory with other parties. We share those memory with all processes who share the local bus.
I agree, don't try to duplicate the mess that people moved away from (hint, everyone sane wraps ib-verbs in another model that can actually be used and understood...)
Quoted 6 lines
But we know we need more "complete" solution to let people understand and accept our idea. So now we are working on it with our Compression and RSA accelerator on Hi1620 Server SoC. We are also planning to port our AI framework on it.
Do you think we can cooperate to create an framework in Linux together? Please feel free to ask for more information. We are happy to answer it.
Sure, that sounds like a great goal!
thanks,
greg k-h
Re: [PATCH/RFC 0/5] HW accel subsystem
Quoted 16 lines · Greg Kroah-Hartman
Quoted 3 lines · Kenneth Lee
After the RFCv2 was sent to the lkml, we do not get much feedback. But the Infini-band guys said they did not like it. They think the solution is re-invention of ib-verbs.
No one needs to re-invent a monstrosity that is ib-verbs. If anything, that is a model that should never be recreated again, showing that we can learn from past mistakes :)
Quoted 4 lines
But we do not think so. ib-verbs maintains semantics of "REMOTE memory". But UACCE maintains semantics of "LOCAL memory". We don't need to send, or sync memory with other parties. We share those memory with all processes who share the local bus.
I agree, don't try to duplicate the mess that people moved away from (hint, everyone sane wraps ib-verbs in another model that can actually be used and understood...)
Quoted 7 lines
Quoted 6 lines
But we know we need more "complete" solution to let people understand and accept our idea. So now we are working on it with our Compression and RSA accelerator on Hi1620 Server SoC. We are also planning to port our AI framework on it.
Do you think we can cooperate to create an framework in Linux together? Please feel free to ask for more information. We are happy to answer it.
Sure, that sounds like a great goal!
Thank you very much for your encouragement:)
Kenneth Lee
Quoted 5 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 30 lines · Olof Johansson
Quoted 21 lines · Greg Kroah-Hartman
Quoted 15 lines · Olof Johansson
On Thu, Jan 24, 2019 at 11:37 PM Greg Kroah-Hartman
Quoted 5 lines
As for what directory the code should live in, I suggested "misc" as there was no other universal location, and I hate to see new subsystems be created with only one driver, as that's pretty sad. But it's just a name/location, I have no dog in the fight, so I really don't care where it ends up in the tree, just as long as it gets merged somewhere :)
I'm usually one to push back against new subsystems too, especially when I see a framework proposal with just one driver. In this case, given that we all know more vendors will come along, I think it makes sense to take the discussion and establish structure now. This should give some clarity to those who are out there that we haven't seen yet, and give them a chance to prepare for things such as the low-level userspace pieces mentioned above.
Quoted 3 lines
So I think setting this up now is the right thing to do, we know there will be more material here and having a common aggregation of it makes sense.
Quoted 6 lines
Ok, how about:
drivers/deep_thought/as a first proposal.
Let the bikeshedding begin! :)
Quoted 7 lines
My original proposal upthread was driver/accel. I'm not sure whether Dave and/or anyone else wants to participate to start though, I hope they will at least join in once things are heading in the direction they want.
I'll post patches with the proposed moves and documentation of expectations shortly, hopefully to collect acks.
Patches all look good to me, I can merge them through my char-misc tree once we get the acks from the relevant driver maintainers.
thanks,
greg k-h