Skip to content

Commit

Permalink
Merge branch 'gma500-next' of git://github.com/patjak/drm-gma500 into…
Browse files Browse the repository at this point in the history
… drm-next

Summary of what's included:

- SGX MMU support
- SGX IRQ handling (Page faults and blitter fences)
- Minor Cedarview and Poulsbo unification
- Work queue for ASLE interrupt work
- Various cleanups, style fixes and removal of dead code

* 'gma500-next' of git://github.com/patjak/drm-gma500:
  drm/gma500: remove stub .open/postclose
  drm/gma500: Code cleanup - inline documentation
  drm/gma500: Code cleanup - style fixes
  drm/gma500: Code cleanup - removal of centralized exiting of function
  drm/gma500/cdv: Cedarview display cleanups
  drm/gma500: Unify encoder mode fixup
  drm/gma500: Unify _get_core_freq for cdv and psb
  drm/gma500: Move asle interrupt work into a work task
  drm/gma500: Remove dead code
  drm/gma500: Add backing type and base align to psb_gem_create()
  drm/gma500: Remove unused ioctls
  drm/gma500: Always trap MMU page faults
  drm/gma500: Hook up the MMU
  drm/gma500: Add first piece of blitter code
  drm/gma500: Give MMU code it's own header file
  drm/gma500: Add support for SGX interrupts
  drm/gma500: Make SGX MMU driver actually do something
  • Loading branch information
Dave Airlie committed Mar 20, 2014
2 parents e84c20a + 7514409 commit 5500493
Show file tree
Hide file tree
Showing 27 changed files with 722 additions and 952 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/gma500/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ gma500_gfx-y += \
intel_i2c.o \
intel_gmbus.o \
mmu.o \
blitter.o \
power.o \
psb_drv.o \
gma_display.o \
gma_device.o \
psb_intel_display.o \
psb_intel_lvds.o \
psb_intel_modes.o \
Expand Down
51 changes: 51 additions & 0 deletions drivers/gpu/drm/gma500/blitter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2014, Patrik Jakobsson
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* Authors: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
*/

#include "psb_drv.h"

#include "blitter.h"
#include "psb_reg.h"

/* Wait for the blitter to be completely idle */
int gma_blt_wait_idle(struct drm_psb_private *dev_priv)
{
unsigned long stop = jiffies + HZ;
int busy = 1;

/* NOP for Cedarview */
if (IS_CDV(dev_priv->dev))
return 0;

/* First do a quick check */
if ((PSB_RSGX32(PSB_CR_2D_SOCIF) == _PSB_C2_SOCIF_EMPTY) &&
((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) & _PSB_C2B_STATUS_BUSY) == 0))
return 0;

do {
busy = (PSB_RSGX32(PSB_CR_2D_SOCIF) != _PSB_C2_SOCIF_EMPTY);
} while (busy && !time_after_eq(jiffies, stop));

if (busy)
return -EBUSY;

do {
busy = ((PSB_RSGX32(PSB_CR_2D_BLIT_STATUS) &
_PSB_C2B_STATUS_BUSY) != 0);
} while (busy && !time_after_eq(jiffies, stop));

/* If still busy, we probably have a hang */
return (busy) ? -EBUSY : 0;
}
22 changes: 22 additions & 0 deletions drivers/gpu/drm/gma500/blitter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2014, Patrik Jakobsson
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* Authors: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
*/

#ifndef __BLITTER_H
#define __BLITTER_H

extern int gma_blt_wait_idle(struct drm_psb_private *dev_priv);

#endif
40 changes: 2 additions & 38 deletions drivers/gpu/drm/gma500/cdv_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "psb_intel_reg.h"
#include "intel_bios.h"
#include "cdv_device.h"
#include "gma_device.h"

#define VGA_SR_INDEX 0x3c4
#define VGA_SR_DATA 0x3c5
Expand Down Expand Up @@ -426,43 +427,6 @@ static int cdv_power_up(struct drm_device *dev)
return 0;
}

/* FIXME ? - shared with Poulsbo */
static void cdv_get_core_freq(struct drm_device *dev)
{
uint32_t clock;
struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
struct drm_psb_private *dev_priv = dev->dev_private;

pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
pci_read_config_dword(pci_root, 0xD4, &clock);
pci_dev_put(pci_root);

switch (clock & 0x07) {
case 0:
dev_priv->core_freq = 100;
break;
case 1:
dev_priv->core_freq = 133;
break;
case 2:
dev_priv->core_freq = 150;
break;
case 3:
dev_priv->core_freq = 178;
break;
case 4:
dev_priv->core_freq = 200;
break;
case 5:
case 6:
case 7:
dev_priv->core_freq = 266;
break;
default:
dev_priv->core_freq = 0;
}
}

static void cdv_hotplug_work_func(struct work_struct *work)
{
struct drm_psb_private *dev_priv = container_of(work, struct drm_psb_private,
Expand Down Expand Up @@ -618,7 +582,7 @@ static int cdv_chip_setup(struct drm_device *dev)
if (pci_enable_msi(dev->pdev))
dev_warn(dev->dev, "Enabling MSI failed!\n");
dev_priv->regmap = cdv_regmap;
cdv_get_core_freq(dev);
gma_get_core_freq(dev);
psb_intel_opregion_init(dev);
psb_intel_init_bios(dev);
cdv_hotplug_enable(dev, false);
Expand Down
9 changes: 1 addition & 8 deletions drivers/gpu/drm/gma500/cdv_intel_crt.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ static int cdv_intel_crt_mode_valid(struct drm_connector *connector,
return MODE_OK;
}

static bool cdv_intel_crt_mode_fixup(struct drm_encoder *encoder,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
return true;
}

static void cdv_intel_crt_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
Expand Down Expand Up @@ -224,7 +217,7 @@ static int cdv_intel_crt_set_property(struct drm_connector *connector,

static const struct drm_encoder_helper_funcs cdv_intel_crt_helper_funcs = {
.dpms = cdv_intel_crt_dpms,
.mode_fixup = cdv_intel_crt_mode_fixup,
.mode_fixup = gma_encoder_mode_fixup,
.prepare = gma_encoder_prepare,
.commit = gma_encoder_commit,
.mode_set = cdv_intel_crt_mode_set,
Expand Down
71 changes: 19 additions & 52 deletions drivers/gpu/drm/gma500/cdv_intel_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,11 @@ static bool cdv_intel_find_dp_pll(const struct gma_limit_t *limit,
int refclk,
struct gma_clock_t *best_clock)
{
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
struct gma_clock_t clock;
if (refclk == 27000) {

switch (refclk) {
case 27000:
if (target < 200000) {
clock.p1 = 2;
clock.p2 = 10;
Expand All @@ -427,7 +430,9 @@ static bool cdv_intel_find_dp_pll(const struct gma_limit_t *limit,
clock.m1 = 0;
clock.m2 = 98;
}
} else if (refclk == 100000) {
break;

case 100000:
if (target < 200000) {
clock.p1 = 2;
clock.p2 = 10;
Expand All @@ -441,12 +446,13 @@ static bool cdv_intel_find_dp_pll(const struct gma_limit_t *limit,
clock.m1 = 0;
clock.m2 = 133;
}
} else
break;

default:
return false;
clock.m = clock.m2 + 2;
clock.p = clock.p1 * clock.p2;
clock.vco = (refclk * clock.m) / clock.n;
clock.dot = clock.vco / clock.p;
}

gma_crtc->clock_funcs->clock(refclk, &clock);
memcpy(best_clock, &clock, sizeof(struct gma_clock_t));
return true;
}
Expand All @@ -468,49 +474,6 @@ static bool cdv_intel_pipe_enabled(struct drm_device *dev, int pipe)
return true;
}

static bool cdv_intel_single_pipe_active (struct drm_device *dev)
{
uint32_t pipe_enabled = 0;

if (cdv_intel_pipe_enabled(dev, 0))
pipe_enabled |= FIFO_PIPEA;

if (cdv_intel_pipe_enabled(dev, 1))
pipe_enabled |= FIFO_PIPEB;


DRM_DEBUG_KMS("pipe enabled %x\n", pipe_enabled);

if (pipe_enabled == FIFO_PIPEA || pipe_enabled == FIFO_PIPEB)
return true;
else
return false;
}

static bool is_pipeb_lvds(struct drm_device *dev, struct drm_crtc *crtc)
{
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
struct drm_mode_config *mode_config = &dev->mode_config;
struct drm_connector *connector;

if (gma_crtc->pipe != 1)
return false;

list_for_each_entry(connector, &mode_config->connector_list, head) {
struct gma_encoder *gma_encoder =
gma_attached_encoder(connector);

if (!connector->encoder
|| connector->encoder->crtc != crtc)
continue;

if (gma_encoder->type == INTEL_OUTPUT_LVDS)
return true;
}

return false;
}

void cdv_disable_sr(struct drm_device *dev)
{
if (REG_READ(FW_BLC_SELF) & FW_BLC_SELF_EN) {
Expand All @@ -535,8 +498,10 @@ void cdv_disable_sr(struct drm_device *dev)
void cdv_update_wm(struct drm_device *dev, struct drm_crtc *crtc)
{
struct drm_psb_private *dev_priv = dev->dev_private;
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);

if (cdv_intel_single_pipe_active(dev)) {
/* Is only one pipe enabled? */
if (cdv_intel_pipe_enabled(dev, 0) ^ cdv_intel_pipe_enabled(dev, 1)) {
u32 fw;

fw = REG_READ(DSPFW1);
Expand All @@ -557,7 +522,9 @@ void cdv_update_wm(struct drm_device *dev, struct drm_crtc *crtc)

/* ignore FW4 */

if (is_pipeb_lvds(dev, crtc)) {
/* Is pipe b lvds ? */
if (gma_crtc->pipe == 1 &&
gma_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
REG_WRITE(DSPFW5, 0x00040330);
} else {
fw = (3 << DSP_PLANE_B_FIFO_WM1_SHIFT) |
Expand Down
9 changes: 1 addition & 8 deletions drivers/gpu/drm/gma500/cdv_intel_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ static void cdv_hdmi_mode_set(struct drm_encoder *encoder,
REG_READ(hdmi_priv->hdmi_reg);
}

static bool cdv_hdmi_mode_fixup(struct drm_encoder *encoder,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
return true;
}

static void cdv_hdmi_dpms(struct drm_encoder *encoder, int mode)
{
struct drm_device *dev = encoder->dev;
Expand Down Expand Up @@ -262,7 +255,7 @@ static void cdv_hdmi_destroy(struct drm_connector *connector)

static const struct drm_encoder_helper_funcs cdv_hdmi_helper_funcs = {
.dpms = cdv_hdmi_dpms,
.mode_fixup = cdv_hdmi_mode_fixup,
.mode_fixup = gma_encoder_mode_fixup,
.prepare = gma_encoder_prepare,
.mode_set = cdv_hdmi_mode_set,
.commit = gma_encoder_commit,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/gma500/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
{
struct gtt_range *backing;
/* Begin by trying to use stolen memory backing */
backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1, PAGE_SIZE);
if (backing) {
drm_gem_private_object_init(dev, &backing->gem, aligned_size);
return backing;
Expand Down
Loading

0 comments on commit 5500493

Please sign in to comment.