Changes in 5.4.287
netlink: terminate outstanding dump on socket close
net/mlx5: fs, lock FTE when checking if active
net/mlx5e: kTLS, Fix incorrect page refcounting
ocfs2: uncache inode which has failed entering the group
KVM: VMX: Bury Intel PT virtualization (guest/host mode) behind CONFIG_BROKEN
nilfs2: fix null-ptr-deref in block_touch_buffer tracepoint
ocfs2: fix UBSAN warning in ocfs2_verify_volume()
nilfs2: fix null-ptr-deref in block_dirty_buffer tracepoint
Revert "mmc: dw_mmc: Fix IDMAC operation with pages bigger than 4K"
media: dvbdev: fix the logic when DVB_DYNAMIC_MINORS is not set
kbuild: Use uname for LINUX_COMPILE_HOST detection
mm: revert "mm: shmem: fix data-race in shmem_getattr()"
ASoC: Intel: bytcr_rt5640: Add DMI quirk for Vexia Edu Atla 10 tablet
mac80211: fix user-power when emulating chanctx
selftests/watchdog-test: Fix system accidentally reset after watchdog-test
ALSA: hda/realtek: Add subwoofer quirk for Infinix ZERO BOOK 13
x86/amd_nb: Fix compile-testing without CONFIG_AMD_NB
net: usb: qmi_wwan: add Quectel RG650V
soc: qcom: Add check devm_kasprintf() returned value
regulator: rk808: Add apply_bit for BUCK3 on RK809
ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate()
ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
proc/softirqs: replace seq_printf with seq_put_decimal_ull_width
ipmr: Fix access to mfc_cache_list without lock held
cifs: Fix buffer overflow when parsing NFS reparse points
NFSD: Force all NFSv4.2 COPY requests to be synchronous
nvme: fix metadata handling in nvme-passthrough
x86/xen/pvh: Annotate indirect branch as safe
mips: asm: fix warning when disabling MIPS_FP_SUPPORT
initramfs: avoid filename buffer overrun
nvme-pci: fix freeing of the HMB descriptor table
m68k: mvme147: Fix SCSI controller IRQ numbers
m68k: mvme16x: Add and use "mvme16x.h"
m68k: mvme147: Reinstate early console
acpi/arm64: Adjust error handling procedure in gtdt_parse_timer_block()
s390/syscalls: Avoid creation of arch/arch/ directory
hfsplus: don't query the device logical block size multiple times
firmware: google: Unregister driver_info on failure and exit in gsmi
firmware: google: Unregister driver_info on failure
EDAC/bluefield: Fix potential integer overflow
EDAC/fsl_ddr: Fix bad bit shift operations
crypto: pcrypt - Call crypto layer directly when padata_do_parallel() return -EBUSY
crypto: cavium - Fix the if condition to exit loop after timeout
crypto: bcm - add error check in the ahash_hmac_init function
crypto: cavium - Fix an error handling path in cpt_ucode_load_fw()
time: Fix references to _msecs_to_jiffies() handling of values
soc: ti: smartreflex: Use IRQF_NO_AUTOEN flag in request_irq()
soc: qcom: geni-se: fix array underflow in geni_se_clk_tbl_get()
mmc: mmc_spi: drop buggy snprintf()
efi/tpm: Pass correct address to memblock_reserve
tpm: fix signed/unsigned bug when checking event logs
ARM: dts: cubieboard4: Fix DCDC5 regulator constraints
regmap: irq: Set lockdep class for hierarchical IRQ domains
firmware: arm_scpi: Check the DVFS OPP count returned by the firmware
drm/mm: Mark drm_mm_interval_tree*() functions with __maybe_unused
wifi: ath9k: add range check for conn_rsp_epid in htc_connect_service()
drm/omap: Fix locking in omap_gem_new_dmabuf()
wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq()
wifi: mwifiex: Use IRQF_NO_AUTOEN flag in request_irq()
drm/imx/ipuv3: Use IRQF_NO_AUTOEN flag in request_irq()
dt-bindings: vendor-prefixes: Add NeoFidelity, Inc
ASoC: fsl_micfil: Drop unnecessary register read
ASoC: fsl_micfil: do not define SHIFT/MASK for single bits
ASoC: fsl_micfil: use GENMASK to define register bit fields
ASoC: fsl_micfil: fix regmap_write_bits usage
bpf: Fix the xdp_adjust_tail sample prog issue
wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_config_scan()
drm/panfrost: Remove unused id_mask from struct panfrost_model
drm/msm/adreno: Use IRQF_NO_AUTOEN flag in request_irq()
drm/etnaviv: dump: fix sparse warnings
drm/etnaviv: fix power register offset on GC300
drm/etnaviv: hold GPU lock across perfmon sampling
bpf, sockmap: Several fixes to bpf_msg_push_data
bpf, sockmap: Several fixes to bpf_msg_pop_data
bpf, sockmap: Fix sk_msg_reset_curr
selftests: net: really check for bg process completion
net: rfkill: gpio: Add check for clk_enable()
ALSA: us122l: Use snd_card_free_when_closed() at disconnection
ALSA: caiaq: Use snd_card_free_when_closed() at disconnection
ALSA: 6fire: Release resources at card release
netpoll: Use rcu_access_pointer() in netpoll_poll_lock
trace/trace_event_perf: remove duplicate samples on the first tracepoint event
powerpc/vdso: Flag VDSO64 entry points as functions
mfd: tps65010: Use IRQF_NO_AUTOEN flag in request_irq() to fix race
mfd: da9052-spi: Change read-mask to write-mask
mfd: intel_soc_pmic_bxtwc: Use dev_err_probe()
mfd: intel_soc_pmic_bxtwc: Use IRQ domain for USB Type-C device
mfd: intel_soc_pmic_bxtwc: Use IRQ domain for TMU device
mfd: intel_soc_pmic_bxtwc: Use IRQ domain for PMIC devices
cpufreq: loongson2: Unregister platform_driver on failure
mtd: rawnand: atmel: Fix possible memory leak
RDMA/bnxt_re: Check cqe flags to know imm_data vs inv_irkey
mfd: rt5033: Fix missing regmap_del_irq_chip()
scsi: bfa: Fix use-after-free in bfad_im_module_exit()
scsi: fusion: Remove unused variable 'rc'
scsi: qedf: Fix a possible memory leak in qedf_alloc_and_init_sb()
scsi: qedi: Fix a possible memory leak in qedi_alloc_and_init_sb()
ocfs2: fix uninitialized value in ocfs2_file_read_iter()
powerpc/sstep: make emulate_vsx_load and emulate_vsx_store static
fbdev/sh7760fb: Alloc DMA memory from hardware device
fbdev: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()
dt-bindings: clock: adi,axi-clkgen: convert old binding to yaml format
dt-bindings: clock: axi-clkgen: include AXI clk
clk: axi-clkgen: use devm_platform_ioremap_resource() short-hand
clk: clk-axi-clkgen: make sure to enable the AXI bus clock
perf cs-etm: Don't flush when packet_queue fills up
perf probe: Correct demangled symbols in C++ program
PCI: cpqphp: Use PCI_POSSIBLE_ERROR() to check config reads
PCI: cpqphp: Fix PCIBIOS_* return value confusion
m68k: mcfgpio: Fix incorrect register offset for CONFIG_M5441x
m68k: coldfire/device.c: only build FEC when HW macros are defined
perf trace: Do not lose last events in a race
perf trace: Avoid garbage when not printing a syscall's arguments
rpmsg: glink: Add TX_DATA_CONT command while sending
rpmsg: glink: Send READ_NOTIFY command in FIFO full case
rpmsg: glink: Fix GLINK command prefix
rpmsg: glink: use only lower 16-bits of param2 for CMD_OPEN name length
NFSD: Prevent NULL dereference in nfsd4_process_cb_update()
NFSD: Cap the number of bytes copied by nfs4_reset_recoverydir()
NFSD: Fix nfsd4_shutdown_copy()
vfio/pci: Properly hide first-in-list PCIe extended capability
power: supply: core: Remove might_sleep() from power_supply_put()
net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device
tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets
net: usb: lan78xx: Fix refcounting and autosuspend on invalid WoL configuration
marvell: pxa168_eth: fix call balance of pep->clk handling routines
net: stmmac: dwmac-socfpga: Set RX watchdog interrupt as broken
ipmr: convert /proc handlers to rcu_read_lock()
ipmr: fix tables suspicious RCU usage
usb: using mutex lock and supporting O_NONBLOCK flag in iowarrior_read()
usb: yurex: make waiting on yurex_write interruptible
USB: chaoskey: fail open after removal
USB: chaoskey: Fix possible deadlock chaoskey_list_lock
misc: apds990x: Fix missing pm_runtime_disable()
staging: greybus: uart: clean up TIOCGSERIAL
apparmor: fix 'Do simple duplicate message elimination'
usb: ehci-spear: fix call balance of sehci clk handling routines
cgroup: Make operations on the cgroup root_list RCU safe
cgroup: Move rcu_head up near the top of cgroup_root
soc: qcom: socinfo: fix revision check in qcom_socinfo_probe()
ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices
ext4: supress data-race warnings in ext4_free_inodes_{count,set}()
ext4: fix FS_IOC_GETFSMAP handling
jfs: xattr: check invalid xattr size more strictly
ASoC: codecs: Fix atomicity violation in snd_soc_component_get_drvdata()
PCI: Fix use-after-free of slot->bus on hot remove
comedi: Flush partial mappings in error case
tty: ldsic: fix tty_ldisc_autoload sysctl's proc_handler
Bluetooth: Fix type of len in rfcomm_sock_getsockopt{,_old}()
Revert "usb: gadget: composite: fix OS descriptors w_value logic"
serial: sh-sci: Clean sci_ports[0] after at earlycon exit
Revert "serial: sh-sci: Clean sci_ports[0] after at earlycon exit"
netfilter: ipset: add missing range check in bitmap_ip_uadt
spi: Fix acpi deferred irq probe
ubi: wl: Put source PEB into correct list if trying locking LEB failed
um: ubd: Do not use drvdata in release
um: net: Do not use drvdata in release
serial: 8250: omap: Move pm_runtime_get_sync
um: vector: Do not use drvdata in release
sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK
arm64: tls: Fix context-switching of tpidrro_el0 when kpti is enabled
block: fix ordering between checking BLK_MQ_S_STOPPED request adding
HID: wacom: Interpret tilt data from Intuos Pro BT as signed values
media: wl128x: Fix atomicity violation in fmc_send_cmd()
ALSA: hda/realtek: Update ALC225 depop procedure
ALSA: hda/realtek: Set PCBeep to default value for ALC274
ALSA: hda/realtek: Fix Internal Speaker and Mic boost of Infinix Y4 Max
ALSA: hda/realtek: Apply quirk for Medion E15433
usb: dwc3: gadget: Fix checking for number of TRBs left
lib: string_helpers: silence snprintf() output truncation warning
NFSD: Prevent a potential integer overflow
SUNRPC: make sure cache entry active before cache_show
rpmsg: glink: Propagate TX failures in intentless mode as well
um: Fix potential integer overflow during physmem setup
um: Fix the return value of elf_core_copy_task_fpregs
um/sysrq: remove needless variable sp
um: add show_stack_loglvl()
um: Clean up stacktrace dump
um: Always dump trace for specified task in show_stack
NFSv4.0: Fix a use-after-free problem in the asynchronous open()
rtc: st-lpc: Use IRQF_NO_AUTOEN flag in request_irq()
rtc: abx80x: Fix WDT bit position of the status register
rtc: check if __rtc_read_time was successful in rtc_timer_do_work()
ubifs: Correct the total block count by deducting journal reservation
ubi: fastmap: Fix duplicate slab cache names while attaching
ubifs: authentication: Fix use-after-free in ubifs_tnc_end_commit
jffs2: fix use of uninitialized variable
block: return unsigned int from bdev_io_min
9p/xen: fix init sequence
9p/xen: fix release of IRQ
rtc: ab-eoz9: don't fail temperature reads on undervoltage notification
modpost: remove incorrect code in do_eisa_entry()
SUNRPC: correct error code comment in xs_tcp_setup_socket()
SUNRPC: Replace internal use of SOCKWQ_ASYNC_NOSPACE
sunrpc: clear XPRT_SOCK_UPD_TIMEOUT when reset transport
sh: intc: Fix use-after-free bug in register_intc_controller()
ASoC: fsl_micfil: fix the naming style for mask definition
quota: flush quota_release_work upon quota writeback
btrfs: ref-verify: fix use-after-free after invalid ref action
media: i2c: tc358743: Fix crash in the probe error path when using polling
media: ts2020: fix null-ptr-deref in ts2020_probe()
media: venus: Fix pm_runtime_set_suspended() with runtime pm enabled
media: gspca: ov534-ov772x: Fix off-by-one error in set_frame_rate()
media: platform: allegro-dvt: Fix possible memory leak in allocate_buffers_internal()
ovl: Filter invalid inodes with missing lookup function
ftrace: Fix regression with module command in stack_trace_filter
clk: qcom: gcc-qcs404: fix initial rate of GPLL3
ad7780: fix division by zero in ad7780_write_raw()
util_macros.h: fix/rework find_closest() macros
i3c: master: Fix miss free init_dyn_addr at i3c_master_put_i3c_addrs()
dm thin: Add missing destroy_work_on_stack()
nfsd: make sure exp active before svc_export_show
nfsd: fix nfs4_openowner leak when concurrent nfsd4_open occur
drm/etnaviv: flush shader L1 cache after user commandstream
iTCO_wdt: mask NMI_NOW bit for update_no_reboot_bit() call
watchdog: mediatek: Make sure system reset gets asserted in mtk_wdt_restart()
can: sun4i_can: sun4i_can_err(): call can_change_state() even if cf is NULL
can: sun4i_can: sun4i_can_err(): fix {rx,tx}_errors statistics
ipvs: fix UB due to uninitialized stack access in ip_vs_protocol_init()
netfilter: x_tables: fix LED ID check in led_tg_check()
net/sched: tbf: correct backlog statistic for GSO packets
can: j1939: j1939_session_new(): fix skb reference counting
net/ipv6: release expired exception dst cached in socket
dccp: Fix memory leak in dccp_feat_change_recv
tipc: add reference counter to bearer
tipc: enable creating a "preliminary" node
tipc: add new AEAD key structure for user API
tipc: Fix use-after-free of kernel socket in cleanup_bearer().
net/qed: allow old cards not supporting "num_images" to work
igb: Fix potential invalid memory access in igb_init_module()
netfilter: ipset: Hold module reference while requesting a module
netfilter: nft_set_hash: skip duplicated elements pending gc run
xen/xenbus: reference count registered modules
xenbus/backend: Add memory pressure handler callback
xenbus/backend: Protect xenbus callback with lock
xen/xenbus: fix locking
xen: Fix the issue of resource not being properly released in xenbus_dev_probe()
x86/asm: Reorder early variables
crypto: x86/aegis128 - access 32-bit arguments as 32-bit
gpio: grgpio: use a helper variable to store the address of ofdev->dev
gpio: grgpio: Add NULL check in grgpio_probe
drm/sti: Add __iomem for mixer_dbg_mxn's parameter
tcp_bpf: Fix the sk_mem_uncharge logic in tcp_bpf_sendmsg
spi: mpc52xx: Add cancel_work_sync before module remove
ocfs2: free inode when ocfs2_get_init_inode() fails
bpf: Handle BPF_EXIST and BPF_NOEXIST for LPM trie
bpf: Fix exact match conditions in trie_get_next_key()
HID: wacom: fix when get product name maybe null pointer
tracing: Fix cmp_entries_dup() to respect sort() comparison rules
ocfs2: update seq_file index in ocfs2_dlm_seq_next
scsi: qla2xxx: Fix NVMe and NPIV connect issue
scsi: qla2xxx: Supported speed displayed incorrectly for VPorts
scsi: qla2xxx: Remove check req_sg_cnt should be equal to rsp_sg_cnt
nilfs2: fix potential out-of-bounds memory access in nilfs_find_entry()
bcache: revert replacing IS_ERR_OR_NULL with IS_ERR again
dma-buf: fix dma_fence_array_signaled v4
regmap: detach regmap from dev on regmap_exit
mmc: core: Further prevent card detect during shutdown
s390/cpum_sf: Handle CPU hotplug remove during sampling
media: uvcvideo: Add a quirk for the Kaiweets KTI-W02 infrared camera
media: cx231xx: Add support for Dexatek USB Video Grabber 1d19:6108
drm: panel-orientation-quirks: Add quirk for AYA NEO 2 model
drm/mcde: Enable module autoloading
drm/radeon/r600_cs: Fix possible int overflow in r600_packet3_check()
samples/bpf: Fix a resource leak
net: fec_mpc52xx_phy: Use %pa to format resource_size_t
net: ethernet: fs_enet: Use %pa to format resource_size_t
net/sched: cbs: Fix integer overflow in cbs_set_port_rate()
af_packet: avoid erroring out after sock_init_data() in packet_create()
Bluetooth: L2CAP: do not leave dangling sk pointer on error in l2cap_sock_create()
net: af_can: do not leave a dangling sk pointer in can_create()
net: ieee802154: do not leave a dangling sk pointer in ieee802154_create()
net: inet: do not leave a dangling sk pointer in inet_create()
net: inet6: do not leave a dangling sk pointer in inet6_create()
wifi: ath5k: add PCI ID for SX76X
wifi: ath5k: add PCI ID for Arcadyan devices
jfs: array-index-out-of-bounds fix in dtReadFirst
jfs: fix shift-out-of-bounds in dbSplit
jfs: fix array-index-out-of-bounds in jfs_readdir
jfs: add a check to prevent array-index-out-of-bounds in dbAdjTree
drm/amdgpu: set the right AMDGPU sg segment limitation
wifi: ipw2x00: libipw_rx_any(): fix bad alignment
wifi: brcmfmac: Fix oops due to NULL pointer dereference in brcmf_sdiod_sglist_rw()
Bluetooth: btusb: Add RTL8852BE device 0489:e123 to device tables
ASoC: hdmi-codec: reorder channel allocation list
rocker: fix link status detection in rocker_carrier_init()
net/neighbor: clear error in case strict check is not set
netpoll: Use rcu_access_pointer() in __netpoll_setup
tracing: Use atomic64_inc_return() in trace_clock_counter()
leds: class: Protect brightness_show() with led_cdev->led_access mutex
scsi: st: Don't modify unknown block number in MTIOCGET
scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset
pinctrl: qcom-pmic-gpio: add support for PM8937
nvdimm: rectify the illogical code within nd_dax_probe()
f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode.
PCI: Add 'reset_subordinate' to reset hierarchy below bridge
PCI: Add ACS quirk for Wangxun FF5xxx NICs
i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock
usb: chipidea: udc: handle USB Error Interrupt if IOC not set
powerpc/prom_init: Fixup missing powermac #size-cells
misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle
xdp: Simplify devmap cleanup
bpf: fix OOB devmap writes when deleting elements
Revert "unicode: Don't special case ignorable code points"
perf/x86/intel/pt: Fix buffer full but size is 0 case
KVM: arm64: vgic-its: Add a data length check in vgic_its_save_*
KVM: arm64: vgic-its: Clear DTE when MAPD unmaps a device
KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE
jffs2: Prevent rtime decompress memory corruption
jffs2: Fix rtime decompressor
ocfs2: Revert "ocfs2: fix the la space leak when unmounting an ocfs2 volume"
modpost: Add .irqentry.text to OTHER_SECTIONS
Revert "drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read()"
PCI: rockchip-ep: Fix address translation unit programming
ALSA: usb-audio: Fix out of bounds reads when finding clock sources
bpf, xdp: Update devmap comments to reflect napi/rcu usage
Linux 5.4.287
Change-Id: Ib48a7a0e01226c0f910efae2139893c6a139b9b5
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1272 lines
33 KiB
C
1272 lines
33 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. */
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/interconnect.h>
|
|
#include <linux/pm_domain.h>
|
|
#include <linux/pm_opp.h>
|
|
#include <soc/qcom/cmd-db.h>
|
|
|
|
#include "a6xx_gpu.h"
|
|
#include "a6xx_gmu.xml.h"
|
|
|
|
static void a6xx_gmu_fault(struct a6xx_gmu *gmu)
|
|
{
|
|
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
|
|
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
|
|
struct msm_gpu *gpu = &adreno_gpu->base;
|
|
struct drm_device *dev = gpu->dev;
|
|
struct msm_drm_private *priv = dev->dev_private;
|
|
|
|
/* FIXME: add a banner here */
|
|
gmu->hung = true;
|
|
|
|
/* Turn off the hangcheck timer while we are resetting */
|
|
del_timer(&gpu->hangcheck_timer);
|
|
|
|
/* Queue the GPU handler because we need to treat this as a recovery */
|
|
queue_work(priv->wq, &gpu->recover_work);
|
|
}
|
|
|
|
static irqreturn_t a6xx_gmu_irq(int irq, void *data)
|
|
{
|
|
struct a6xx_gmu *gmu = data;
|
|
u32 status;
|
|
|
|
status = gmu_read(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_STATUS);
|
|
gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_CLR, status);
|
|
|
|
if (status & A6XX_GMU_AO_HOST_INTERRUPT_STATUS_WDOG_BITE) {
|
|
dev_err_ratelimited(gmu->dev, "GMU watchdog expired\n");
|
|
|
|
a6xx_gmu_fault(gmu);
|
|
}
|
|
|
|
if (status & A6XX_GMU_AO_HOST_INTERRUPT_STATUS_HOST_AHB_BUS_ERROR)
|
|
dev_err_ratelimited(gmu->dev, "GMU AHB bus error\n");
|
|
|
|
if (status & A6XX_GMU_AO_HOST_INTERRUPT_STATUS_FENCE_ERR)
|
|
dev_err_ratelimited(gmu->dev, "GMU fence error: 0x%x\n",
|
|
gmu_read(gmu, REG_A6XX_GMU_AHB_FENCE_STATUS));
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static irqreturn_t a6xx_hfi_irq(int irq, void *data)
|
|
{
|
|
struct a6xx_gmu *gmu = data;
|
|
u32 status;
|
|
|
|
status = gmu_read(gmu, REG_A6XX_GMU_GMU2HOST_INTR_INFO);
|
|
gmu_write(gmu, REG_A6XX_GMU_GMU2HOST_INTR_CLR, status);
|
|
|
|
if (status & A6XX_GMU_GMU2HOST_INTR_INFO_CM3_FAULT) {
|
|
dev_err_ratelimited(gmu->dev, "GMU firmware fault\n");
|
|
|
|
a6xx_gmu_fault(gmu);
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
bool a6xx_gmu_sptprac_is_on(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 val;
|
|
|
|
/* This can be called from gpu state code so make sure GMU is valid */
|
|
if (!gmu->initialized)
|
|
return false;
|
|
|
|
val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
|
|
|
|
return !(val &
|
|
(A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_SPTPRAC_GDSC_POWER_OFF |
|
|
A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_SP_CLOCK_OFF));
|
|
}
|
|
|
|
/* Check to see if the GX rail is still powered */
|
|
bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 val;
|
|
|
|
/* This can be called from gpu state code so make sure GMU is valid */
|
|
if (!gmu->initialized)
|
|
return false;
|
|
|
|
val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
|
|
|
|
return !(val &
|
|
(A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_GDSC_POWER_OFF |
|
|
A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_CLK_OFF));
|
|
}
|
|
|
|
static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
|
|
{
|
|
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
|
|
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
|
|
struct msm_gpu *gpu = &adreno_gpu->base;
|
|
int ret;
|
|
|
|
/*
|
|
* This can get called from devfreq while the hardware is idle. Don't
|
|
* bring up the power if it isn't already active
|
|
*/
|
|
if (pm_runtime_get_if_in_use(gmu->dev) == 0)
|
|
return;
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_DCVS_ACK_OPTION, 0);
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_DCVS_PERF_SETTING,
|
|
((3 & 0xf) << 28) | index);
|
|
|
|
/*
|
|
* Send an invalid index as a vote for the bus bandwidth and let the
|
|
* firmware decide on the right vote
|
|
*/
|
|
gmu_write(gmu, REG_A6XX_GMU_DCVS_BW_SETTING, 0xff);
|
|
|
|
/* Set and clear the OOB for DCVS to trigger the GMU */
|
|
a6xx_gmu_set_oob(gmu, GMU_OOB_DCVS_SET);
|
|
a6xx_gmu_clear_oob(gmu, GMU_OOB_DCVS_SET);
|
|
|
|
ret = gmu_read(gmu, REG_A6XX_GMU_DCVS_RETURN);
|
|
if (ret)
|
|
dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
|
|
|
|
gmu->freq = gmu->gpu_freqs[index];
|
|
|
|
/*
|
|
* Eventually we will want to scale the path vote with the frequency but
|
|
* for now leave it at max so that the performance is nominal.
|
|
*/
|
|
icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
|
|
pm_runtime_put(gmu->dev);
|
|
}
|
|
|
|
void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq)
|
|
{
|
|
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
|
|
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
|
|
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
|
|
u32 perf_index = 0;
|
|
|
|
if (freq == gmu->freq)
|
|
return;
|
|
|
|
for (perf_index = 0; perf_index < gmu->nr_gpu_freqs - 1; perf_index++)
|
|
if (freq == gmu->gpu_freqs[perf_index])
|
|
break;
|
|
|
|
__a6xx_gmu_set_freq(gmu, perf_index);
|
|
}
|
|
|
|
unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
|
|
{
|
|
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
|
|
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
|
|
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
|
|
|
|
return gmu->freq;
|
|
}
|
|
|
|
static bool a6xx_gmu_check_idle_level(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 val;
|
|
int local = gmu->idle_level;
|
|
|
|
/* SPTP and IFPC both report as IFPC */
|
|
if (gmu->idle_level == GMU_IDLE_STATE_SPTP)
|
|
local = GMU_IDLE_STATE_IFPC;
|
|
|
|
val = gmu_read(gmu, REG_A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE);
|
|
|
|
if (val == local) {
|
|
if (gmu->idle_level != GMU_IDLE_STATE_IFPC ||
|
|
!a6xx_gmu_gx_is_on(gmu))
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/* Wait for the GMU to get to its most idle state */
|
|
int a6xx_gmu_wait_for_idle(struct a6xx_gmu *gmu)
|
|
{
|
|
return spin_until(a6xx_gmu_check_idle_level(gmu));
|
|
}
|
|
|
|
static int a6xx_gmu_start(struct a6xx_gmu *gmu)
|
|
{
|
|
int ret;
|
|
u32 val;
|
|
u32 mask, reset_val;
|
|
|
|
val = gmu_read(gmu, REG_A6XX_GMU_CM3_DTCM_START + 0xff8);
|
|
if (val <= 0x20010004) {
|
|
mask = 0xffffffff;
|
|
reset_val = 0xbabeface;
|
|
} else {
|
|
mask = 0x1ff;
|
|
reset_val = 0x100;
|
|
}
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_CM3_SYSRESET, 1);
|
|
gmu_write(gmu, REG_A6XX_GMU_CM3_SYSRESET, 0);
|
|
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_CM3_FW_INIT_RESULT, val,
|
|
(val & mask) == reset_val, 100, 10000);
|
|
|
|
if (ret)
|
|
DRM_DEV_ERROR(gmu->dev, "GMU firmware initialization timed out\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int a6xx_gmu_hfi_start(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 val;
|
|
int ret;
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_HFI_CTRL_INIT, 1);
|
|
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_HFI_CTRL_STATUS, val,
|
|
val & 1, 100, 10000);
|
|
if (ret)
|
|
DRM_DEV_ERROR(gmu->dev, "Unable to start the HFI queues\n");
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* Trigger a OOB (out of band) request to the GMU */
|
|
int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)
|
|
{
|
|
int ret;
|
|
u32 val;
|
|
int request, ack;
|
|
const char *name;
|
|
|
|
switch (state) {
|
|
case GMU_OOB_GPU_SET:
|
|
request = GMU_OOB_GPU_SET_REQUEST;
|
|
ack = GMU_OOB_GPU_SET_ACK;
|
|
name = "GPU_SET";
|
|
break;
|
|
case GMU_OOB_BOOT_SLUMBER:
|
|
request = GMU_OOB_BOOT_SLUMBER_REQUEST;
|
|
ack = GMU_OOB_BOOT_SLUMBER_ACK;
|
|
name = "BOOT_SLUMBER";
|
|
break;
|
|
case GMU_OOB_DCVS_SET:
|
|
request = GMU_OOB_DCVS_REQUEST;
|
|
ack = GMU_OOB_DCVS_ACK;
|
|
name = "GPU_DCVS";
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
/* Trigger the equested OOB operation */
|
|
gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET, 1 << request);
|
|
|
|
/* Wait for the acknowledge interrupt */
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_GMU2HOST_INTR_INFO, val,
|
|
val & (1 << ack), 100, 10000);
|
|
|
|
if (ret)
|
|
DRM_DEV_ERROR(gmu->dev,
|
|
"Timeout waiting for GMU OOB set %s: 0x%x\n",
|
|
name,
|
|
gmu_read(gmu, REG_A6XX_GMU_GMU2HOST_INTR_INFO));
|
|
|
|
/* Clear the acknowledge interrupt */
|
|
gmu_write(gmu, REG_A6XX_GMU_GMU2HOST_INTR_CLR, 1 << ack);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* Clear a pending OOB state in the GMU */
|
|
void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)
|
|
{
|
|
switch (state) {
|
|
case GMU_OOB_GPU_SET:
|
|
gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET,
|
|
1 << GMU_OOB_GPU_SET_CLEAR);
|
|
break;
|
|
case GMU_OOB_BOOT_SLUMBER:
|
|
gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET,
|
|
1 << GMU_OOB_BOOT_SLUMBER_CLEAR);
|
|
break;
|
|
case GMU_OOB_DCVS_SET:
|
|
gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET,
|
|
1 << GMU_OOB_DCVS_CLEAR);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* Enable CPU control of SPTP power power collapse */
|
|
static int a6xx_sptprac_enable(struct a6xx_gmu *gmu)
|
|
{
|
|
int ret;
|
|
u32 val;
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_GX_SPTPRAC_POWER_CONTROL, 0x778000);
|
|
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, val,
|
|
(val & 0x38) == 0x28, 1, 100);
|
|
|
|
if (ret) {
|
|
DRM_DEV_ERROR(gmu->dev, "Unable to power on SPTPRAC: 0x%x\n",
|
|
gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS));
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Disable CPU control of SPTP power power collapse */
|
|
static void a6xx_sptprac_disable(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 val;
|
|
int ret;
|
|
|
|
/* Make sure retention is on */
|
|
gmu_rmw(gmu, REG_A6XX_GPU_CC_GX_GDSCR, 0, (1 << 11));
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_GX_SPTPRAC_POWER_CONTROL, 0x778001);
|
|
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, val,
|
|
(val & 0x04), 100, 10000);
|
|
|
|
if (ret)
|
|
DRM_DEV_ERROR(gmu->dev, "failed to power off SPTPRAC: 0x%x\n",
|
|
gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS));
|
|
}
|
|
|
|
/* Let the GMU know we are starting a boot sequence */
|
|
static int a6xx_gmu_gfx_rail_on(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 vote;
|
|
|
|
/* Let the GMU know we are getting ready for boot */
|
|
gmu_write(gmu, REG_A6XX_GMU_BOOT_SLUMBER_OPTION, 0);
|
|
|
|
/* Choose the "default" power level as the highest available */
|
|
vote = gmu->gx_arc_votes[gmu->nr_gpu_freqs - 1];
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_GX_VOTE_IDX, vote & 0xff);
|
|
gmu_write(gmu, REG_A6XX_GMU_MX_VOTE_IDX, (vote >> 8) & 0xff);
|
|
|
|
/* Let the GMU know the boot sequence has started */
|
|
return a6xx_gmu_set_oob(gmu, GMU_OOB_BOOT_SLUMBER);
|
|
}
|
|
|
|
/* Let the GMU know that we are about to go into slumber */
|
|
static int a6xx_gmu_notify_slumber(struct a6xx_gmu *gmu)
|
|
{
|
|
int ret;
|
|
|
|
/* Disable the power counter so the GMU isn't busy */
|
|
gmu_write(gmu, REG_A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
|
|
|
|
/* Disable SPTP_PC if the CPU is responsible for it */
|
|
if (gmu->idle_level < GMU_IDLE_STATE_SPTP)
|
|
a6xx_sptprac_disable(gmu);
|
|
|
|
/* Tell the GMU to get ready to slumber */
|
|
gmu_write(gmu, REG_A6XX_GMU_BOOT_SLUMBER_OPTION, 1);
|
|
|
|
ret = a6xx_gmu_set_oob(gmu, GMU_OOB_BOOT_SLUMBER);
|
|
a6xx_gmu_clear_oob(gmu, GMU_OOB_BOOT_SLUMBER);
|
|
|
|
if (!ret) {
|
|
/* Check to see if the GMU really did slumber */
|
|
if (gmu_read(gmu, REG_A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE)
|
|
!= 0x0f) {
|
|
DRM_DEV_ERROR(gmu->dev, "The GMU did not go into slumber\n");
|
|
ret = -ETIMEDOUT;
|
|
}
|
|
}
|
|
|
|
/* Put fence into allow mode */
|
|
gmu_write(gmu, REG_A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
|
|
return ret;
|
|
}
|
|
|
|
static int a6xx_rpmh_start(struct a6xx_gmu *gmu)
|
|
{
|
|
int ret;
|
|
u32 val;
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, 1 << 1);
|
|
/* Wait for the register to finish posting */
|
|
wmb();
|
|
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val,
|
|
val & (1 << 1), 100, 10000);
|
|
if (ret) {
|
|
DRM_DEV_ERROR(gmu->dev, "Unable to power on the GPU RSC\n");
|
|
return ret;
|
|
}
|
|
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_RSCC_SEQ_BUSY_DRV0, val,
|
|
!val, 100, 10000);
|
|
|
|
if (ret) {
|
|
DRM_DEV_ERROR(gmu->dev, "GPU RSC sequence stuck while waking up the GPU\n");
|
|
return ret;
|
|
}
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, 0);
|
|
|
|
/* Set up CX GMU counter 0 to count busy ticks */
|
|
gmu_write(gmu, REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_MASK, 0xff000000);
|
|
gmu_rmw(gmu, REG_A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0, 0xff, 0x20);
|
|
|
|
/* Enable the power counter */
|
|
gmu_write(gmu, REG_A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
|
|
return 0;
|
|
}
|
|
|
|
static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)
|
|
{
|
|
int ret;
|
|
u32 val;
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, 1);
|
|
|
|
ret = gmu_poll_timeout(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,
|
|
val, val & (1 << 16), 100, 10000);
|
|
if (ret)
|
|
DRM_DEV_ERROR(gmu->dev, "Unable to power off the GPU RSC\n");
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, 0);
|
|
}
|
|
|
|
static inline void pdc_write(void __iomem *ptr, u32 offset, u32 value)
|
|
{
|
|
return msm_writel(value, ptr + (offset << 2));
|
|
}
|
|
|
|
static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev,
|
|
const char *name);
|
|
|
|
static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(gmu->dev);
|
|
void __iomem *pdcptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc");
|
|
void __iomem *seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
|
|
|
|
if (!pdcptr || !seqptr)
|
|
goto err;
|
|
|
|
/* Disable SDE clock gating */
|
|
gmu_write(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0, BIT(24));
|
|
|
|
/* Setup RSC PDC handshake for sleep and wakeup */
|
|
gmu_write(gmu, REG_A6XX_RSCC_PDC_SLAVE_ID_DRV0, 1);
|
|
gmu_write(gmu, REG_A6XX_RSCC_HIDDEN_TCS_CMD0_DATA, 0);
|
|
gmu_write(gmu, REG_A6XX_RSCC_HIDDEN_TCS_CMD0_ADDR, 0);
|
|
gmu_write(gmu, REG_A6XX_RSCC_HIDDEN_TCS_CMD0_DATA + 2, 0);
|
|
gmu_write(gmu, REG_A6XX_RSCC_HIDDEN_TCS_CMD0_ADDR + 2, 0);
|
|
gmu_write(gmu, REG_A6XX_RSCC_HIDDEN_TCS_CMD0_DATA + 4, 0x80000000);
|
|
gmu_write(gmu, REG_A6XX_RSCC_HIDDEN_TCS_CMD0_ADDR + 4, 0);
|
|
gmu_write(gmu, REG_A6XX_RSCC_OVERRIDE_START_ADDR, 0);
|
|
gmu_write(gmu, REG_A6XX_RSCC_PDC_SEQ_START_ADDR, 0x4520);
|
|
gmu_write(gmu, REG_A6XX_RSCC_PDC_MATCH_VALUE_LO, 0x4510);
|
|
gmu_write(gmu, REG_A6XX_RSCC_PDC_MATCH_VALUE_HI, 0x4514);
|
|
|
|
/* Load RSC sequencer uCode for sleep and wakeup */
|
|
gmu_write(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0, 0xa7a506a0);
|
|
gmu_write(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 1, 0xa1e6a6e7);
|
|
gmu_write(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 2, 0xa2e081e1);
|
|
gmu_write(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 3, 0xe9a982e2);
|
|
gmu_write(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 4, 0x0020e8a8);
|
|
|
|
/* Load PDC sequencer uCode for power up and power down sequence */
|
|
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0, 0xfebea1e1);
|
|
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0 + 1, 0xa5a4a3a2);
|
|
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0 + 2, 0x8382a6e0);
|
|
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0 + 3, 0xbce3e284);
|
|
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0 + 4, 0x002081fc);
|
|
|
|
/* Set TCS commands used by PDC sequence for low power modes */
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD_ENABLE_BANK, 7);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD_WAIT_FOR_CMPL_BANK, 0);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CONTROL, 0);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_MSGID, 0x10108);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_ADDR, 0x30010);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_DATA, 1);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_MSGID + 4, 0x10108);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_ADDR + 4, 0x30000);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_DATA + 4, 0x0);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_MSGID + 8, 0x10108);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_ADDR + 8, 0x30080);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS1_CMD0_DATA + 8, 0x0);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD_ENABLE_BANK, 7);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD_WAIT_FOR_CMPL_BANK, 0);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CONTROL, 0);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_MSGID, 0x10108);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_ADDR, 0x30010);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA, 2);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_MSGID + 4, 0x10108);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_ADDR + 4, 0x30000);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 4, 0x3);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_MSGID + 8, 0x10108);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_ADDR + 8, 0x30080);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 8, 0x3);
|
|
|
|
/* Setup GPU PDC */
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_SEQ_START_ADDR, 0);
|
|
pdc_write(pdcptr, REG_A6XX_PDC_GPU_ENABLE_PDC, 0x80000001);
|
|
|
|
/* ensure no writes happen before the uCode is fully written */
|
|
wmb();
|
|
|
|
err:
|
|
if (!IS_ERR_OR_NULL(pdcptr))
|
|
iounmap(pdcptr);
|
|
if (!IS_ERR_OR_NULL(seqptr))
|
|
iounmap(seqptr);
|
|
}
|
|
|
|
/*
|
|
* The lowest 16 bits of this value are the number of XO clock cycles for main
|
|
* hysteresis which is set at 0x1680 cycles (300 us). The higher 16 bits are
|
|
* for the shorter hysteresis that happens after main - this is 0xa (.5 us)
|
|
*/
|
|
|
|
#define GMU_PWR_COL_HYST 0x000a1680
|
|
|
|
/* Set up the idle state for the GMU */
|
|
static void a6xx_gmu_power_config(struct a6xx_gmu *gmu)
|
|
{
|
|
/* Disable GMU WB/RB buffer */
|
|
gmu_write(gmu, REG_A6XX_GMU_SYS_BUS_CONFIG, 0x1);
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0x9c40400);
|
|
|
|
switch (gmu->idle_level) {
|
|
case GMU_IDLE_STATE_IFPC:
|
|
gmu_write(gmu, REG_A6XX_GMU_PWR_COL_INTER_FRAME_HYST,
|
|
GMU_PWR_COL_HYST);
|
|
gmu_rmw(gmu, REG_A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0,
|
|
A6XX_GMU_PWR_COL_INTER_FRAME_CTRL_IFPC_ENABLE |
|
|
A6XX_GMU_PWR_COL_INTER_FRAME_CTRL_HM_POWER_COLLAPSE_ENABLE);
|
|
/* Fall through */
|
|
case GMU_IDLE_STATE_SPTP:
|
|
gmu_write(gmu, REG_A6XX_GMU_PWR_COL_SPTPRAC_HYST,
|
|
GMU_PWR_COL_HYST);
|
|
gmu_rmw(gmu, REG_A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0,
|
|
A6XX_GMU_PWR_COL_INTER_FRAME_CTRL_IFPC_ENABLE |
|
|
A6XX_GMU_PWR_COL_INTER_FRAME_CTRL_SPTPRAC_POWER_CONTROL_ENABLE);
|
|
}
|
|
|
|
/* Enable RPMh GPU client */
|
|
gmu_rmw(gmu, REG_A6XX_GMU_RPMH_CTRL, 0,
|
|
A6XX_GMU_RPMH_CTRL_RPMH_INTERFACE_ENABLE |
|
|
A6XX_GMU_RPMH_CTRL_LLC_VOTE_ENABLE |
|
|
A6XX_GMU_RPMH_CTRL_DDR_VOTE_ENABLE |
|
|
A6XX_GMU_RPMH_CTRL_MX_VOTE_ENABLE |
|
|
A6XX_GMU_RPMH_CTRL_CX_VOTE_ENABLE |
|
|
A6XX_GMU_RPMH_CTRL_GFX_VOTE_ENABLE);
|
|
}
|
|
|
|
static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)
|
|
{
|
|
static bool rpmh_init;
|
|
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
|
|
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
|
|
int i, ret;
|
|
u32 chipid;
|
|
u32 *image;
|
|
|
|
if (state == GMU_WARM_BOOT) {
|
|
ret = a6xx_rpmh_start(gmu);
|
|
if (ret)
|
|
return ret;
|
|
} else {
|
|
if (WARN(!adreno_gpu->fw[ADRENO_FW_GMU],
|
|
"GMU firmware is not loaded\n"))
|
|
return -ENOENT;
|
|
|
|
/* Sanity check the size of the firmware that was loaded */
|
|
if (adreno_gpu->fw[ADRENO_FW_GMU]->size > 0x8000) {
|
|
DRM_DEV_ERROR(gmu->dev,
|
|
"GMU firmware is bigger than the available region\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
/* Turn on register retention */
|
|
gmu_write(gmu, REG_A6XX_GMU_GENERAL_7, 1);
|
|
|
|
/* We only need to load the RPMh microcode once */
|
|
if (!rpmh_init) {
|
|
a6xx_gmu_rpmh_init(gmu);
|
|
rpmh_init = true;
|
|
} else {
|
|
ret = a6xx_rpmh_start(gmu);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
image = (u32 *) adreno_gpu->fw[ADRENO_FW_GMU]->data;
|
|
|
|
for (i = 0; i < adreno_gpu->fw[ADRENO_FW_GMU]->size >> 2; i++)
|
|
gmu_write(gmu, REG_A6XX_GMU_CM3_ITCM_START + i,
|
|
image[i]);
|
|
}
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_CM3_FW_INIT_RESULT, 0);
|
|
gmu_write(gmu, REG_A6XX_GMU_CM3_BOOT_CONFIG, 0x02);
|
|
|
|
/* Write the iova of the HFI table */
|
|
gmu_write(gmu, REG_A6XX_GMU_HFI_QTBL_ADDR, gmu->hfi->iova);
|
|
gmu_write(gmu, REG_A6XX_GMU_HFI_QTBL_INFO, 1);
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_AHB_FENCE_RANGE_0,
|
|
(1 << 31) | (0xa << 18) | (0xa0));
|
|
|
|
chipid = adreno_gpu->rev.core << 24;
|
|
chipid |= adreno_gpu->rev.major << 16;
|
|
chipid |= adreno_gpu->rev.minor << 12;
|
|
chipid |= adreno_gpu->rev.patchid << 8;
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_HFI_SFR_ADDR, chipid);
|
|
|
|
/* Set up the lowest idle level on the GMU */
|
|
a6xx_gmu_power_config(gmu);
|
|
|
|
ret = a6xx_gmu_start(gmu);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = a6xx_gmu_gfx_rail_on(gmu);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* Enable SPTP_PC if the CPU is responsible for it */
|
|
if (gmu->idle_level < GMU_IDLE_STATE_SPTP) {
|
|
ret = a6xx_sptprac_enable(gmu);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
ret = a6xx_gmu_hfi_start(gmu);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* FIXME: Do we need this wmb() here? */
|
|
wmb();
|
|
|
|
return 0;
|
|
}
|
|
|
|
#define A6XX_HFI_IRQ_MASK \
|
|
(A6XX_GMU_GMU2HOST_INTR_INFO_CM3_FAULT)
|
|
|
|
#define A6XX_GMU_IRQ_MASK \
|
|
(A6XX_GMU_AO_HOST_INTERRUPT_STATUS_WDOG_BITE | \
|
|
A6XX_GMU_AO_HOST_INTERRUPT_STATUS_HOST_AHB_BUS_ERROR | \
|
|
A6XX_GMU_AO_HOST_INTERRUPT_STATUS_FENCE_ERR)
|
|
|
|
static void a6xx_gmu_irq_disable(struct a6xx_gmu *gmu)
|
|
{
|
|
disable_irq(gmu->gmu_irq);
|
|
disable_irq(gmu->hfi_irq);
|
|
|
|
gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_MASK, ~0);
|
|
gmu_write(gmu, REG_A6XX_GMU_GMU2HOST_INTR_MASK, ~0);
|
|
}
|
|
|
|
static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 val;
|
|
|
|
/* Make sure there are no outstanding RPMh votes */
|
|
gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS0_DRV0_STATUS, val,
|
|
(val & 1), 100, 10000);
|
|
gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS1_DRV0_STATUS, val,
|
|
(val & 1), 100, 10000);
|
|
gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS2_DRV0_STATUS, val,
|
|
(val & 1), 100, 10000);
|
|
gmu_poll_timeout(gmu, REG_A6XX_RSCC_TCS3_DRV0_STATUS, val,
|
|
(val & 1), 100, 1000);
|
|
}
|
|
|
|
/* Force the GMU off in case it isn't responsive */
|
|
static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)
|
|
{
|
|
/* Flush all the queues */
|
|
a6xx_hfi_stop(gmu);
|
|
|
|
/* Stop the interrupts */
|
|
a6xx_gmu_irq_disable(gmu);
|
|
|
|
/* Force off SPTP in case the GMU is managing it */
|
|
a6xx_sptprac_disable(gmu);
|
|
|
|
/* Make sure there are no outstanding RPMh votes */
|
|
a6xx_gmu_rpmh_off(gmu);
|
|
}
|
|
|
|
int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
|
|
{
|
|
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
|
|
struct msm_gpu *gpu = &adreno_gpu->base;
|
|
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
|
|
int status, ret;
|
|
|
|
if (WARN(!gmu->initialized, "The GMU is not set up yet\n"))
|
|
return 0;
|
|
|
|
gmu->hung = false;
|
|
|
|
/* Turn on the resources */
|
|
pm_runtime_get_sync(gmu->dev);
|
|
|
|
/*
|
|
* "enable" the GX power domain which won't actually do anything but it
|
|
* will make sure that the refcounting is correct in case we need to
|
|
* bring down the GX after a GMU failure
|
|
*/
|
|
if (!IS_ERR_OR_NULL(gmu->gxpd))
|
|
pm_runtime_get_sync(gmu->gxpd);
|
|
|
|
/* Use a known rate to bring up the GMU */
|
|
clk_set_rate(gmu->core_clk, 200000000);
|
|
ret = clk_bulk_prepare_enable(gmu->nr_clocks, gmu->clocks);
|
|
if (ret) {
|
|
pm_runtime_put(gmu->gxpd);
|
|
pm_runtime_put(gmu->dev);
|
|
return ret;
|
|
}
|
|
|
|
/* Set the bus quota to a reasonable value for boot */
|
|
icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));
|
|
|
|
/* Enable the GMU interrupt */
|
|
gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_CLR, ~0);
|
|
gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_MASK, ~A6XX_GMU_IRQ_MASK);
|
|
enable_irq(gmu->gmu_irq);
|
|
|
|
/* Check to see if we are doing a cold or warm boot */
|
|
status = gmu_read(gmu, REG_A6XX_GMU_GENERAL_7) == 1 ?
|
|
GMU_WARM_BOOT : GMU_COLD_BOOT;
|
|
|
|
ret = a6xx_gmu_fw_start(gmu, status);
|
|
if (ret)
|
|
goto out;
|
|
|
|
ret = a6xx_hfi_start(gmu, status);
|
|
if (ret)
|
|
goto out;
|
|
|
|
/*
|
|
* Turn on the GMU firmware fault interrupt after we know the boot
|
|
* sequence is successful
|
|
*/
|
|
gmu_write(gmu, REG_A6XX_GMU_GMU2HOST_INTR_CLR, ~0);
|
|
gmu_write(gmu, REG_A6XX_GMU_GMU2HOST_INTR_MASK, ~A6XX_HFI_IRQ_MASK);
|
|
enable_irq(gmu->hfi_irq);
|
|
|
|
/* Set the GPU to the highest power frequency */
|
|
__a6xx_gmu_set_freq(gmu, gmu->nr_gpu_freqs - 1);
|
|
|
|
out:
|
|
/* On failure, shut down the GMU to leave it in a good state */
|
|
if (ret) {
|
|
disable_irq(gmu->gmu_irq);
|
|
a6xx_rpmh_stop(gmu);
|
|
pm_runtime_put(gmu->gxpd);
|
|
pm_runtime_put(gmu->dev);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool a6xx_gmu_isidle(struct a6xx_gmu *gmu)
|
|
{
|
|
u32 reg;
|
|
|
|
if (!gmu->initialized)
|
|
return true;
|
|
|
|
reg = gmu_read(gmu, REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS);
|
|
|
|
if (reg & A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS_GPUBUSYIGNAHB)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
/* Gracefully try to shut down the GMU and by extension the GPU */
|
|
static void a6xx_gmu_shutdown(struct a6xx_gmu *gmu)
|
|
{
|
|
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
|
|
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
|
|
struct msm_gpu *gpu = &adreno_gpu->base;
|
|
u32 val;
|
|
|
|
/*
|
|
* The GMU may still be in slumber unless the GPU started so check and
|
|
* skip putting it back into slumber if so
|
|
*/
|
|
val = gmu_read(gmu, REG_A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE);
|
|
|
|
if (val != 0xf) {
|
|
int ret = a6xx_gmu_wait_for_idle(gmu);
|
|
|
|
/* If the GMU isn't responding assume it is hung */
|
|
if (ret) {
|
|
a6xx_gmu_force_off(gmu);
|
|
return;
|
|
}
|
|
|
|
/* Clear the VBIF pipe before shutting down */
|
|
gpu_write(gpu, REG_A6XX_VBIF_XIN_HALT_CTRL0, 0xf);
|
|
spin_until((gpu_read(gpu, REG_A6XX_VBIF_XIN_HALT_CTRL1) & 0xf)
|
|
== 0xf);
|
|
gpu_write(gpu, REG_A6XX_VBIF_XIN_HALT_CTRL0, 0);
|
|
|
|
/* tell the GMU we want to slumber */
|
|
a6xx_gmu_notify_slumber(gmu);
|
|
|
|
ret = gmu_poll_timeout(gmu,
|
|
REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, val,
|
|
!(val & A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS_GPUBUSYIGNAHB),
|
|
100, 10000);
|
|
|
|
/*
|
|
* Let the user know we failed to slumber but don't worry too
|
|
* much because we are powering down anyway
|
|
*/
|
|
|
|
if (ret)
|
|
DRM_DEV_ERROR(gmu->dev,
|
|
"Unable to slumber GMU: status = 0%x/0%x\n",
|
|
gmu_read(gmu,
|
|
REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS),
|
|
gmu_read(gmu,
|
|
REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS2));
|
|
}
|
|
|
|
/* Turn off HFI */
|
|
a6xx_hfi_stop(gmu);
|
|
|
|
/* Stop the interrupts and mask the hardware */
|
|
a6xx_gmu_irq_disable(gmu);
|
|
|
|
/* Tell RPMh to power off the GPU */
|
|
a6xx_rpmh_stop(gmu);
|
|
}
|
|
|
|
|
|
int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
|
|
{
|
|
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
|
|
struct msm_gpu *gpu = &a6xx_gpu->base.base;
|
|
|
|
if (!pm_runtime_active(gmu->dev))
|
|
return 0;
|
|
|
|
/*
|
|
* Force the GMU off if we detected a hang, otherwise try to shut it
|
|
* down gracefully
|
|
*/
|
|
if (gmu->hung)
|
|
a6xx_gmu_force_off(gmu);
|
|
else
|
|
a6xx_gmu_shutdown(gmu);
|
|
|
|
/* Remove the bus vote */
|
|
icc_set_bw(gpu->icc_path, 0, 0);
|
|
|
|
/*
|
|
* Make sure the GX domain is off before turning off the GMU (CX)
|
|
* domain. Usually the GMU does this but only if the shutdown sequence
|
|
* was successful
|
|
*/
|
|
if (!IS_ERR_OR_NULL(gmu->gxpd))
|
|
pm_runtime_put_sync(gmu->gxpd);
|
|
|
|
clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
|
|
|
|
pm_runtime_put_sync(gmu->dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void a6xx_gmu_memory_free(struct a6xx_gmu *gmu, struct a6xx_gmu_bo *bo)
|
|
{
|
|
if (IS_ERR_OR_NULL(bo))
|
|
return;
|
|
|
|
dma_free_attrs(gmu->dev, bo->size, bo->virt, bo->iova, bo->attrs);
|
|
kfree(bo);
|
|
}
|
|
|
|
static struct a6xx_gmu_bo *a6xx_gmu_memory_alloc(struct a6xx_gmu *gmu,
|
|
size_t size)
|
|
{
|
|
struct a6xx_gmu_bo *bo;
|
|
|
|
bo = kzalloc(sizeof(*bo), GFP_KERNEL);
|
|
if (!bo)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
bo->size = PAGE_ALIGN(size);
|
|
bo->attrs = DMA_ATTR_WRITE_COMBINE;
|
|
|
|
bo->virt = dma_alloc_attrs(gmu->dev, bo->size, &bo->iova, GFP_KERNEL,
|
|
bo->attrs);
|
|
|
|
if (!bo->virt) {
|
|
kfree(bo);
|
|
return ERR_PTR(-ENOMEM);
|
|
}
|
|
|
|
return bo;
|
|
}
|
|
|
|
/* Return the 'arc-level' for the given frequency */
|
|
static unsigned int a6xx_gmu_get_arc_level(struct device *dev,
|
|
unsigned long freq)
|
|
{
|
|
struct dev_pm_opp *opp;
|
|
unsigned int val;
|
|
|
|
if (!freq)
|
|
return 0;
|
|
|
|
opp = dev_pm_opp_find_freq_exact(dev, freq, true);
|
|
if (IS_ERR(opp))
|
|
return 0;
|
|
|
|
val = dev_pm_opp_get_level(opp);
|
|
|
|
dev_pm_opp_put(opp);
|
|
|
|
return val;
|
|
}
|
|
|
|
static int a6xx_gmu_rpmh_arc_votes_init(struct device *dev, u32 *votes,
|
|
unsigned long *freqs, int freqs_count, const char *id)
|
|
{
|
|
int i, j;
|
|
const u16 *pri, *sec;
|
|
size_t pri_count, sec_count;
|
|
|
|
pri = cmd_db_read_aux_data(id, &pri_count);
|
|
if (IS_ERR(pri))
|
|
return PTR_ERR(pri);
|
|
/*
|
|
* The data comes back as an array of unsigned shorts so adjust the
|
|
* count accordingly
|
|
*/
|
|
pri_count >>= 1;
|
|
if (!pri_count)
|
|
return -EINVAL;
|
|
|
|
sec = cmd_db_read_aux_data("mx.lvl", &sec_count);
|
|
if (IS_ERR(sec))
|
|
return PTR_ERR(sec);
|
|
|
|
sec_count >>= 1;
|
|
if (!sec_count)
|
|
return -EINVAL;
|
|
|
|
/* Construct a vote for each frequency */
|
|
for (i = 0; i < freqs_count; i++) {
|
|
u8 pindex = 0, sindex = 0;
|
|
unsigned int level = a6xx_gmu_get_arc_level(dev, freqs[i]);
|
|
|
|
/* Get the primary index that matches the arc level */
|
|
for (j = 0; j < pri_count; j++) {
|
|
if (pri[j] >= level) {
|
|
pindex = j;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (j == pri_count) {
|
|
DRM_DEV_ERROR(dev,
|
|
"Level %u not found in in the RPMh list\n",
|
|
level);
|
|
DRM_DEV_ERROR(dev, "Available levels:\n");
|
|
for (j = 0; j < pri_count; j++)
|
|
DRM_DEV_ERROR(dev, " %u\n", pri[j]);
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
/*
|
|
* Look for a level in in the secondary list that matches. If
|
|
* nothing fits, use the maximum non zero vote
|
|
*/
|
|
|
|
for (j = 0; j < sec_count; j++) {
|
|
if (sec[j] >= level) {
|
|
sindex = j;
|
|
break;
|
|
} else if (sec[j]) {
|
|
sindex = j;
|
|
}
|
|
}
|
|
|
|
/* Construct the vote */
|
|
votes[i] = ((pri[pindex] & 0xffff) << 16) |
|
|
(sindex << 8) | pindex;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* The GMU votes with the RPMh for itself and on behalf of the GPU but we need
|
|
* to construct the list of votes on the CPU and send it over. Query the RPMh
|
|
* voltage levels and build the votes
|
|
*/
|
|
|
|
static int a6xx_gmu_rpmh_votes_init(struct a6xx_gmu *gmu)
|
|
{
|
|
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
|
|
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
|
|
struct msm_gpu *gpu = &adreno_gpu->base;
|
|
int ret;
|
|
|
|
/* Build the GX votes */
|
|
ret = a6xx_gmu_rpmh_arc_votes_init(&gpu->pdev->dev, gmu->gx_arc_votes,
|
|
gmu->gpu_freqs, gmu->nr_gpu_freqs, "gfx.lvl");
|
|
|
|
/* Build the CX votes */
|
|
ret |= a6xx_gmu_rpmh_arc_votes_init(gmu->dev, gmu->cx_arc_votes,
|
|
gmu->gmu_freqs, gmu->nr_gmu_freqs, "cx.lvl");
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int a6xx_gmu_build_freq_table(struct device *dev, unsigned long *freqs,
|
|
u32 size)
|
|
{
|
|
int count = dev_pm_opp_get_opp_count(dev);
|
|
struct dev_pm_opp *opp;
|
|
int i, index = 0;
|
|
unsigned long freq = 1;
|
|
|
|
/*
|
|
* The OPP table doesn't contain the "off" frequency level so we need to
|
|
* add 1 to the table size to account for it
|
|
*/
|
|
|
|
if (WARN(count + 1 > size,
|
|
"The GMU frequency table is being truncated\n"))
|
|
count = size - 1;
|
|
|
|
/* Set the "off" frequency */
|
|
freqs[index++] = 0;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
opp = dev_pm_opp_find_freq_ceil(dev, &freq);
|
|
if (IS_ERR(opp))
|
|
break;
|
|
|
|
dev_pm_opp_put(opp);
|
|
freqs[index++] = freq++;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
static int a6xx_gmu_pwrlevels_probe(struct a6xx_gmu *gmu)
|
|
{
|
|
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
|
|
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
|
|
struct msm_gpu *gpu = &adreno_gpu->base;
|
|
|
|
int ret = 0;
|
|
|
|
/*
|
|
* The GMU handles its own frequency switching so build a list of
|
|
* available frequencies to send during initialization
|
|
*/
|
|
ret = dev_pm_opp_of_add_table(gmu->dev);
|
|
if (ret) {
|
|
DRM_DEV_ERROR(gmu->dev, "Unable to set the OPP table for the GMU\n");
|
|
return ret;
|
|
}
|
|
|
|
gmu->nr_gmu_freqs = a6xx_gmu_build_freq_table(gmu->dev,
|
|
gmu->gmu_freqs, ARRAY_SIZE(gmu->gmu_freqs));
|
|
|
|
/*
|
|
* The GMU also handles GPU frequency switching so build a list
|
|
* from the GPU OPP table
|
|
*/
|
|
gmu->nr_gpu_freqs = a6xx_gmu_build_freq_table(&gpu->pdev->dev,
|
|
gmu->gpu_freqs, ARRAY_SIZE(gmu->gpu_freqs));
|
|
|
|
/* Build the list of RPMh votes that we'll send to the GMU */
|
|
return a6xx_gmu_rpmh_votes_init(gmu);
|
|
}
|
|
|
|
static int a6xx_gmu_clocks_probe(struct a6xx_gmu *gmu)
|
|
{
|
|
int ret = devm_clk_bulk_get_all(gmu->dev, &gmu->clocks);
|
|
|
|
if (ret < 1)
|
|
return ret;
|
|
|
|
gmu->nr_clocks = ret;
|
|
|
|
gmu->core_clk = msm_clk_bulk_get_clock(gmu->clocks,
|
|
gmu->nr_clocks, "gmu");
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev,
|
|
const char *name)
|
|
{
|
|
void __iomem *ret;
|
|
struct resource *res = platform_get_resource_byname(pdev,
|
|
IORESOURCE_MEM, name);
|
|
|
|
if (!res) {
|
|
DRM_DEV_ERROR(&pdev->dev, "Unable to find the %s registers\n", name);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
ret = ioremap(res->start, resource_size(res));
|
|
if (!ret) {
|
|
DRM_DEV_ERROR(&pdev->dev, "Unable to map the %s registers\n", name);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int a6xx_gmu_get_irq(struct a6xx_gmu *gmu, struct platform_device *pdev,
|
|
const char *name, irq_handler_t handler)
|
|
{
|
|
int irq, ret;
|
|
|
|
irq = platform_get_irq_byname(pdev, name);
|
|
|
|
ret = request_irq(irq, handler, IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN, name, gmu);
|
|
if (ret) {
|
|
DRM_DEV_ERROR(&pdev->dev, "Unable to get interrupt %s %d\n",
|
|
name, ret);
|
|
return ret;
|
|
}
|
|
|
|
return irq;
|
|
}
|
|
|
|
void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
|
|
{
|
|
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
|
|
|
|
if (!gmu->initialized)
|
|
return;
|
|
|
|
pm_runtime_force_suspend(gmu->dev);
|
|
|
|
if (!IS_ERR_OR_NULL(gmu->gxpd)) {
|
|
pm_runtime_disable(gmu->gxpd);
|
|
dev_pm_domain_detach(gmu->gxpd, false);
|
|
}
|
|
|
|
iounmap(gmu->mmio);
|
|
gmu->mmio = NULL;
|
|
|
|
a6xx_gmu_memory_free(gmu, gmu->hfi);
|
|
|
|
free_irq(gmu->gmu_irq, gmu);
|
|
free_irq(gmu->hfi_irq, gmu);
|
|
|
|
/* Drop reference taken in of_find_device_by_node */
|
|
put_device(gmu->dev);
|
|
|
|
gmu->initialized = false;
|
|
}
|
|
|
|
int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
|
|
{
|
|
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
|
|
struct platform_device *pdev = of_find_device_by_node(node);
|
|
int ret;
|
|
|
|
if (!pdev)
|
|
return -ENODEV;
|
|
|
|
gmu->dev = &pdev->dev;
|
|
|
|
/* Pass force_dma false to require the DT to set the dma region */
|
|
ret = of_dma_configure(gmu->dev, node, false);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* Fow now, don't do anything fancy until we get our feet under us */
|
|
gmu->idle_level = GMU_IDLE_STATE_ACTIVE;
|
|
|
|
pm_runtime_enable(gmu->dev);
|
|
|
|
/* Get the list of clocks */
|
|
ret = a6xx_gmu_clocks_probe(gmu);
|
|
if (ret)
|
|
goto err_put_device;
|
|
|
|
/* Allocate memory for for the HFI queues */
|
|
gmu->hfi = a6xx_gmu_memory_alloc(gmu, SZ_16K);
|
|
if (IS_ERR(gmu->hfi))
|
|
goto err_memory;
|
|
|
|
/* Allocate memory for the GMU debug region */
|
|
gmu->debug = a6xx_gmu_memory_alloc(gmu, SZ_16K);
|
|
if (IS_ERR(gmu->debug))
|
|
goto err_memory;
|
|
|
|
/* Map the GMU registers */
|
|
gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu");
|
|
if (IS_ERR(gmu->mmio))
|
|
goto err_memory;
|
|
|
|
/* Get the HFI and GMU interrupts */
|
|
gmu->hfi_irq = a6xx_gmu_get_irq(gmu, pdev, "hfi", a6xx_hfi_irq);
|
|
gmu->gmu_irq = a6xx_gmu_get_irq(gmu, pdev, "gmu", a6xx_gmu_irq);
|
|
|
|
if (gmu->hfi_irq < 0 || gmu->gmu_irq < 0)
|
|
goto err_mmio;
|
|
|
|
/*
|
|
* Get a link to the GX power domain to reset the GPU in case of GMU
|
|
* crash
|
|
*/
|
|
gmu->gxpd = dev_pm_domain_attach_by_name(gmu->dev, "gx");
|
|
|
|
/* Get the power levels for the GMU and GPU */
|
|
a6xx_gmu_pwrlevels_probe(gmu);
|
|
|
|
/* Set up the HFI queues */
|
|
a6xx_hfi_init(gmu);
|
|
|
|
gmu->initialized = true;
|
|
|
|
return 0;
|
|
|
|
err_mmio:
|
|
iounmap(gmu->mmio);
|
|
free_irq(gmu->gmu_irq, gmu);
|
|
free_irq(gmu->hfi_irq, gmu);
|
|
err_memory:
|
|
a6xx_gmu_memory_free(gmu, gmu->hfi);
|
|
|
|
ret = -ENODEV;
|
|
|
|
err_put_device:
|
|
/* Drop reference taken in of_find_device_by_node */
|
|
put_device(gmu->dev);
|
|
|
|
return ret;
|
|
}
|