Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
f4ba070
Documentation
LICENSES
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
connector
counter
cpufreq
cpuidle
crypto
dax
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio
gpu
drm
amd
arc
arm
armada
aspeed
ast
atmel-hlcdc
bochs
bridge
cirrus
etnaviv
exynos
fsl-dcu
gma500
hisilicon
i2c
i810
i915
display
gem
gt
gvt
oa
selftests
Kconfig
Kconfig.debug
Kconfig.profile
Kconfig.unstable
Makefile
i915_active.c
i915_active.h
i915_active_types.h
i915_buddy.c
i915_buddy.h
i915_cmd_parser.c
i915_debugfs.c
i915_debugfs.h
i915_drv.c
i915_drv.h
i915_fixed.h
i915_gem.c
i915_gem.h
i915_gem_evict.c
i915_gem_fence_reg.c
i915_gem_fence_reg.h
i915_gem_gtt.c
i915_gem_gtt.h
i915_getparam.c
i915_globals.c
i915_globals.h
i915_gpu_error.c
i915_gpu_error.h
i915_ioc32.c
i915_irq.c
i915_irq.h
i915_memcpy.c
i915_memcpy.h
i915_mm.c
i915_params.c
i915_params.h
i915_pci.c
i915_perf.c
i915_perf.h
i915_perf_types.h
i915_pmu.c
i915_pmu.h
i915_priolist_types.h
i915_pvinfo.h
i915_query.c
i915_query.h
i915_reg.h
i915_request.c
i915_request.h
i915_scatterlist.c
i915_scatterlist.h
i915_scheduler.c
i915_scheduler.h
i915_scheduler_types.h
i915_selftest.h
i915_suspend.c
i915_suspend.h
i915_sw_fence.c
i915_sw_fence.h
i915_sw_fence_work.c
i915_sw_fence_work.h
i915_switcheroo.c
i915_switcheroo.h
i915_syncmap.c
i915_syncmap.h
i915_sysfs.c
i915_sysfs.h
i915_trace.h
i915_trace_points.c
i915_user_extensions.c
i915_user_extensions.h
i915_utils.c
i915_utils.h
i915_vgpu.c
i915_vgpu.h
i915_vma.c
i915_vma.h
intel_csr.c
intel_csr.h
intel_device_info.c
intel_device_info.h
intel_gvt.c
intel_gvt.h
intel_memory_region.c
intel_memory_region.h
intel_pch.c
intel_pch.h
intel_pm.c
intel_pm.h
intel_region_lmem.c
intel_region_lmem.h
intel_runtime_pm.c
intel_runtime_pm.h
intel_sideband.c
intel_sideband.h
intel_uncore.c
intel_uncore.h
intel_wakeref.c
intel_wakeref.h
intel_wopcm.c
intel_wopcm.h
imx
ingenic
lib
lima
mcde
mediatek
meson
mga
mgag200
msm
mxsfb
nouveau
omapdrm
panel
panfrost
pl111
qxl
r128
radeon
rcar-du
rockchip
savage
scheduler
selftests
shmobile
sis
sti
stm
sun4i
tdfx
tegra
tilcdc
tiny
ttm
tve200
udl
v3d
vboxvideo
vc4
vgem
via
virtio
vkms
vmwgfx
xen
zte
Kconfig
Makefile
ati_pcigart.c
drm_agpsupport.c
drm_atomic.c
drm_atomic_helper.c
drm_atomic_state_helper.c
drm_atomic_uapi.c
drm_auth.c
drm_blend.c
drm_bridge.c
drm_bufs.c
drm_cache.c
drm_client.c
drm_client_modeset.c
drm_color_mgmt.c
drm_connector.c
drm_context.c
drm_crtc.c
drm_crtc_helper.c
drm_crtc_helper_internal.h
drm_crtc_internal.h
drm_damage_helper.c
drm_debugfs.c
drm_debugfs_crc.c
drm_dma.c
drm_dp_aux_dev.c
drm_dp_cec.c
drm_dp_dual_mode_helper.c
drm_dp_helper.c
drm_dp_mst_topology.c
drm_dp_mst_topology_internal.h
drm_drv.c
drm_dsc.c
drm_dumb_buffers.c
drm_edid.c
drm_edid_load.c
drm_encoder.c
drm_encoder_slave.c
drm_fb_cma_helper.c
drm_fb_helper.c
drm_file.c
drm_flip_work.c
drm_format_helper.c
drm_fourcc.c
drm_framebuffer.c
drm_gem.c
drm_gem_cma_helper.c
drm_gem_framebuffer_helper.c
drm_gem_shmem_helper.c
drm_gem_ttm_helper.c
drm_gem_vram_helper.c
drm_hashtab.c
drm_hdcp.c
drm_internal.h
drm_ioc32.c
drm_ioctl.c
drm_irq.c
drm_kms_helper_common.c
drm_lease.c
drm_legacy.h
drm_legacy_misc.c
drm_lock.c
drm_memory.c
drm_mipi_dbi.c
drm_mipi_dsi.c
drm_mm.c
drm_mode_config.c
drm_mode_object.c
drm_modes.c
drm_modeset_helper.c
drm_modeset_lock.c
drm_of.c
drm_panel.c
drm_panel_orientation_quirks.c
drm_pci.c
drm_plane.c
drm_plane_helper.c
drm_prime.c
drm_print.c
drm_probe_helper.c
drm_property.c
drm_rect.c
drm_scatter.c
drm_scdc_helper.c
drm_self_refresh_helper.c
drm_simple_kms_helper.c
drm_syncobj.c
drm_sysfs.c
drm_trace.h
drm_trace_points.c
drm_vblank.c
drm_vm.c
drm_vma_manager.c
drm_vram_helper_common.c
drm_writeback.c
host1x
ipu-v3
vga
Makefile
greybus
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
ide
idle
iio
infiniband
input
interconnect
iommu
ipack
irqchip
isdn
leds
lightnvm
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
mux
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
siox
slimbus
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
drivers
/
gpu
/
drm
/
i915
/
intel_wakeref.c
Blame
Blame
Latest commit
Chris Wilson
drm/i915: Wait until the intel_wakeref idle callback is complete
Nov 19, 2019
f4ba070
·
Nov 19, 2019
History
History
186 lines (149 loc) · 4.16 KB
Breadcrumbs
linux
/
drivers
/
gpu
/
drm
/
i915
/
intel_wakeref.c
Top
File metadata and controls
Code
Blame
186 lines (149 loc) · 4.16 KB
Raw
/* * SPDX-License-Identifier: MIT * * Copyright © 2019 Intel Corporation */ #include <linux/wait_bit.h> #include "intel_runtime_pm.h" #include "intel_wakeref.h" static void rpm_get(struct intel_wakeref *wf) { wf->wakeref = intel_runtime_pm_get(wf->rpm); } static void rpm_put(struct intel_wakeref *wf) { intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref); intel_runtime_pm_put(wf->rpm, wakeref); INTEL_WAKEREF_BUG_ON(!wakeref); } int __intel_wakeref_get_first(struct intel_wakeref *wf) { /* * Treat get/put as different subclasses, as we may need to run * the put callback from under the shrinker and do not want to * cross-contanimate that callback with any extra work performed * upon acquiring the wakeref. */ mutex_lock_nested(&wf->mutex, SINGLE_DEPTH_NESTING); if (!atomic_read(&wf->count)) { int err; rpm_get(wf); err = wf->ops->get(wf); if (unlikely(err)) { rpm_put(wf); mutex_unlock(&wf->mutex); return err; } smp_mb__before_atomic(); /* release wf->count */ } atomic_inc(&wf->count); mutex_unlock(&wf->mutex); INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0); return 0; } static void ____intel_wakeref_put_last(struct intel_wakeref *wf) { if (!atomic_dec_and_test(&wf->count)) goto unlock; /* ops->put() must reschedule its own release on error/deferral */ if (likely(!wf->ops->put(wf))) { rpm_put(wf); wake_up_var(&wf->wakeref); } unlock: mutex_unlock(&wf->mutex); } void __intel_wakeref_put_last(struct intel_wakeref *wf) { INTEL_WAKEREF_BUG_ON(work_pending(&wf->work)); /* Assume we are not in process context and so cannot sleep. */ if (wf->ops->flags & INTEL_WAKEREF_PUT_ASYNC || !mutex_trylock(&wf->mutex)) { schedule_work(&wf->work); return; } ____intel_wakeref_put_last(wf); } static void __intel_wakeref_put_work(struct work_struct *wrk) { struct intel_wakeref *wf = container_of(wrk, typeof(*wf), work); if (atomic_add_unless(&wf->count, -1, 1)) return; mutex_lock(&wf->mutex); ____intel_wakeref_put_last(wf); } void __intel_wakeref_init(struct intel_wakeref *wf, struct intel_runtime_pm *rpm, const struct intel_wakeref_ops *ops, struct lock_class_key *key) { wf->rpm = rpm; wf->ops = ops; __mutex_init(&wf->mutex, "wakeref", key); atomic_set(&wf->count, 0); wf->wakeref = 0; INIT_WORK(&wf->work, __intel_wakeref_put_work); } int intel_wakeref_wait_for_idle(struct intel_wakeref *wf) { int err; might_sleep(); err = wait_var_event_killable(&wf->wakeref, !intel_wakeref_is_active(wf)); if (err) return err; intel_wakeref_unlock_wait(wf); return 0; } static void wakeref_auto_timeout(struct timer_list *t) { struct intel_wakeref_auto *wf = from_timer(wf, t, timer); intel_wakeref_t wakeref; unsigned long flags; if (!refcount_dec_and_lock_irqsave(&wf->count, &wf->lock, &flags)) return; wakeref = fetch_and_zero(&wf->wakeref); spin_unlock_irqrestore(&wf->lock, flags); intel_runtime_pm_put(wf->rpm, wakeref); } void intel_wakeref_auto_init(struct intel_wakeref_auto *wf, struct intel_runtime_pm *rpm) { spin_lock_init(&wf->lock); timer_setup(&wf->timer, wakeref_auto_timeout, 0); refcount_set(&wf->count, 0); wf->wakeref = 0; wf->rpm = rpm; } void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout) { unsigned long flags; if (!timeout) { if (del_timer_sync(&wf->timer)) wakeref_auto_timeout(&wf->timer); return; } /* Our mission is that we only extend an already active wakeref */ assert_rpm_wakelock_held(wf->rpm); if (!refcount_inc_not_zero(&wf->count)) { spin_lock_irqsave(&wf->lock, flags); if (!refcount_inc_not_zero(&wf->count)) { INTEL_WAKEREF_BUG_ON(wf->wakeref); wf->wakeref = intel_runtime_pm_get_if_in_use(wf->rpm); refcount_set(&wf->count, 1); } spin_unlock_irqrestore(&wf->lock, flags); } /* * If we extend a pending timer, we will only get a single timer * callback and so need to cancel the local inc by running the * elided callback to keep the wf->count balanced. */ if (mod_timer(&wf->timer, jiffies + timeout)) wakeref_auto_timeout(&wf->timer); } void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf) { intel_wakeref_auto(wf, 0); INTEL_WAKEREF_BUG_ON(wf->wakeref); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
You can’t perform that action at this time.
While the code is focused, press Alt+F1 for a menu of operations.