/* * Copyright 2017 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Authors: Jérôme Glisse */ #ifndef COMPOTE_H #define COMPOTE_H #include typedef struct { uint64_t id; } compote_channel_t; typedef struct { int fd; compote_channel_t channel; } compote_context_t; typedef struct { uint64_t foffset; uint64_t nbytes; void *ptr; } compote_mo_t; int compote_context_new(compote_context_t **ctxp); void compote_context_del(compote_context_t **ctxp); int compote_context_ioctl(compote_context_t *ctx, int command, void *arg); int compote_context_execute(compote_context_t *ctx, void *addr, unsigned ndw); int compote_mo_new(compote_context_t *ctx, compote_mo_t **mop, uint64_t nbytes); void compote_mo_del(compote_context_t *ctx, compote_mo_t **mop); static inline uint64_t compote_mo_gpu_addr(compote_mo_t *mo) { if (mo == NULL || mo->ptr == NULL) { return -1UL; } return (unsigned long)mo->ptr; } void *malloc_below40(unsigned nbytes); static inline uint32_t nvk_sq_cmd(unsigned subc, unsigned method, unsigned len) { return ((method >> 2) & 0x1fff) | ((len & 0xfff) << 16) | ((subc & 0x7) << 13) | (0x1 << 29); } static inline uint32_t nvk_ni_cmd(unsigned subc, unsigned method, unsigned len) { return ((method >> 2) & 0x1fff) | ((len & 0xfff) << 16) | ((subc & 0x7) << 13) | (0x3 << 29); } static inline uint32_t nvk_addr_high(uint64_t offset) { return (offset >> 32) & 0xffffffff; } static inline uint32_t nvk_addr_low(uint64_t offset) { return offset & 0xffffffff; } static inline uint32_t nvk_size_high(uint64_t offset) { return (offset >> 32) & 0xffffffff; } static inline uint32_t nvk_size_low(uint64_t offset) { return offset & 0xffffffff; } int test_compute(compote_context_t *ctx, void *buffer, void *dstp, unsigned dimx); #endif // COMPOTE_H