
* refs/heads/tmp-ba15277: Linux 5.10.11 Revert "mm: fix initialization of struct page for holes in memory layout" mm: fix initialization of struct page for holes in memory layout Commit 9bb48c82aced ("tty: implement write_iter") converted the tty layer to use write_iter. Fix the redirected_tty_write declaration also in n_tty and change the comparisons to use write_iter instead of write. also in n_tty and change the comparisons to use write_iter instead of write. fs/pipe: allow sendfile() to pipe again interconnect: imx8mq: Use icc_sync_state kernfs: wire up ->splice_read and ->splice_write kernfs: implement ->write_iter kernfs: implement ->read_iter bpf: Local storage helpers should check nullness of owner ptr passed drm/i915/hdcp: Get conn while content_type changed ASoC: SOF: Intel: hda: Avoid checking jack on system suspend tcp: Fix potential use-after-free due to double kfree() x86/sev-es: Handle string port IO to kernel memory properly net: systemport: free dev before on error path tty: fix up hung_up_tty_write() conversion tty: implement write_iter x86/sev: Fix nonistr violation pinctrl: qcom: Don't clear pending interrupts when enabling pinctrl: qcom: Properly clear "intr_ack_high" interrupts when unmasking pinctrl: qcom: No need to read-modify-write the interrupt status pinctrl: qcom: Allow SoCs to specify a GPIO function that's not 0 net: core: devlink: use right genl user_ptr when handling port param get/set net: mscc: ocelot: Fix multicast to the CPU port tcp: fix TCP_USER_TIMEOUT with zero window tcp: do not mess with cloned skbs in tcp_add_backlog() net: dsa: b53: fix an off by one in checking "vlan->vid" net: Disable NETIF_F_HW_TLS_RX when RXCSUM is disabled net: mscc: ocelot: allow offloading of bridge on top of LAG ipv6: set multicast flag on the multicast route net_sched: reject silly cell_log in qdisc_get_rtab() net_sched: avoid shift-out-of-bounds in tcindex_set_parms() ipv6: create multicast route with RTPROT_KERNEL udp: mask TOS bits in udp_v4_early_demux() net_sched: gen_estimator: support large ewma log tcp: fix TCP socket rehash stats mis-accounting kasan: fix incorrect arguments passing in kasan_add_zero_shadow kasan: fix unaligned address is unhandled in kasan_remove_zero_shadow skbuff: back tiny skbs with kmalloc() in __netdev_alloc_skb() too lightnvm: fix memory leak when submit fails cachefiles: Drop superfluous readpages aops NULL check nvme-pci: fix error unwind in nvme_map_data nvme-pci: refactor nvme_unmap_data sh_eth: Fix power down vs. is_opened flag ordering selftests/powerpc: Fix exit status of pkey tests net: dsa: mv88e6xxx: also read STU state in mv88e6250_g1_vtu_getnext octeontx2-af: Fix missing check bugs in rvu_cgx.c ASoC: SOF: Intel: fix page fault at probe if i915 init fails locking/lockdep: Cure noinstr fail sh: Remove unused HAVE_COPY_THREAD_TLS macro sh: dma: fix kconfig dependency for G2_DMA drm/i915/hdcp: Update CP property in update_pipe tools: gpio: fix %llu warning in gpio-watch.c tools: gpio: fix %llu warning in gpio-event-mon.c netfilter: rpfilter: mask ecn bits before fib lookup cls_flower: call nla_ok() before nla_next() x86/cpu/amd: Set __max_die_per_package on AMD x86/entry: Fix noinstr fail drm/i915: Only enable DFP 4:4:4->4:2:0 conversion when outputting YCbCr 4:4:4 drm/i915: s/intel_dp_sink_dpms/intel_dp_set_power/ driver core: Extend device_is_dependent() driver core: Fix device link device name collision drivers core: Free dma_range_map when driver probe failed xhci: tegra: Delay for disabling LFPS detector xhci: make sure TRB is fully written before giving it to the controller usb: cdns3: imx: fix can't create core device the second time issue usb: cdns3: imx: fix writing read-only memory issue usb: bdc: Make bdc pci driver depend on BROKEN usb: udc: core: Use lock when write to soft_connect USB: gadget: dummy-hcd: Fix errors in port-reset handling usb: gadget: aspeed: fix stop dma register setting. USB: ehci: fix an interrupt calltrace error ehci: fix EHCI host controller initialization sequence serial: mvebu-uart: fix tx lost characters at power off stm class: Fix module init return on allocation failure intel_th: pci: Add Alder Lake-P support io_uring: fix short read retries for non-reg files io_uring: fix SQPOLL IORING_OP_CLOSE cancelation state io_uring: iopoll requests should also wake task ->in_idle state mm: fix numa stats for thp migration mm: memcg: fix memcg file_dirty numa stat mm: memcg/slab: optimize objcg stock draining proc_sysctl: fix oops caused by incorrect command parameters x86/setup: don't remove E820_TYPE_RAM for pfn 0 x86/mmx: Use KFPU_387 for MMX string operations x86/topology: Make __max_die_per_package available unconditionally x86/fpu: Add kernel_fpu_begin_mask() to selectively initialize state irqchip/mips-cpu: Set IPI domain parent chip cifs: do not fail __smb_send_rqst if non-fatal signals are pending powerpc/64s: fix scv entry fallback flush vs interrupt counter:ti-eqep: remove floor iio: adc: ti_am335x_adc: remove omitted iio_kfifo_free() drivers: iio: temperature: Add delay after the addressed reset command in mlx90632.c iio: ad5504: Fix setting power-down state iio: common: st_sensors: fix possible infinite loop in st_sensors_irq_thread i2c: sprd: depend on COMMON_CLK to fix compile tests perf evlist: Fix id index for heterogeneous systems can: peak_usb: fix use after free bugs can: vxcan: vxcan_xmit: fix use after free bug can: dev: can_restart: fix use after free bug selftests: net: fib_tests: remove duplicate log test xsk: Clear pool even for inactive queues ALSA: hda: Balance runtime/system PM if direct-complete is disabled gpio: sifive: select IRQ_DOMAIN_HIERARCHY rather than depend on it platform/x86: hp-wmi: Don't log a warning on HPWMI_RET_UNKNOWN_COMMAND errors platform/x86: intel-vbtn: Drop HP Stream x360 Convertible PC 11 from allow-list drm/vc4: Unify PCM card's driver_name i2c: octeon: check correct size of maximum RECV_LEN packet iov_iter: fix the uaccess area in copy_compat_iovec_from_user printk: fix kmsg_dump_get_buffer length calulations printk: ringbuffer: fix line counting RDMA/cma: Fix error flow in default_roce_mode_store RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two() drm/amdkfd: Fix out-of-bounds read in kdf_create_vcrat_image_cpu() bpf: Reject too big ctx_size_in for raw_tp test run arm64: entry: remove redundant IRQ flag tracing powerpc: Fix alignment bug within the init sections powerpc: Use the common INIT_DATA_SECTION macro in vmlinux.lds.S bpf: Prevent double bpf_prog_put call from bpf_tracing_prog_attach crypto: omap-sham - Fix link error without crypto-engine scsi: ufs: Fix tm request when non-fatal error happens scsi: ufs: ufshcd-pltfrm depends on HAS_IOMEM scsi: megaraid_sas: Fix MEGASAS_IOC_FIRMWARE regression btrfs: print the actual offset in btrfs_root_name RDMA/ucma: Do not miss ctx destruction steps in some cases pinctrl: mediatek: Fix fallback call path pinctrl: aspeed: g6: Fix PWMG0 pinctrl setting gpiolib: cdev: fix frame size warning in gpio_ioctl() nfsd: Don't set eof on a truncated READ_PLUS nfsd: Fixes for nfsd4_encode_read_plus_data() x86/xen: fix 'nopvspin' build error RISC-V: Fix maximum allowed phsyical memory for RV32 RISC-V: Set current memblock limit libperf tests: Fail when failing to get a tracepoint id libperf tests: If a test fails return non-zero io_uring: flush timeouts that should already have expired drm/nouveau/kms/nv50-: fix case where notifier buffer is at offset 0 drm/nouveau/mmu: fix vram heap sizing drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields drm/nouveau/privring: ack interrupts the same way as RM drm/nouveau/bios: fix issue shadowing expansion ROMs drm/amd/display: Fix to be able to stop crc calculation HID: logitech-hidpp: Add product ID for MX Ergo in Bluetooth mode drm/amd/display: disable dcn10 pipe split by default drm/amdgpu/psp: fix psp gfx ctrl cmds riscv: defconfig: enable gpio support for HiFive Unleashed dts: phy: add GPIO number and active state used for phy reset dts: phy: fix missing mdio device and probe failure of vsc8541-01 device x86/xen: Fix xen_hvm_smp_init() when vector callback not available x86/xen: Add xen_no_vector_callback option to test PCI INTX delivery xen: Fix event channel callback via INTX/GSI arm64: make atomic helpers __always_inline riscv: cacheinfo: Fix using smp_processor_id() in preemptible ALSA: hda/tegra: fix tegra-hda on tegra30 soc clk: tegra30: Add hda clock default rates to clock driver HID: Ignore battery for Elan touchscreen on ASUS UX550 HID: logitech-dj: add the G602 receiver riscv: Enable interrupts during syscalls with M-Mode riscv: Fix sifive serial driver riscv: Fix kernel time_init() scsi: sd: Suppress spurious errors when WRITE SAME is being disabled scsi: scsi_debug: Fix memleak in scsi_debug_init() scsi: qedi: Correct max length of CHAP secret scsi: ufs: Correct the LUN used in eh_device_reset_handler() callback scsi: ufs: Relax the condition of UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL x86/hyperv: Fix kexec panic/hang issues dm integrity: select CRYPTO_SKCIPHER HID: sony: select CONFIG_CRC32 HID: multitouch: Enable multi-input for Synaptics pointstick/touchpad device SUNRPC: Handle TCP socket sends with kernel_sendpage() again ASoC: rt711: mutex between calibration and power state changes ASoC: Intel: haswell: Add missing pm_ops drm/i915: Check for rq->hwsp validity after acquiring RCU lock drm/i915/gt: Prevent use of engine->wa_ctx after error drm/amd/display: DCN2X Find Secondary Pipe properly in MPO + ODM Case drm/amdgpu: remove gpu info firmware of green sardine drm/syncobj: Fix use-after-free drm/atomic: put state on error path dm integrity: conditionally disable "recalculate" feature dm integrity: fix a crash if "recalculate" used without "internal_hash" dm: avoid filesystem lookup in dm_get_dev_t() mmc: sdhci-brcmstb: Fix mmc timeout errors on S5 suspend mmc: sdhci-xenon: fix 1.8v regulator stabilization mmc: sdhci-of-dwcmshc: fix rpmb access mmc: core: don't initialize block size from ext_csd if not present pinctrl: ingenic: Fix JZ4760 support fs: fix lazytime expiration handling in __writeback_single_inode() btrfs: send: fix invalid clone operations when cloning from the same file and root btrfs: don't clear ret in btrfs_start_dirty_block_groups btrfs: fix lockdep splat in btrfs_recover_relocation btrfs: do not double free backref nodes on error btrfs: don't get an EINTR during drop_snapshot for reloc ACPI: scan: Make acpi_bus_get_device() clear return pointer on error dm crypt: fix copy and paste bug in crypt_alloc_req_aead crypto: xor - Fix divide error in do_xor_speed() ALSA: hda/via: Add minimum mute flag ALSA: hda/realtek - Limit int mic boost on Acer Aspire E5-575T ALSA: seq: oss: Fix missing error check in snd_seq_oss_synth_make_info() platform/x86: ideapad-laptop: Disable touchpad_switch for ELAN0634 platform/x86: i2c-multi-instantiate: Don't create platform device for INT3515 ACPI nodes i2c: bpmp-tegra: Ignore unknown I2C_M flags i2c: tegra: Wait for config load atomically while in ISR mtd: rawnand: nandsim: Fix the logic when selecting Hamming soft ECC engine mtd: rawnand: gpmi: fix dst bit offset when extracting raw payload scsi: target: tcmu: Fix use-after-free of se_cmd->priv ANDROID: simplify vendor hook definitions ANDROID: add macros to create OEM data fields ANDROID: dma-buf: fix return type mismatch ANDROID: cpu/hotplug: create vendor hook for cpu_up/cpu_down FROMLIST: fuse: Introduce passthrough for mmap ANDROID: Fix sparse warning in wp_page_copy caused by SPF patchset FROMLIST: fuse: Use daemon creds in passthrough mode FROMLIST: fuse: Handle asynchronous read and write in passthrough FROMLIST: fuse: Introduce synchronous read and write for passthrough FROMLIST: fuse: Passthrough initialization and release FROMLIST: fuse: Definitions and ioctl for passthrough FROMLIST: fuse: 32-bit user space ioctl compat for fuse device FROMLIST: fs: Generic function to convert iocb to rw flags Revert "FROMLIST: fuse: Definitions and ioctl() for passthrough" Revert "FROMLIST: fuse: Passthrough initialization and release" Revert "FROMLIST: fuse: Introduce synchronous read and write for passthrough" Revert "FROMLIST: fuse: Handle asynchronous read and write in passthrough" Revert "FROMLIST: fuse: Use daemon creds in passthrough mode" Revert "FROMLIST: fuse: Fix colliding FUSE_PASSTHROUGH flag" UPSTREAM: usb: xhci-mtk: fix unreleased bandwidth data ANDROID: sched: export task_rq_lock ANDROID: GKI: make VIDEOBUF2_DMA_CONTIG under GKI_HIDDEN_MEDIA_CONFIGS ANDROID: clang: update to 12.0.1 FROMLIST: dma-buf: heaps: add chunk heap to dmabuf heaps FROMLIST: dt-bindings: reserved-memory: Make DMA-BUF CMA heap DT-configurable FROMLIST: mm: failfast mode with __GFP_NORETRY in alloc_contig_range FROMLIST: mm: cma: introduce gfp flag in cma_alloc instead of no_warn UPSTREAM: kernfs: wire up ->splice_read and ->splice_write UPSTREAM: kernfs: implement ->write_iter UPSTREAM: kernfs: implement ->read_iter UPSTREAM: usb: typec: tcpm: Create legacy PDOs for PD2 connection Conflicts: Documentation/devicetree/bindings drivers/dma-buf/heaps/Kconfig drivers/dma-buf/heaps/Makefile drivers/pinctrl/qcom/pinctrl-msm.h Change-Id: I6412ddc7b1d215b7ea8bff5815277e13e8143888 Signed-off-by: Ivaylo Georgiev <irgeorgiev@codeaurora.org>
613 lines
19 KiB
C
613 lines
19 KiB
C
/*
|
|
* Copyright © 2008-2018 Intel Corporation
|
|
*
|
|
* 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
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS 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.
|
|
*
|
|
*/
|
|
|
|
#ifndef I915_REQUEST_H
|
|
#define I915_REQUEST_H
|
|
|
|
#include <linux/dma-fence.h>
|
|
#include <linux/irq_work.h>
|
|
#include <linux/lockdep.h>
|
|
|
|
#include "gem/i915_gem_context_types.h"
|
|
#include "gt/intel_context_types.h"
|
|
#include "gt/intel_engine_types.h"
|
|
#include "gt/intel_timeline_types.h"
|
|
|
|
#include "i915_gem.h"
|
|
#include "i915_scheduler.h"
|
|
#include "i915_selftest.h"
|
|
#include "i915_sw_fence.h"
|
|
|
|
#include <uapi/drm/i915_drm.h>
|
|
|
|
struct drm_file;
|
|
struct drm_i915_gem_object;
|
|
struct i915_request;
|
|
|
|
struct i915_capture_list {
|
|
struct i915_capture_list *next;
|
|
struct i915_vma *vma;
|
|
};
|
|
|
|
#define RQ_TRACE(rq, fmt, ...) do { \
|
|
const struct i915_request *rq__ = (rq); \
|
|
ENGINE_TRACE(rq__->engine, "fence %llx:%lld, current %d " fmt, \
|
|
rq__->fence.context, rq__->fence.seqno, \
|
|
hwsp_seqno(rq__), ##__VA_ARGS__); \
|
|
} while (0)
|
|
|
|
enum {
|
|
/*
|
|
* I915_FENCE_FLAG_ACTIVE - this request is currently submitted to HW.
|
|
*
|
|
* Set by __i915_request_submit() on handing over to HW, and cleared
|
|
* by __i915_request_unsubmit() if we preempt this request.
|
|
*
|
|
* Finally cleared for consistency on retiring the request, when
|
|
* we know the HW is no longer running this request.
|
|
*
|
|
* See i915_request_is_active()
|
|
*/
|
|
I915_FENCE_FLAG_ACTIVE = DMA_FENCE_FLAG_USER_BITS,
|
|
|
|
/*
|
|
* I915_FENCE_FLAG_PQUEUE - this request is ready for execution
|
|
*
|
|
* Using the scheduler, when a request is ready for execution it is put
|
|
* into the priority queue, and removed from that queue when transferred
|
|
* to the HW runlists. We want to track its membership within the
|
|
* priority queue so that we can easily check before rescheduling.
|
|
*
|
|
* See i915_request_in_priority_queue()
|
|
*/
|
|
I915_FENCE_FLAG_PQUEUE,
|
|
|
|
/*
|
|
* I915_FENCE_FLAG_HOLD - this request is currently on hold
|
|
*
|
|
* This request has been suspended, pending an ongoing investigation.
|
|
*/
|
|
I915_FENCE_FLAG_HOLD,
|
|
|
|
/*
|
|
* I915_FENCE_FLAG_INITIAL_BREADCRUMB - this request has the initial
|
|
* breadcrumb that marks the end of semaphore waits and start of the
|
|
* user payload.
|
|
*/
|
|
I915_FENCE_FLAG_INITIAL_BREADCRUMB,
|
|
|
|
/*
|
|
* I915_FENCE_FLAG_SIGNAL - this request is currently on signal_list
|
|
*
|
|
* Internal bookkeeping used by the breadcrumb code to track when
|
|
* a request is on the various signal_list.
|
|
*/
|
|
I915_FENCE_FLAG_SIGNAL,
|
|
|
|
/*
|
|
* I915_FENCE_FLAG_NOPREEMPT - this request should not be preempted
|
|
*
|
|
* The execution of some requests should not be interrupted. This is
|
|
* a sensitive operation as it makes the request super important,
|
|
* blocking other higher priority work. Abuse of this flag will
|
|
* lead to quality of service issues.
|
|
*/
|
|
I915_FENCE_FLAG_NOPREEMPT,
|
|
|
|
/*
|
|
* I915_FENCE_FLAG_SENTINEL - this request should be last in the queue
|
|
*
|
|
* A high priority sentinel request may be submitted to clear the
|
|
* submission queue. As it will be the only request in-flight, upon
|
|
* execution all other active requests will have been preempted and
|
|
* unsubmitted. This preemptive pulse is used to re-evaluate the
|
|
* in-flight requests, particularly in cases where an active context
|
|
* is banned and those active requests need to be cancelled.
|
|
*/
|
|
I915_FENCE_FLAG_SENTINEL,
|
|
|
|
/*
|
|
* I915_FENCE_FLAG_BOOST - upclock the gpu for this request
|
|
*
|
|
* Some requests are more important than others! In particular, a
|
|
* request that the user is waiting on is typically required for
|
|
* interactive latency, for which we want to minimise by upclocking
|
|
* the GPU. Here we track such boost requests on a per-request basis.
|
|
*/
|
|
I915_FENCE_FLAG_BOOST,
|
|
};
|
|
|
|
/**
|
|
* Request queue structure.
|
|
*
|
|
* The request queue allows us to note sequence numbers that have been emitted
|
|
* and may be associated with active buffers to be retired.
|
|
*
|
|
* By keeping this list, we can avoid having to do questionable sequence
|
|
* number comparisons on buffer last_read|write_seqno. It also allows an
|
|
* emission time to be associated with the request for tracking how far ahead
|
|
* of the GPU the submission is.
|
|
*
|
|
* When modifying this structure be very aware that we perform a lockless
|
|
* RCU lookup of it that may race against reallocation of the struct
|
|
* from the slab freelist. We intentionally do not zero the structure on
|
|
* allocation so that the lookup can use the dangling pointers (and is
|
|
* cogniscent that those pointers may be wrong). Instead, everything that
|
|
* needs to be initialised must be done so explicitly.
|
|
*
|
|
* The requests are reference counted.
|
|
*/
|
|
struct i915_request {
|
|
struct dma_fence fence;
|
|
spinlock_t lock;
|
|
|
|
/**
|
|
* Context and ring buffer related to this request
|
|
* Contexts are refcounted, so when this request is associated with a
|
|
* context, we must increment the context's refcount, to guarantee that
|
|
* it persists while any request is linked to it. Requests themselves
|
|
* are also refcounted, so the request will only be freed when the last
|
|
* reference to it is dismissed, and the code in
|
|
* i915_request_free() will then decrement the refcount on the
|
|
* context.
|
|
*/
|
|
struct intel_engine_cs *engine;
|
|
struct intel_context *context;
|
|
struct intel_ring *ring;
|
|
struct intel_timeline __rcu *timeline;
|
|
|
|
struct list_head signal_link;
|
|
struct llist_node signal_node;
|
|
|
|
/*
|
|
* The rcu epoch of when this request was allocated. Used to judiciously
|
|
* apply backpressure on future allocations to ensure that under
|
|
* mempressure there is sufficient RCU ticks for us to reclaim our
|
|
* RCU protected slabs.
|
|
*/
|
|
unsigned long rcustate;
|
|
|
|
/*
|
|
* We pin the timeline->mutex while constructing the request to
|
|
* ensure that no caller accidentally drops it during construction.
|
|
* The timeline->mutex must be held to ensure that only this caller
|
|
* can use the ring and manipulate the associated timeline during
|
|
* construction.
|
|
*/
|
|
struct pin_cookie cookie;
|
|
|
|
/*
|
|
* Fences for the various phases in the request's lifetime.
|
|
*
|
|
* The submit fence is used to await upon all of the request's
|
|
* dependencies. When it is signaled, the request is ready to run.
|
|
* It is used by the driver to then queue the request for execution.
|
|
*/
|
|
struct i915_sw_fence submit;
|
|
union {
|
|
wait_queue_entry_t submitq;
|
|
struct i915_sw_dma_fence_cb dmaq;
|
|
struct i915_request_duration_cb {
|
|
struct dma_fence_cb cb;
|
|
ktime_t emitted;
|
|
} duration;
|
|
};
|
|
struct llist_head execute_cb;
|
|
struct i915_sw_fence semaphore;
|
|
struct irq_work semaphore_work;
|
|
|
|
/*
|
|
* A list of everyone we wait upon, and everyone who waits upon us.
|
|
* Even though we will not be submitted to the hardware before the
|
|
* submit fence is signaled (it waits for all external events as well
|
|
* as our own requests), the scheduler still needs to know the
|
|
* dependency tree for the lifetime of the request (from execbuf
|
|
* to retirement), i.e. bidirectional dependency information for the
|
|
* request not tied to individual fences.
|
|
*/
|
|
struct i915_sched_node sched;
|
|
struct i915_dependency dep;
|
|
intel_engine_mask_t execution_mask;
|
|
|
|
/*
|
|
* A convenience pointer to the current breadcrumb value stored in
|
|
* the HW status page (or our timeline's local equivalent). The full
|
|
* path would be rq->hw_context->ring->timeline->hwsp_seqno.
|
|
*/
|
|
const u32 *hwsp_seqno;
|
|
|
|
/*
|
|
* If we need to access the timeline's seqno for this request in
|
|
* another request, we need to keep a read reference to this associated
|
|
* cacheline, so that we do not free and recycle it before the foreign
|
|
* observers have completed. Hence, we keep a pointer to the cacheline
|
|
* inside the timeline's HWSP vma, but it is only valid while this
|
|
* request has not completed and guarded by the timeline mutex.
|
|
*/
|
|
struct intel_timeline_cacheline __rcu *hwsp_cacheline;
|
|
|
|
/** Position in the ring of the start of the request */
|
|
u32 head;
|
|
|
|
/** Position in the ring of the start of the user packets */
|
|
u32 infix;
|
|
|
|
/**
|
|
* Position in the ring of the start of the postfix.
|
|
* This is required to calculate the maximum available ring space
|
|
* without overwriting the postfix.
|
|
*/
|
|
u32 postfix;
|
|
|
|
/** Position in the ring of the end of the whole request */
|
|
u32 tail;
|
|
|
|
/** Position in the ring of the end of any workarounds after the tail */
|
|
u32 wa_tail;
|
|
|
|
/** Preallocate space in the ring for the emitting the request */
|
|
u32 reserved_space;
|
|
|
|
/** Batch buffer related to this request if any (used for
|
|
* error state dump only).
|
|
*/
|
|
struct i915_vma *batch;
|
|
/**
|
|
* Additional buffers requested by userspace to be captured upon
|
|
* a GPU hang. The vma/obj on this list are protected by their
|
|
* active reference - all objects on this list must also be
|
|
* on the active_list (of their final request).
|
|
*/
|
|
struct i915_capture_list *capture_list;
|
|
|
|
/** Time at which this request was emitted, in jiffies. */
|
|
unsigned long emitted_jiffies;
|
|
|
|
/** timeline->request entry for this request */
|
|
struct list_head link;
|
|
|
|
I915_SELFTEST_DECLARE(struct {
|
|
struct list_head link;
|
|
unsigned long delay;
|
|
} mock;)
|
|
};
|
|
|
|
#define I915_FENCE_GFP (GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN)
|
|
|
|
extern const struct dma_fence_ops i915_fence_ops;
|
|
|
|
static inline bool dma_fence_is_i915(const struct dma_fence *fence)
|
|
{
|
|
return fence->ops == &i915_fence_ops;
|
|
}
|
|
|
|
struct kmem_cache *i915_request_slab_cache(void);
|
|
|
|
struct i915_request * __must_check
|
|
__i915_request_create(struct intel_context *ce, gfp_t gfp);
|
|
struct i915_request * __must_check
|
|
i915_request_create(struct intel_context *ce);
|
|
|
|
void i915_request_set_error_once(struct i915_request *rq, int error);
|
|
void __i915_request_skip(struct i915_request *rq);
|
|
|
|
struct i915_request *__i915_request_commit(struct i915_request *request);
|
|
void __i915_request_queue(struct i915_request *rq,
|
|
const struct i915_sched_attr *attr);
|
|
|
|
bool i915_request_retire(struct i915_request *rq);
|
|
void i915_request_retire_upto(struct i915_request *rq);
|
|
|
|
static inline struct i915_request *
|
|
to_request(struct dma_fence *fence)
|
|
{
|
|
/* We assume that NULL fence/request are interoperable */
|
|
BUILD_BUG_ON(offsetof(struct i915_request, fence) != 0);
|
|
GEM_BUG_ON(fence && !dma_fence_is_i915(fence));
|
|
return container_of(fence, struct i915_request, fence);
|
|
}
|
|
|
|
static inline struct i915_request *
|
|
i915_request_get(struct i915_request *rq)
|
|
{
|
|
return to_request(dma_fence_get(&rq->fence));
|
|
}
|
|
|
|
static inline struct i915_request *
|
|
i915_request_get_rcu(struct i915_request *rq)
|
|
{
|
|
return to_request(dma_fence_get_rcu(&rq->fence));
|
|
}
|
|
|
|
static inline void
|
|
i915_request_put(struct i915_request *rq)
|
|
{
|
|
dma_fence_put(&rq->fence);
|
|
}
|
|
|
|
int i915_request_await_object(struct i915_request *to,
|
|
struct drm_i915_gem_object *obj,
|
|
bool write);
|
|
int i915_request_await_dma_fence(struct i915_request *rq,
|
|
struct dma_fence *fence);
|
|
int i915_request_await_execution(struct i915_request *rq,
|
|
struct dma_fence *fence,
|
|
void (*hook)(struct i915_request *rq,
|
|
struct dma_fence *signal));
|
|
|
|
void i915_request_add(struct i915_request *rq);
|
|
|
|
bool __i915_request_submit(struct i915_request *request);
|
|
void i915_request_submit(struct i915_request *request);
|
|
|
|
void __i915_request_unsubmit(struct i915_request *request);
|
|
void i915_request_unsubmit(struct i915_request *request);
|
|
|
|
long i915_request_wait(struct i915_request *rq,
|
|
unsigned int flags,
|
|
long timeout)
|
|
__attribute__((nonnull(1)));
|
|
#define I915_WAIT_INTERRUPTIBLE BIT(0)
|
|
#define I915_WAIT_PRIORITY BIT(1) /* small priority bump for the request */
|
|
#define I915_WAIT_ALL BIT(2) /* used by i915_gem_object_wait() */
|
|
|
|
static inline bool i915_request_signaled(const struct i915_request *rq)
|
|
{
|
|
/* The request may live longer than its HWSP, so check flags first! */
|
|
return test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags);
|
|
}
|
|
|
|
static inline bool i915_request_is_active(const struct i915_request *rq)
|
|
{
|
|
return test_bit(I915_FENCE_FLAG_ACTIVE, &rq->fence.flags);
|
|
}
|
|
|
|
static inline bool i915_request_in_priority_queue(const struct i915_request *rq)
|
|
{
|
|
return test_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags);
|
|
}
|
|
|
|
static inline bool
|
|
i915_request_has_initial_breadcrumb(const struct i915_request *rq)
|
|
{
|
|
return test_bit(I915_FENCE_FLAG_INITIAL_BREADCRUMB, &rq->fence.flags);
|
|
}
|
|
|
|
/**
|
|
* Returns true if seq1 is later than seq2.
|
|
*/
|
|
static inline bool i915_seqno_passed(u32 seq1, u32 seq2)
|
|
{
|
|
return (s32)(seq1 - seq2) >= 0;
|
|
}
|
|
|
|
static inline u32 __hwsp_seqno(const struct i915_request *rq)
|
|
{
|
|
const u32 *hwsp = READ_ONCE(rq->hwsp_seqno);
|
|
|
|
return READ_ONCE(*hwsp);
|
|
}
|
|
|
|
/**
|
|
* hwsp_seqno - the current breadcrumb value in the HW status page
|
|
* @rq: the request, to chase the relevant HW status page
|
|
*
|
|
* The emphasis in naming here is that hwsp_seqno() is not a property of the
|
|
* request, but an indication of the current HW state (associated with this
|
|
* request). Its value will change as the GPU executes more requests.
|
|
*
|
|
* Returns the current breadcrumb value in the associated HW status page (or
|
|
* the local timeline's equivalent) for this request. The request itself
|
|
* has the associated breadcrumb value of rq->fence.seqno, when the HW
|
|
* status page has that breadcrumb or later, this request is complete.
|
|
*/
|
|
static inline u32 hwsp_seqno(const struct i915_request *rq)
|
|
{
|
|
u32 seqno;
|
|
|
|
rcu_read_lock(); /* the HWSP may be freed at runtime */
|
|
seqno = __hwsp_seqno(rq);
|
|
rcu_read_unlock();
|
|
|
|
return seqno;
|
|
}
|
|
|
|
static inline bool __i915_request_has_started(const struct i915_request *rq)
|
|
{
|
|
return i915_seqno_passed(__hwsp_seqno(rq), rq->fence.seqno - 1);
|
|
}
|
|
|
|
/**
|
|
* i915_request_started - check if the request has begun being executed
|
|
* @rq: the request
|
|
*
|
|
* If the timeline is not using initial breadcrumbs, a request is
|
|
* considered started if the previous request on its timeline (i.e.
|
|
* context) has been signaled.
|
|
*
|
|
* If the timeline is using semaphores, it will also be emitting an
|
|
* "initial breadcrumb" after the semaphores are complete and just before
|
|
* it began executing the user payload. A request can therefore be active
|
|
* on the HW and not yet started as it is still busywaiting on its
|
|
* dependencies (via HW semaphores).
|
|
*
|
|
* If the request has started, its dependencies will have been signaled
|
|
* (either by fences or by semaphores) and it will have begun processing
|
|
* the user payload.
|
|
*
|
|
* However, even if a request has started, it may have been preempted and
|
|
* so no longer active, or it may have already completed.
|
|
*
|
|
* See also i915_request_is_active().
|
|
*
|
|
* Returns true if the request has begun executing the user payload, or
|
|
* has completed:
|
|
*/
|
|
static inline bool i915_request_started(const struct i915_request *rq)
|
|
{
|
|
bool result;
|
|
|
|
if (i915_request_signaled(rq))
|
|
return true;
|
|
|
|
result = true;
|
|
rcu_read_lock(); /* the HWSP may be freed at runtime */
|
|
if (likely(!i915_request_signaled(rq)))
|
|
/* Remember: started but may have since been preempted! */
|
|
result = __i915_request_has_started(rq);
|
|
rcu_read_unlock();
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* i915_request_is_running - check if the request may actually be executing
|
|
* @rq: the request
|
|
*
|
|
* Returns true if the request is currently submitted to hardware, has passed
|
|
* its start point (i.e. the context is setup and not busywaiting). Note that
|
|
* it may no longer be running by the time the function returns!
|
|
*/
|
|
static inline bool i915_request_is_running(const struct i915_request *rq)
|
|
{
|
|
bool result;
|
|
|
|
if (!i915_request_is_active(rq))
|
|
return false;
|
|
|
|
rcu_read_lock();
|
|
result = __i915_request_has_started(rq) && i915_request_is_active(rq);
|
|
rcu_read_unlock();
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* i915_request_is_ready - check if the request is ready for execution
|
|
* @rq: the request
|
|
*
|
|
* Upon construction, the request is instructed to wait upon various
|
|
* signals before it is ready to be executed by the HW. That is, we do
|
|
* not want to start execution and read data before it is written. In practice,
|
|
* this is controlled with a mixture of interrupts and semaphores. Once
|
|
* the submit fence is completed, the backend scheduler will place the
|
|
* request into its queue and from there submit it for execution. So we
|
|
* can detect when a request is eligible for execution (and is under control
|
|
* of the scheduler) by querying where it is in any of the scheduler's lists.
|
|
*
|
|
* Returns true if the request is ready for execution (it may be inflight),
|
|
* false otherwise.
|
|
*/
|
|
static inline bool i915_request_is_ready(const struct i915_request *rq)
|
|
{
|
|
return !list_empty(&rq->sched.link);
|
|
}
|
|
|
|
static inline bool __i915_request_is_complete(const struct i915_request *rq)
|
|
{
|
|
return i915_seqno_passed(__hwsp_seqno(rq), rq->fence.seqno);
|
|
}
|
|
|
|
static inline bool i915_request_completed(const struct i915_request *rq)
|
|
{
|
|
bool result;
|
|
|
|
if (i915_request_signaled(rq))
|
|
return true;
|
|
|
|
result = true;
|
|
rcu_read_lock(); /* the HWSP may be freed at runtime */
|
|
if (likely(!i915_request_signaled(rq)))
|
|
result = __i915_request_is_complete(rq);
|
|
rcu_read_unlock();
|
|
|
|
return result;
|
|
}
|
|
|
|
static inline void i915_request_mark_complete(struct i915_request *rq)
|
|
{
|
|
WRITE_ONCE(rq->hwsp_seqno, /* decouple from HWSP */
|
|
(u32 *)&rq->fence.seqno);
|
|
}
|
|
|
|
static inline bool i915_request_has_waitboost(const struct i915_request *rq)
|
|
{
|
|
return test_bit(I915_FENCE_FLAG_BOOST, &rq->fence.flags);
|
|
}
|
|
|
|
static inline bool i915_request_has_nopreempt(const struct i915_request *rq)
|
|
{
|
|
/* Preemption should only be disabled very rarely */
|
|
return unlikely(test_bit(I915_FENCE_FLAG_NOPREEMPT, &rq->fence.flags));
|
|
}
|
|
|
|
static inline bool i915_request_has_sentinel(const struct i915_request *rq)
|
|
{
|
|
return unlikely(test_bit(I915_FENCE_FLAG_SENTINEL, &rq->fence.flags));
|
|
}
|
|
|
|
static inline bool i915_request_on_hold(const struct i915_request *rq)
|
|
{
|
|
return unlikely(test_bit(I915_FENCE_FLAG_HOLD, &rq->fence.flags));
|
|
}
|
|
|
|
static inline void i915_request_set_hold(struct i915_request *rq)
|
|
{
|
|
set_bit(I915_FENCE_FLAG_HOLD, &rq->fence.flags);
|
|
}
|
|
|
|
static inline void i915_request_clear_hold(struct i915_request *rq)
|
|
{
|
|
clear_bit(I915_FENCE_FLAG_HOLD, &rq->fence.flags);
|
|
}
|
|
|
|
static inline struct intel_timeline *
|
|
i915_request_timeline(const struct i915_request *rq)
|
|
{
|
|
/* Valid only while the request is being constructed (or retired). */
|
|
return rcu_dereference_protected(rq->timeline,
|
|
lockdep_is_held(&rcu_access_pointer(rq->timeline)->mutex));
|
|
}
|
|
|
|
static inline struct i915_gem_context *
|
|
i915_request_gem_context(const struct i915_request *rq)
|
|
{
|
|
/* Valid only while the request is being constructed (or retired). */
|
|
return rcu_dereference_protected(rq->context->gem_context, true);
|
|
}
|
|
|
|
static inline struct intel_timeline *
|
|
i915_request_active_timeline(const struct i915_request *rq)
|
|
{
|
|
/*
|
|
* When in use during submission, we are protected by a guarantee that
|
|
* the context/timeline is pinned and must remain pinned until after
|
|
* this submission.
|
|
*/
|
|
return rcu_dereference_protected(rq->timeline,
|
|
lockdep_is_held(&rq->engine->active.lock));
|
|
}
|
|
|
|
#endif /* I915_REQUEST_H */
|