/* * Copyright 2008 Advanced Micro Devices, Inc. * Copyright 2008 Red Hat Inc. * Copyright 2009 Jerome Glisse. * * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Dave Airlie * Alex Deucher * Jerome Glisse */ #include <linux/pci.h> #include <linux/pm_runtime.h> #include <drm/drm_device.h> #include <drm/drm_drv.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h> #include <drm/radeon_drm.h> #include "atom.h" #include "radeon.h" #include "radeon_kms.h" #include "radeon_reg.h" #define RADEON_WAIT_IDLE_TIMEOUT … /* * radeon_driver_irq_handler_kms - irq handler for KMS * * This is the irq handler for the radeon KMS driver (all asics). * radeon_irq_process is a macro that points to the per-asic * irq handler callback. */ static irqreturn_t radeon_driver_irq_handler_kms(int irq, void *arg) { … } /* * Handle hotplug events outside the interrupt handler proper. */ /** * radeon_hotplug_work_func - display hotplug work handler * * @work: work struct * * This is the hot plug event work handler (all asics). * The work gets scheduled from the irq handler if there * was a hot plug interrupt. It walks the connector table * and calls the hotplug handler for each one, then sends * a drm hotplug event to alert userspace. */ static void radeon_hotplug_work_func(struct work_struct *work) { … } static void radeon_dp_work_func(struct work_struct *work) { … } /** * radeon_driver_irq_preinstall_kms - drm irq preinstall callback * * @dev: drm dev pointer * * Gets the hw ready to enable irqs (all asics). * This function disables all interrupt sources on the GPU. */ static void radeon_driver_irq_preinstall_kms(struct drm_device *dev) { … } /** * radeon_driver_irq_postinstall_kms - drm irq preinstall callback * * @dev: drm dev pointer * * Handles stuff to be done after enabling irqs (all asics). * Returns 0 on success. */ static int radeon_driver_irq_postinstall_kms(struct drm_device *dev) { … } /** * radeon_driver_irq_uninstall_kms - drm irq uninstall callback * * @dev: drm dev pointer * * This function disables all interrupt sources on the GPU (all asics). */ static void radeon_driver_irq_uninstall_kms(struct drm_device *dev) { … } static int radeon_irq_install(struct radeon_device *rdev, int irq) { … } static void radeon_irq_uninstall(struct radeon_device *rdev) { … } /** * radeon_msi_ok - asic specific msi checks * * @rdev: radeon device pointer * * Handles asic specific MSI checks to determine if * MSIs should be enabled on a particular chip (all asics). * Returns true if MSIs should be enabled, false if MSIs * should not be enabled. */ static bool radeon_msi_ok(struct radeon_device *rdev) { … } /** * radeon_irq_kms_init - init driver interrupt info * * @rdev: radeon device pointer * * Sets up the work irq handlers, vblank init, MSIs, etc. (all asics). * Returns 0 for success, error for failure. */ int radeon_irq_kms_init(struct radeon_device *rdev) { … } /** * radeon_irq_kms_fini - tear down driver interrupt info * * @rdev: radeon device pointer * * Tears down the work irq handlers, vblank handlers, MSIs, etc. (all asics). */ void radeon_irq_kms_fini(struct radeon_device *rdev) { … } /** * radeon_irq_kms_sw_irq_get - enable software interrupt * * @rdev: radeon device pointer * @ring: ring whose interrupt you want to enable * * Enables the software interrupt for a specific ring (all asics). * The software interrupt is generally used to signal a fence on * a particular ring. */ void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring) { … } /** * radeon_irq_kms_sw_irq_get_delayed - enable software interrupt * * @rdev: radeon device pointer * @ring: ring whose interrupt you want to enable * * Enables the software interrupt for a specific ring (all asics). * The software interrupt is generally used to signal a fence on * a particular ring. */ bool radeon_irq_kms_sw_irq_get_delayed(struct radeon_device *rdev, int ring) { … } /** * radeon_irq_kms_sw_irq_put - disable software interrupt * * @rdev: radeon device pointer * @ring: ring whose interrupt you want to disable * * Disables the software interrupt for a specific ring (all asics). * The software interrupt is generally used to signal a fence on * a particular ring. */ void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring) { … } /** * radeon_irq_kms_pflip_irq_get - enable pageflip interrupt * * @rdev: radeon device pointer * @crtc: crtc whose interrupt you want to enable * * Enables the pageflip interrupt for a specific crtc (all asics). * For pageflips we use the vblank interrupt source. */ void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc) { … } /** * radeon_irq_kms_pflip_irq_put - disable pageflip interrupt * * @rdev: radeon device pointer * @crtc: crtc whose interrupt you want to disable * * Disables the pageflip interrupt for a specific crtc (all asics). * For pageflips we use the vblank interrupt source. */ void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc) { … } /** * radeon_irq_kms_enable_afmt - enable audio format change interrupt * * @rdev: radeon device pointer * @block: afmt block whose interrupt you want to enable * * Enables the afmt change interrupt for a specific afmt block (all asics). */ void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block) { … } /** * radeon_irq_kms_disable_afmt - disable audio format change interrupt * * @rdev: radeon device pointer * @block: afmt block whose interrupt you want to disable * * Disables the afmt change interrupt for a specific afmt block (all asics). */ void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block) { … } /** * radeon_irq_kms_enable_hpd - enable hotplug detect interrupt * * @rdev: radeon device pointer * @hpd_mask: mask of hpd pins you want to enable. * * Enables the hotplug detect interrupt for a specific hpd pin (all asics). */ void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask) { … } /** * radeon_irq_kms_disable_hpd - disable hotplug detect interrupt * * @rdev: radeon device pointer * @hpd_mask: mask of hpd pins you want to disable. * * Disables the hotplug detect interrupt for a specific hpd pin (all asics). */ void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask) { … } /** * radeon_irq_kms_set_irq_n_enabled - helper for updating interrupt enable registers * * @rdev: radeon device pointer * @reg: the register to write to enable/disable interrupts * @mask: the mask that enables the interrupts * @enable: whether to enable or disable the interrupt register * @name: the name of the interrupt register to print to the kernel log * @n: the number of the interrupt register to print to the kernel log * * Helper for updating the enable state of interrupt registers. Checks whether * or not the interrupt matches the enable state we want. If it doesn't, then * we update it and print a debugging message to the kernel log indicating the * new state of the interrupt register. * * Used for updating sequences of interrupts registers like HPD1, HPD2, etc. */ void radeon_irq_kms_set_irq_n_enabled(struct radeon_device *rdev, u32 reg, u32 mask, bool enable, const char *name, unsigned n) { … }