/* * Copyright 2008 Jerome Glisse. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Jerome Glisse <[email protected]> */ #include <linux/list_sort.h> #include <linux/pci.h> #include <linux/uaccess.h> #include <drm/drm_device.h> #include <drm/drm_file.h> #include <drm/radeon_drm.h> #include "radeon.h" #include "radeon_reg.h" #include "radeon_trace.h" #define RADEON_CS_MAX_PRIORITY … #define RADEON_CS_NUM_BUCKETS … /* This is based on the bucket sort with O(n) time complexity. * An item with priority "i" is added to bucket[i]. The lists are then * concatenated in descending order. */ struct radeon_cs_buckets { … }; static void radeon_cs_buckets_init(struct radeon_cs_buckets *b) { … } static void radeon_cs_buckets_add(struct radeon_cs_buckets *b, struct list_head *item, unsigned priority) { … } static void radeon_cs_buckets_get_list(struct radeon_cs_buckets *b, struct list_head *out_list) { … } static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) { … } static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority) { … } static int radeon_cs_sync_rings(struct radeon_cs_parser *p) { … } /* XXX: note that this is called from the legacy UMS CS ioctl as well */ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) { … } static int cmp_size_smaller_first(void *priv, const struct list_head *a, const struct list_head *b) { … } /** * radeon_cs_parser_fini() - clean parser states * @parser: parser structure holding parsing context. * @error: error number * @backoff: indicator to backoff the reservation * * If error is set than unvalidate buffer, otherwise just free memory * used by parsing context. **/ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bool backoff) { … } static int radeon_cs_ib_chunk(struct radeon_device *rdev, struct radeon_cs_parser *parser) { … } static int radeon_bo_vm_update_pte(struct radeon_cs_parser *p, struct radeon_vm *vm) { … } static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev, struct radeon_cs_parser *parser) { … } static int radeon_cs_handle_lockup(struct radeon_device *rdev, int r) { … } static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser *parser) { … } int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { … } /** * radeon_cs_packet_parse() - parse cp packet and point ib index to next packet * @p: parser structure holding parsing context. * @pkt: where to store packet information * @idx: packet index * * Assume that chunk_ib_index is properly set. Will return -EINVAL * if packet is bigger than remaining ib size. or if packets is unknown. **/ int radeon_cs_packet_parse(struct radeon_cs_parser *p, struct radeon_cs_packet *pkt, unsigned idx) { … } /** * radeon_cs_packet_next_is_pkt3_nop() - test if the next packet is P3 NOP * @p: structure holding the parser context. * * Check if the next packet is NOP relocation packet3. **/ bool radeon_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser *p) { … } /** * radeon_cs_dump_packet() - dump raw packet context * @p: structure holding the parser context. * @pkt: structure holding the packet. * * Used mostly for debugging and error reporting. **/ void radeon_cs_dump_packet(struct radeon_cs_parser *p, struct radeon_cs_packet *pkt) { … } /** * radeon_cs_packet_next_reloc() - parse next (should be reloc) packet * @p: parser structure holding parsing context. * @cs_reloc: reloc informations * @nomm: no memory management for debugging * * Check if next packet is relocation packet3, do bo validation and compute * GPU offset using the provided start. **/ int radeon_cs_packet_next_reloc(struct radeon_cs_parser *p, struct radeon_bo_list **cs_reloc, int nomm) { … }