-/* $OpenBSD: drmP.h,v 1.194 2015/04/17 00:54:41 jsg Exp $ */
+/* $OpenBSD: drmP.h,v 1.195 2015/04/18 14:47:34 jsg Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
#define DRM_SUSER(p) (suser(p, 0) == 0)
#define DRM_MTRR_WC MDF_WRITECOMBINE
+#define DRM_WAKEUP(x) wakeup(x)
+
extern int ticks;
#define drm_msleep(x, msg) mdelay(x)
-/* $OpenBSD: drm_atomic.h,v 1.11 2013/10/01 20:06:57 kettenis Exp $ */
+/* $OpenBSD: drm_atomic.h,v 1.12 2015/04/18 14:47:34 jsg Exp $ */
/**
* \file drm_atomic.h
* Atomic operations used in the DRM which may or may not be provided by the OS.
/* FIXME */
#define atomic_set_int(p, bits) atomic_setbits_int(p,bits)
#define atomic_clear_int(p, bits) atomic_clearbits_int(p,bits)
+#define atomic_clear_mask(bits, p) atomic_clearbits_int(p,bits)
#define atomic_fetchadd_int(p, n) __sync_fetch_and_add(p, n)
#define atomic_fetchsub_int(p, n) __sync_fetch_and_sub(p, n)
-/* $OpenBSD: drm_edid.c,v 1.13 2015/04/18 11:05:32 jsg Exp $ */
+/* $OpenBSD: drm_edid.c,v 1.14 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright (c) 2006 Luc Verhaegen (quirks list)
* Copyright (c) 2007-2008 Intel Corporation
return NULL;
if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
- timing->pixel_clock = htole16(1088);
+ timing->pixel_clock = cpu_to_le16(1088);
- mode->clock = letoh16(timing->pixel_clock) * 10;
+ mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
mode->hdisplay = hactive;
mode->hsync_start = mode->hdisplay + hsync_offset;
const u8 empty[3] = { 0, 0, 0 };
for (i = 0; i < 4; i++) {
- int width, height;
+ int uninitialized_var(width), height;
cvt = &(timing->data.other_data.data.cvt[i]);
if (!memcmp(cvt->code, empty, 3))
-/* $OpenBSD: drm_irq.c,v 1.63 2015/04/15 09:48:19 kettenis Exp $ */
+/* $OpenBSD: drm_irq.c,v 1.64 2015/04/18 14:47:34 jsg Exp $ */
/**
* \file drm_irq.c
* IRQ support
if (dev->num_crtcs) {
spin_lock_irqsave(&dev->vbl_lock, irqflags);
for (i = 0; i < dev->num_crtcs; i++) {
- wakeup(&dev->vbl_queue[i]);
+ DRM_WAKEUP(&dev->vbl_queue[i]);
dev->vblank_enabled[i] = 0;
dev->last_vblank[i] =
- dev->driver->get_vblank_counter(dev, i);
+ dev->driver->get_vblank_counter(dev, i);
}
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
}
* line duration, frame duration and pixel duration in
* nanoseconds:
*/
- pixeldur_ns = (s64) 1000000000 / dotclock;
- linedur_ns = (s64) ((u64) crtc->hwmode.crtc_htotal *
- 1000000000) / dotclock;
+ pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
+ linedur_ns = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal *
+ 1000000000), dotclock);
framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns;
} else
DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n",
(drm_vblank_offdelay > 0))
timeout_add_msec(&dev->vblank_disable_timer, drm_vblank_offdelay);
}
+EXPORT_SYMBOL(drm_vblank_put);
/**
* drm_vblank_off - disable vblank events on a CRTC
spin_lock_irqsave(&dev->vbl_lock, irqflags);
vblank_disable_and_save(dev, crtc);
- wakeup(&dev->vbl_queue[crtc]);
+ DRM_WAKEUP(&dev->vbl_queue[crtc]);
list = &dev->vbl_events;
/* Send any queued vblank events, lest the natives grow disquiet */
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
}
+EXPORT_SYMBOL(drm_vblank_off);
/**
* drm_vblank_pre_modeset - account for vblanks across mode sets
crtc, (int) diff_ns);
}
- wakeup(&dev->vbl_queue[crtc]);
+ DRM_WAKEUP(&dev->vbl_queue[crtc]);
drm_handle_vblank_events(dev, crtc);
spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
-/* $OpenBSD: drm_linux.h,v 1.26 2015/04/18 11:41:28 jsg Exp $ */
+/* $OpenBSD: drm_linux.h,v 1.27 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright (c) 2013, 2014 Mark Kettenis
*
#define __must_check
#define __init
+#define uninitialized_var(x) x
+
#if BYTE_ORDER == BIG_ENDIAN
#define __BIG_ENDIAN
#else
#define pr_fmt(fmt) fmt
#endif
+#define printk_once(fmt, arg...) ({ \
+ static int __warned; \
+ if (!__warned) { \
+ printf(fmt, ## arg); \
+ __warned = 1; \
+ } \
+})
+
#define printk(fmt, arg...) printf(fmt, ## arg)
#define pr_warn(fmt, arg...) printf(pr_fmt(fmt), ## arg)
+#define pr_warn_once(fmt, arg...) printk_once(pr_fmt(fmt), ## arg)
#define pr_notice(fmt, arg...) printf(pr_fmt(fmt), ## arg)
#define pr_crit(fmt, arg...) printf(pr_fmt(fmt), ## arg)
#define pr_err(fmt, arg...) printf(pr_fmt(fmt), ## arg)
#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
#endif
+typedef struct rwlock rwlock_t;
typedef struct mutex spinlock_t;
#define DEFINE_SPINLOCK(x) struct mutex x
#define msecs_to_jiffies(x) (((int64_t)(x)) * hz / 1000)
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
#define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0)
+#define get_seconds() time_second
+#define getrawmonotonic(x) nanouptime(x)
static inline void
set_normalized_timespec(struct timespec *ts, time_t sec, int64_t nsec)
return (x / y);
}
+static inline uint64_t
+div64_u64(uint64_t x, uint64_t y)
+{
+ return (x / y);
+}
+
static inline int64_t
abs64(int64_t x)
{
#define page_to_phys(page) (VM_PAGE_TO_PHYS(page))
#define page_to_pfn(pp) (VM_PAGE_TO_PHYS(pp) / PAGE_SIZE)
#define offset_in_page(off) ((off) & PAGE_MASK)
+#define set_page_dirty(page) atomic_clearbits_int(&page->pg_flags, PG_CLEAN)
typedef int pgprot_t;
#define pgprot_val(v) (v)
return (0);
}
+static inline int
+power_supply_is_system_supplied(void)
+{
+ /* XXX return 0 if on battery */
+ return (1);
+}
+
#ifdef __macppc__
static __inline int
of_machine_is_compatible(const char *model)
-/* $OpenBSD: drm_mem_util.h,v 1.3 2015/04/11 04:36:10 jsg Exp $ */
+/* $OpenBSD: drm_mem_util.h,v 1.4 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright © 2008 Intel Corporation
*
free(ptr, M_DRM, 0);
#ifdef notyet
if (!is_vmalloc_addr(ptr))
- return free(ptr, M_DRM, 0);
+ return kfree(ptr);
vfree(ptr);
#endif
-/* $OpenBSD: drm_mm.h,v 1.2 2013/09/12 13:03:31 jsg Exp $ */
+/* $OpenBSD: drm_mm.h,v 1.3 2015/04/18 14:47:34 jsg Exp $ */
/**************************************************************************
*
* Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX. USA.
struct drm_mm_node head_node;
struct list_head unused_nodes;
int num_unused;
- struct mutex unused_lock;
+ spinlock_t unused_lock;
unsigned int scan_check_range : 1;
unsigned scan_alignment;
unsigned long scan_color;
-/* $OpenBSD: i915_dma.c,v 1.20 2015/04/17 00:54:42 jsg Exp $ */
+/* $OpenBSD: i915_dma.c,v 1.21 2015/04/18 14:47:34 jsg Exp $ */
/* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
*/
/*
if (ret)
goto cleanup_vga_switcheroo;
#endif
+
intel_modeset_init(dev);
ret = i915_gem_init(dev);
/* We're off and running w/KMS */
dev_priv->mm.suspended = 0;
- return (0);
+ return 0;
cleanup_irq:
drm_irq_uninstall(dev);
DRM_ERROR("failed to idle hardware: %d\n", ret);
}
-int
-i915_driver_open(struct drm_device *dev, struct drm_file *file)
+int i915_driver_open(struct drm_device *dev, struct drm_file *file)
{
struct drm_i915_file_private *file_priv;
-/* $OpenBSD: i915_drv.c,v 1.82 2015/04/18 11:41:28 jsg Exp $ */
+/* $OpenBSD: i915_drv.c,v 1.83 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
void i915_alloc_ifp(struct inteldrm_softc *, struct pci_attach_args *);
void i965_alloc_ifp(struct inteldrm_softc *, struct pci_attach_args *);
-int i915_drm_freeze(struct drm_device *);
-int __i915_drm_thaw(struct drm_device *);
-int i915_drm_thaw(struct drm_device *);
-
#define INTEL_VGA_DEVICE(id, info) { \
.class = PCI_CLASS_DISPLAY << 16, \
.class_mask = 0xff0000, \
.has_force_wake = 1,
};
-const static struct drm_pcidev inteldrm_pciidlist[] = { /* aka */
+static const struct drm_pcidev inteldrm_pciidlist[] = { /* aka */
INTEL_VGA_DEVICE(0x3577, &intel_i830_info), /* I830_M */
INTEL_VGA_DEVICE(0x2562, &intel_845g_info), /* 845_G */
INTEL_VGA_DEVICE(0x3582, &intel_i85x_info), /* I855_GM */
inteldrm_pciidlist));
}
-bool
-i915_semaphore_is_enabled(struct drm_device *dev)
+bool i915_semaphore_is_enabled(struct drm_device *dev)
{
if (INTEL_INFO(dev)->gen < 6)
return 0;
return 1;
}
-int
-i915_drm_freeze(struct drm_device *dev)
+static int i915_drm_freeze(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
return 0;
}
-int
-__i915_drm_thaw(struct drm_device *dev)
+static int __i915_drm_thaw(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
int error = 0;
return error;
}
-int
-i915_drm_thaw(struct drm_device *dev)
+static int i915_drm_thaw(struct drm_device *dev)
{
int error = 0;
i915_gem_reset(dev);
ret = -ENODEV;
- if (time_second - dev_priv->last_gpu_reset < 5)
+ if (get_seconds() - dev_priv->last_gpu_reset < 5)
DRM_ERROR("GPU hanging too fast, declaring wedged!\n");
else
ret = intel_gpu_reset(dev);
- dev_priv->last_gpu_reset = time_second;
+ dev_priv->last_gpu_reset = get_seconds();
if (ret) {
DRM_ERROR("Failed to reset chip.\n");
mutex_unlock(&dev->struct_mutex);
__i915_write(32, l)
__i915_write(64, q)
#undef __i915_write
+
+static const struct register_whitelist {
+ uint64_t offset;
+ uint32_t size;
+ uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */
+} whitelist[] = {
+ { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0xF0 },
+};
+
+int i915_reg_read_ioctl(struct drm_device *dev,
+ void *data, struct drm_file *file)
+{
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ struct drm_i915_reg_read *reg = data;
+ struct register_whitelist const *entry = whitelist;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(whitelist); i++, entry++) {
+ if (entry->offset == reg->offset &&
+ (1 << INTEL_INFO(dev)->gen & entry->gen_bitmask))
+ break;
+ }
+
+ if (i == ARRAY_SIZE(whitelist))
+ return -EINVAL;
+
+ switch (entry->size) {
+ case 8:
+ reg->val = I915_READ64(reg->offset);
+ break;
+ case 4:
+ reg->val = I915_READ(reg->offset);
+ break;
+ case 2:
+ reg->val = I915_READ16(reg->offset);
+ break;
+ case 1:
+ reg->val = I915_READ8(reg->offset);
+ break;
+ default:
+ WARN_ON(1);
+ return -EINVAL;
+ }
+
+ return 0;
+}
-/* $OpenBSD: i915_gem.c,v 1.93 2015/04/18 11:41:28 jsg Exp $ */
+/* $OpenBSD: i915_gem.c,v 1.94 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
#ifdef __linux__
page = sg_page(sg);
- page_do_bit17_swizzling = obj_do_bit17_swizzling &&
- (page_to_phys(page) & (1 << 17)) != 0;
#else
page = obj->pages[i];
- page_do_bit17_swizzling = obj_do_bit17_swizzling &&
- (VM_PAGE_TO_PHYS(page) & (1 << 17)) != 0;
#endif
+ page_do_bit17_swizzling = obj_do_bit17_swizzling &&
+ (page_to_phys(page) & (1 << 17)) != 0;
ret = shmem_pread_fast(page, shmem_page_offset, page_length,
user_data, page_do_bit17_swizzling,
#ifdef __linux__
page = sg_page(sg);
- page_do_bit17_swizzling = obj_do_bit17_swizzling &&
- (page_to_phys(page) & (1 << 17)) != 0;
#else
page = obj->pages[i];
- page_do_bit17_swizzling = obj_do_bit17_swizzling &&
- (VM_PAGE_TO_PHYS(page) & (1 << 17)) != 0;
#endif
+ page_do_bit17_swizzling = obj_do_bit17_swizzling &&
+ (page_to_phys(page) & (1 << 17)) != 0;
ret = shmem_pwrite_fast(page, shmem_page_offset, page_length,
user_data, page_do_bit17_swizzling,
mutex_lock(&dev->struct_mutex);
next_page:
-#ifdef __linux__
set_page_dirty(page);
+#ifdef __linux__
mark_page_accessed(page);
-#else
- atomic_clearbits_int(&page->pg_flags, PG_CLEAN);
#endif
if (ret)
return -ENODEV;
/* Record current time in case interrupted by signal, or wedged * */
- nanouptime(&before);
+ getrawmonotonic(&before);
#define EXIT_COND \
(i915_seqno_passed(ring->get_seqno(ring, false), seqno) || \
end = ret;
} while (end == 0 && wait_forever);
- nanouptime(&now);
+ getrawmonotonic(&now);
ring->irq_put(ring);
trace_i915_gem_request_wait_end(ring, seqno);
-/* $OpenBSD: i915_gem_tiling.c,v 1.17 2015/04/08 02:28:13 jsg Exp $ */
+/* $OpenBSD: i915_gem_tiling.c,v 1.18 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
for (i = 0; i < page_count; i++) {
struct vm_page *page = obj->pages[i];
- char new_bit_17 = VM_PAGE_TO_PHYS(page) >> 17;
+ char new_bit_17 = page_to_phys(page) >> 17;
if ((new_bit_17 & 0x1) !=
(test_bit(i, obj->bit_17) != 0)) {
i915_gem_swizzle_page(page);
- atomic_clearbits_int(&page->pg_flags, PG_CLEAN);
+ set_page_dirty(page);
}
}
}
for (i = 0; i < page_count; i++) {
struct vm_page *page = obj->pages[i];
- if (VM_PAGE_TO_PHYS(page) & (1 << 17))
+ if (page_to_phys(page) & (1 << 17))
set_bit(i, obj->bit_17);
else
clear_bit(i, obj->bit_17);
-/* $OpenBSD: i915_suspend.c,v 1.5 2015/02/10 01:39:32 jsg Exp $ */
+/* $OpenBSD: i915_suspend.c,v 1.6 2015/04/18 14:47:34 jsg Exp $ */
/*
*
* Copyright 2008 (c) Intel Corporation
dev_priv->regfile.saveDSPARB = I915_READ(DSPARB);
/* This is only meaningful in non-KMS mode */
- /* Don't save them in KMS mode */
+ /* Don't regfile.save them in KMS mode */
i915_save_modeset_reg(dev);
/* LVDS state */
dev_priv->regfile.savePIPEA_DP_LINK_N = I915_READ(_PIPEA_DP_LINK_N);
dev_priv->regfile.savePIPEB_DP_LINK_N = I915_READ(_PIPEB_DP_LINK_N);
}
- /* FIXME: save TV & SDVO state */
+ /* FIXME: regfile.save TV & SDVO state */
}
- /* Only save FBC state on the platform that supports FBC */
+ /* Only regfile.save FBC state on the platform that supports FBC */
if (I915_HAS_FBC(dev)) {
if (HAS_PCH_SPLIT(dev)) {
dev_priv->regfile.saveDPFC_CB_BASE = I915_READ(ILK_DPFC_CB_BASE);
-/* $OpenBSD: intel_ddi.c,v 1.13 2015/02/12 04:56:03 kettenis Exp $ */
+/* $OpenBSD: intel_ddi.c,v 1.14 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright © 2012 Intel Corporation
*
return PORT_E;
} else {
- panic("Invalid DDI encoder type %d\n", type);
+ DRM_ERROR("Invalid DDI encoder type %d\n", type);
+ BUG();
}
}
struct intel_dp *intel_dp = &intel_dig_port->dp;
struct drm_i915_private *dev_priv = encoder->dev->dev_private;
enum port port = intel_dig_port->port;
- uint32_t val;
bool wait = false;
+ uint32_t val;
if (I915_READ(DP_TP_CTL(port)) & DP_TP_CTL_ENABLE) {
val = I915_READ(DDI_BUF_CTL(port));
-/* $OpenBSD: intel_display.c,v 1.49 2015/04/12 17:10:07 kettenis Exp $ */
+/* $OpenBSD: intel_display.c,v 1.50 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright © 2006-2007 Intel Corporation
*
DRM_ERROR("Y tiled not allowed for scan out buffers\n");
return -EINVAL;
default:
-#ifdef notyet
BUG();
-#else
- DRM_ERROR("invalid tiling mode %d", obj->tiling_mode);
- return -EINVAL;
-#endif
}
dev_priv->mm.interruptible = false;
obj = work->old_fb_obj;
- atomic_clear_int(&obj->pending_flip, 1 << intel_crtc->plane);
+ atomic_clear_mask(1 << intel_crtc->plane,
+ &obj->pending_flip);
wake_up(&dev_priv->pending_flip_queue);
task_add(systq, &work->task);
-/* $OpenBSD: intel_opregion.c,v 1.7 2015/04/12 05:31:23 jsg Exp $ */
+/* $OpenBSD: intel_opregion.c,v 1.8 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright 2008 Intel Corporation <hong.liu@intel.com>
* Copyright 2008 Red Hat <mjg@redhat.com>
#endif
}
+static void intel_setup_cadls(struct drm_device *dev)
+{
+#ifdef notyet
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ struct intel_opregion *opregion = &dev_priv->opregion;
+ int i = 0;
+ u32 disp_id;
+
+ /* Initialize the CADL field by duplicating the DIDL values.
+ * Technically, this is not always correct as display outputs may exist,
+ * but not active. This initialization is necessary for some Clevo
+ * laptops that check this field before processing the brightness and
+ * display switching hotkeys. Just like DIDL, CADL is NULL-terminated if
+ * there are less than eight devices. */
+ do {
+ disp_id = ioread32(&opregion->acpi->didl[i]);
+ iowrite32(disp_id, &opregion->acpi->cadl[i]);
+ } while (++i < 8 && disp_id != 0);
+#endif
+}
+
void intel_opregion_init(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
return;
if (opregion->acpi) {
- if (drm_core_check_feature(dev, DRIVER_MODESET))
+ if (drm_core_check_feature(dev, DRIVER_MODESET)) {
intel_didl_outputs(dev);
+ intel_setup_cadls(dev);
+ }
/* Notify BIOS we are ready to handle ACPI video ext notifs.
* Right now, all the events are handled by the ACPI video module.
-/* $OpenBSD: intel_panel.c,v 1.9 2015/04/18 11:05:32 jsg Exp $ */
+/* $OpenBSD: intel_panel.c,v 1.10 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright © 2006-2010 Intel Corporation
* Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
/* XXX add code here to query mode clock or hardware clock
* and program max PWM appropriately.
*/
-#ifdef notyet
pr_warn_once("fixme: max PWM is zero\n");
-#endif
return 1;
}
-/* $OpenBSD: intel_pm.c,v 1.33 2015/04/18 11:41:29 jsg Exp $ */
+/* $OpenBSD: intel_pm.c,v 1.34 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright © 2012 Intel Corporation
*
I915_READ(0x112e0);
dev_priv->ips.last_time1 = jiffies_to_msecs(ticks);
dev_priv->ips.last_count2 = I915_READ(0x112f4);
- nanouptime(&dev_priv->ips.last_time2);
+ getrawmonotonic(&dev_priv->ips.last_time2);
spin_unlock_irq(&mchdev_lock);
}
assert_spin_locked(&mchdev_lock);
- nanouptime(&now);
+ getrawmonotonic(&now);
timespecsub(&now, &dev_priv->ips.last_time2, &diff1);
/* Don't divide by 0 */
-/* $OpenBSD: atom.c,v 1.6 2015/02/11 07:01:37 jsg Exp $ */
+/* $OpenBSD: atom.c,v 1.7 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
*
};
static int atom_def_dst[8] = { 0, 0, 1, 2, 0, 1, 2, 3 };
-extern int ticks;
-
static int debug_depth = 0;
#ifdef ATOM_DEBUG
static void debug_print_spaces(int n)
-/* $OpenBSD: atombios_dp.c,v 1.5 2015/04/06 10:56:37 jsg Exp $ */
+/* $OpenBSD: atombios_dp.c,v 1.6 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright 2007-8 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
};
#endif
-void radeon_atom_copy_swap(u8 *, u8 *, u8, bool);
-
/***** radeon AUX functions *****/
/* Atom needs data in little endian format
-/* $OpenBSD: atombios_encoders.c,v 1.8 2014/08/08 16:35:56 jsg Exp $ */
+/* $OpenBSD: atombios_encoders.c,v 1.9 2015/04/18 14:47:34 jsg Exp $ */
/*
* Copyright 2007-11 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
extern int atom_debug;
-u8 atombios_get_backlight_level(struct radeon_encoder *);
-void atombios_set_backlight_level(struct radeon_encoder *, u8);
-void radeon_atom_backlight_init(struct radeon_encoder *);
-void radeon_add_atom_encoder(struct drm_device *, uint32_t,
- uint32_t, u16);
-
static u8
radeon_atom_get_backlight_level_from_reg(struct radeon_device *rdev)
{
-/* $OpenBSD: evergreen.c,v 1.18 2015/04/06 14:10:59 jsg Exp $ */
+/* $OpenBSD: evergreen.c,v 1.19 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2010 Advanced Micro Devices, Inc.
*
void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
extern void cayman_cp_int_cntl_setup(struct radeon_device *rdev,
int ring, u32 cp_int_cntl);
-void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev);
-u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev);
-void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save);
-void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save);
-void evergreen_mc_program(struct radeon_device *rdev);
-int evergreen_mc_init(struct radeon_device *rdev);
-void evergreen_irq_suspend(struct radeon_device *rdev);
void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw,
unsigned *bankh, unsigned *mtaspect,
-/* $OpenBSD: evergreen_blit_kms.c,v 1.2 2015/04/08 04:03:06 jsg Exp $ */
+/* $OpenBSD: evergreen_blit_kms.c,v 1.3 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2010 Advanced Micro Devices, Inc.
*
#include "cayman_blit_shaders.h"
#include "radeon_blit_common.h"
-int evergreen_blit_init(struct radeon_device *rdev);
-
/* emits 17 */
static void
set_render_target(struct radeon_device *rdev, int format,
-/* $OpenBSD: evergreen_cs.c,v 1.5 2015/04/06 14:32:55 jsg Exp $ */
+/* $OpenBSD: evergreen_cs.c,v 1.6 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2010 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
struct radeon_cs_reloc **cs_reloc);
static int evergreen_cs_packet_next_reloc(struct radeon_cs_parser *p,
struct radeon_cs_reloc **cs_reloc);
-int evergreen_cs_parse(struct radeon_cs_parser *p);
-int evergreen_dma_cs_parse(struct radeon_cs_parser *p);
-int evergreen_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib);
-int evergreen_dma_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib);
struct evergreen_cs_track {
u32 group_size;
-/* $OpenBSD: ni.c,v 1.9 2015/02/11 07:01:37 jsg Exp $ */
+/* $OpenBSD: ni.c,v 1.10 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2010 Advanced Micro Devices, Inc.
*
extern void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
extern void si_rlc_fini(struct radeon_device *rdev);
extern int si_rlc_init(struct radeon_device *rdev);
-void cayman_cp_int_cntl_setup(struct radeon_device *rdev, int ring, u32 cp_int_cntl);
#define EVERGREEN_PFP_UCODE_SIZE 1120
#define EVERGREEN_PM4_UCODE_SIZE 1376
-/* $OpenBSD: r600_blit_kms.c,v 1.2 2015/04/08 04:03:06 jsg Exp $ */
+/* $OpenBSD: r600_blit_kms.c,v 1.3 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2009 Advanced Micro Devices, Inc.
* Copyright 2009 Red Hat Inc.
#include "r600_blit_shaders.h"
#include "radeon_blit_common.h"
-int r600_blit_init(struct radeon_device *rdev);
-void r600_blit_fini(struct radeon_device *rdev);
-int r600_blit_prepare_copy(struct radeon_device *rdev, unsigned num_gpu_pages,
- struct radeon_fence **fence, struct radeon_sa_bo **vb,
- struct radeon_semaphore **sem);
-void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence **fence,
- struct radeon_sa_bo *vb, struct radeon_semaphore *sem);
-void r600_kms_blit_copy(struct radeon_device *rdev,
- u64 src_gpu_addr, u64 dst_gpu_addr,
- unsigned num_gpu_pages,
- struct radeon_sa_bo *vb);
-
/* emits 21 on rv770+, 23 on r600 */
static void
set_render_target(struct radeon_device *rdev, int format,
-/* $OpenBSD: r600_cs.c,v 1.6 2015/04/06 14:32:55 jsg Exp $ */
+/* $OpenBSD: r600_cs.c,v 1.7 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
static next_reloc_t r600_cs_packet_next_reloc = &r600_cs_packet_next_reloc_mm;
extern void r600_cs_legacy_get_tiling_conf(struct drm_device *dev, u32 *npipes, u32 *nbanks, u32 *group_size);
-int r600_cs_parse(struct radeon_cs_parser *p);
-int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp,
- unsigned family, u32 *ib, int *l);
-void r600_cs_legacy_init(void);
-int r600_dma_cs_next_reloc(struct radeon_cs_parser *p,
- struct radeon_cs_reloc **cs_reloc);
-int r600_dma_cs_parse(struct radeon_cs_parser *p);
struct r600_cs_track {
/* configuration we miror so that we use same code btw kms/ums */
-/* $OpenBSD: radeon.h,v 1.14 2015/04/12 03:54:10 jsg Exp $ */
+/* $OpenBSD: radeon.h,v 1.15 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
* situation the init path must succeed up to the memory controller
* initialization point. Failure before this point are considered as
* fatal error. Here is the init callchain :
- * radeon_device_init perform common structure, rwlock initialization
+ * radeon_device_init perform common structure, mutex initialization
* asic_init setup the GPU memory layout and perform all
* one time initialization (failure in this
* function are considered fatal)
-/* $OpenBSD: radeon_atombios.c,v 1.6 2014/04/07 06:43:11 jsg Exp $ */
+/* $OpenBSD: radeon_atombios.c,v 1.7 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2007-8 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
/* local */
static int radeon_atom_get_max_vddc(struct radeon_device *rdev, u8 voltage_type,
u16 voltage_id, u16 *voltage);
-bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
- struct drm_display_mode *mode);
-uint32_t radeon_atom_get_engine_clock(struct radeon_device *rdev);
-uint32_t radeon_atom_get_memory_clock(struct radeon_device *rdev);
-void radeon_atom_set_engine_clock(struct radeon_device *rdev, uint32_t eng_clock);
-void radeon_atom_set_memory_clock(struct radeon_device *rdev, uint32_t mem_clock);
-void radeon_atombios_connected_scratch_regs(struct drm_connector *connector,
- struct drm_encoder *encoder, bool connected);
union atom_supported_devices {
struct _ATOM_SUPPORTED_DEVICES_INFO info;
-/* $OpenBSD: radeon_benchmark.c,v 1.3 2015/04/06 07:38:49 jsg Exp $ */
+/* $OpenBSD: radeon_benchmark.c,v 1.4 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2009 Jerome Glisse.
*
#define RADEON_BENCHMARK_ITERATIONS 1024
#define RADEON_BENCHMARK_COMMON_MODES_N 17
-extern int ticks;
-
static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size,
uint64_t saddr, uint64_t daddr,
int flag, int n)
-/* $OpenBSD: radeon_clocks.c,v 1.2 2014/07/03 18:58:21 kettenis Exp $ */
+/* $OpenBSD: radeon_clocks.c,v 1.3 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
#include <dev/ofw/openfirm.h>
#endif
-uint32_t radeon_legacy_get_engine_clock(struct radeon_device *);
-uint32_t radeon_legacy_get_memory_clock(struct radeon_device *);
-void radeon_legacy_set_engine_clock(struct radeon_device *, uint32_t);
-
/* 10 khz */
uint32_t radeon_legacy_get_engine_clock(struct radeon_device *rdev)
{
-/* $OpenBSD: radeon_combios.c,v 1.7 2015/04/08 03:21:13 jsg Exp $ */
+/* $OpenBSD: radeon_combios.c,v 1.8 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2004 ATI Technologies Inc., Markham, Ontario
* Copyright 2007-8 Advanced Micro Devices, Inc.
radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum,
uint32_t supported_device);
-
-void radeon_combios_connected_scratch_regs(struct drm_connector *connector,
- struct drm_encoder *encoder,
- bool connected);
-
/* old legacy ATI BIOS routines */
/* COMBIOS table offsets */
-/* $OpenBSD: radeon_connectors.c,v 1.5 2015/04/06 09:23:19 jsg Exp $ */
+/* $OpenBSD: radeon_connectors.c,v 1.6 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2007-8 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
radeon_atombios_connected_scratch_regs(struct drm_connector *connector,
struct drm_encoder *encoder,
bool connected);
-void radeon_add_atom_connector(struct drm_device *, uint32_t, uint32_t, int,
- struct radeon_i2c_bus_rec *, uint32_t, uint16_t, struct radeon_hpd *,
- struct radeon_router *);
-void radeon_add_legacy_connector(struct drm_device *, uint32_t, uint32_t, int,
- struct radeon_i2c_bus_rec *, uint16_t, struct radeon_hpd *);
void radeon_connector_hotplug(struct drm_connector *connector)
{
-/* $OpenBSD: radeon_encoders.c,v 1.1 2013/08/12 04:11:53 jsg Exp $ */
+/* $OpenBSD: radeon_encoders.c,v 1.2 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2007-8 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
struct drm_connector *drm_connector);
-uint32_t radeon_get_encoder_enum(struct drm_device *, uint32_t, uint8_t);
-void radeon_link_encoder_connector(struct drm_device *);
static uint32_t radeon_encoder_clones(struct drm_encoder *encoder)
{
-/* $OpenBSD: radeon_fence.c,v 1.7 2015/04/18 11:41:29 jsg Exp $ */
+/* $OpenBSD: radeon_fence.c,v 1.8 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2009 Jerome Glisse.
* All Rights Reserved.
#include <dev/pci/drm/refcount.h>
-extern int ticks;
-
/*
* Fences
* Fences mark an event in the GPUs pipeline and are used
-/* $OpenBSD: radeon_gem.c,v 1.6 2015/02/11 07:01:37 jsg Exp $ */
+/* $OpenBSD: radeon_gem.c,v 1.7 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
#include <dev/pci/drm/radeon_drm.h>
#include "radeon.h"
-int radeon_gem_object_init(struct drm_gem_object *);
-void radeon_gem_object_free(struct drm_gem_object *);
-int radeon_gem_set_domain(struct drm_gem_object *, uint32_t, uint32_t);
-int radeon_gem_object_open(struct drm_gem_object *, struct drm_file *);
-void radeon_gem_object_close(struct drm_gem_object *, struct drm_file *);
-
int radeon_gem_object_init(struct drm_gem_object *obj)
{
BUG();
}
if (args->offset < RADEON_VA_RESERVED_SIZE) {
- DRM_ERROR("offset 0x%lX is in reserved area 0x%X\n",
+ dev_err(&dev->pdev->dev,
+ "offset 0x%lX is in reserved area 0x%X\n",
(unsigned long)args->offset,
RADEON_VA_RESERVED_SIZE);
args->operation = RADEON_VA_RESULT_ERROR;
-/* $OpenBSD: radeon_irq_kms.c,v 1.8 2015/04/06 07:38:49 jsg Exp $ */
+/* $OpenBSD: radeon_irq_kms.c,v 1.9 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
* radeon_irq_process is a macro that points to the per-asic
* irq handler callback.
*/
-int
-radeon_driver_irq_handler_kms(void *arg)
+irqreturn_t radeon_driver_irq_handler_kms(void *arg)
{
struct drm_device *dev = arg;
struct radeon_device *rdev = dev->dev_private;
-/* $OpenBSD: radeon_pm.c,v 1.11 2015/04/06 07:38:49 jsg Exp $ */
+/* $OpenBSD: radeon_pm.c,v 1.12 2015/04/18 14:47:35 jsg Exp $ */
/*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
static void radeon_pm_update_profile(struct radeon_device *rdev);
static void radeon_pm_set_clocks(struct radeon_device *rdev);
-extern int ticks;
-
int radeon_pm_get_type_index(struct radeon_device *rdev,
enum radeon_pm_state_type ps_type,
int instance)
}
}
-static int
-power_supply_is_system_supplied(void)
-{
- /* XXX return 0 if on battery */
- return (1);
-}
-
static void radeon_pm_update_profile(struct radeon_device *rdev)
{
switch (rdev->pm.profile) {
-/* $OpenBSD: radeon_ring.c,v 1.6 2015/02/10 06:19:36 jsg Exp $ */
+/* $OpenBSD: radeon_ring.c,v 1.7 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
#include "radeon.h"
#include "atom.h"
-extern int ticks;
-
/*
* IB
* IBs (Indirect Buffers) and areas of GPU accessible memory where
-/* $OpenBSD: rv770.c,v 1.6 2015/04/06 14:10:59 jsg Exp $ */
+/* $OpenBSD: rv770.c,v 1.7 2015/04/18 14:47:35 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
/* x2 cards have a special sequence */
if (ASIC_IS_X2(rdev))
return;
-
+
ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask);
if (ret != 0)
return;
-/* $OpenBSD: ttm_bo_api.h,v 1.3 2015/04/12 03:54:10 jsg Exp $ */
+/* $OpenBSD: ttm_bo_api.h,v 1.4 2015/04/18 14:47:35 jsg Exp $ */
/**************************************************************************
*
* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
*
* @bdev: Pointer to the buffer object device structure.
* @type: The bo type.
- * @destroy: Destruction function. If NULL, free is used.
+ * @destroy: Destruction function. If NULL, kfree is used.
* @num_pages: Actual number of pages.
* @addr_space_offset: Address space offset.
* @acc_size: Accounted size for this object.
* point to the shmem object backing a GEM object if TTM is used to back a
* GEM user interface.
* @acc_size: Accounted size for this object.
- * @destroy: Destroy function. Use NULL for free().
+ * @destroy: Destroy function. Use NULL for kfree().
*
* This function initializes a pre-allocated struct ttm_buffer_object.
* As this object may be part of a larger structure, this function,
* enables driver-specific objects derived from a ttm_buffer_object.
* On successful return, the object kref and list_kref are set to 1.
* If a failure occurs, the function will call the @destroy function, or
- * free() if @destroy is NULL. Thus, after a failure, dereferencing @bo is
+ * kfree() if @destroy is NULL. Thus, after a failure, dereferencing @bo is
* illegal and will likely cause memory corruption.
*
* Returns
* @p_bo: On successful completion *p_bo points to the created object.
*
* This function allocates a ttm_buffer_object, and then calls ttm_bo_init
- * on that object. The destroy function is set to free().
+ * on that object. The destroy function is set to kfree().
* Returns
* -ENOMEM: Out of memory.
* -EINVAL: Invalid placement flags.
-/* $OpenBSD: ttm_bo_driver.h,v 1.4 2015/04/08 02:28:13 jsg Exp $ */
+/* $OpenBSD: ttm_bo_driver.h,v 1.5 2015/04/18 14:47:35 jsg Exp $ */
/**************************************************************************
*
* Copyright (c) 2006-2009 Vmware, Inc., Palo Alto, CA., USA
struct vm_page *dummy_read_page;
struct ttm_mem_shrink shrink;
struct rwlock device_list_mutex;
- struct mutex lru_lock;
+ spinlock_t lru_lock;
/**
* Protected by device_list_mutex.
struct list_head device_list;
struct ttm_bo_global *glob;
struct ttm_bo_driver *driver;
- struct rwlock vm_lock;
+ rwlock_t vm_lock;
struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
- struct mutex fence_lock;
+ spinlock_t fence_lock;
bus_space_tag_t iot;
bus_space_tag_t memt;
* to make room for a buffer already reserved. (Buffers are reserved before
* they are evicted). The following algorithm prevents such deadlocks from
* occurring:
- * 1) Buffers are reserved with the lru mutex held. Upon successful
+ * 1) Buffers are reserved with the lru spinlock held. Upon successful
* reservation they are removed from the lru list. This stops a reserved buffer
- * from being evicted. However the lru mutex is released between the time
+ * from being evicted. However the lru spinlock is released between the time
* a buffer is selected for eviction and the time it is reserved.
* Therefore a check is made when a buffer is reserved for eviction, that it
* is still the first buffer in the lru list, before it is removed from the
*
* Must be called with struct ttm_bo_global::lru_lock held,
* and will not remove reserved buffers from the lru lists.
- * The function may release the LRU mutex if it needs to sleep.
+ * The function may release the LRU spinlock if it needs to sleep.
* Otherwise identical to ttm_bo_reserve.
*
* Returns:
-/* $OpenBSD: ttm_lock.h,v 1.2 2015/04/12 03:54:10 jsg Exp $ */
+/* $OpenBSD: ttm_lock.h,v 1.3 2015/04/18 14:47:35 jsg Exp $ */
/**************************************************************************
*
* Copyright (c) 2007-2009 VMware, Inc., Palo Alto, CA., USA
struct ttm_lock {
struct ttm_base_object base;
wait_queue_head_t queue;
- struct mutex lock;
+ spinlock_t lock;
int32_t rw;
uint32_t flags;
bool kill_takers;
-/* $OpenBSD: ttm_memory.h,v 1.3 2015/02/10 10:50:49 jsg Exp $ */
+/* $OpenBSD: ttm_memory.h,v 1.4 2015/04/18 14:47:35 jsg Exp $ */
/**************************************************************************
*
* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
struct taskq *swap_queue;
struct task task;
bool task_queued;
- struct mutex lock;
+ spinlock_t lock;
struct ttm_mem_zone *zones[TTM_MEM_MAX_ZONES];
unsigned int num_zones;
struct ttm_mem_zone *zone_kernel;
-/* $OpenBSD: ttm_object.c,v 1.7 2015/04/11 05:10:13 jsg Exp $ */
+/* $OpenBSD: ttm_object.c,v 1.8 2015/04/18 14:47:35 jsg Exp $ */
/**************************************************************************
*
* Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
struct ttm_object_file {
struct ttm_object_device *tdev;
- struct rwlock lock;
+ rwlock_t lock;
struct list_head ref_list;
struct drm_open_hash ref_hash[TTM_REF_NUM];
int refcount;
-/* $OpenBSD: ttm_object.h,v 1.1 2013/08/12 04:11:53 jsg Exp $ */
+/* $OpenBSD: ttm_object.h,v 1.2 2015/04/18 14:47:35 jsg Exp $ */
/**************************************************************************
*
* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
extern void ttm_object_device_release(struct ttm_object_device **p_tdev);
-#define ttm_base_object_free(__object, __base)\
+#define ttm_base_object_kfree(__object, __base)\
kfree_rcu(__object, __base.rhead)
#endif