diff options
author | Dave Airlie <airlied@redhat.com> | 2011-05-15 20:45:40 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-05-15 20:45:40 -0400 |
commit | 69f7876b2ab61e8114675d6092ad0b482e233612 (patch) | |
tree | a55aefd08d6c5f617d277a99e11b5a707e162585 /drivers | |
parent | 0eacdba3a186e5d5b8a8bb421caacddc135e67e3 (diff) | |
parent | 645c62a5e95a5f9a8e0d0627446bbda4ee042024 (diff) |
Merge remote branch 'keithp/drm-intel-next' of /ssd/git/drm-next into drm-core-next
* 'keithp/drm-intel-next' of /ssd/git/drm-next: (301 commits)
drm/i915: split PCH clock gating init
drm/i915: add Ivybridge clock gating init function
drm/i915: Update the location of the ringbuffers' HWS_PGA registers for IVB.
drm/i915: Add support for fence registers on Ivybridge.
drm/i915: Use existing function instead of open-coding fence reg clear.
drm/i915: split clock gating init into per-chipset functions
drm/i915: set IBX pch type explicitly
drm/i915: add Ivy Bridge PCI IDs and driver feature structs
drm/i915: add PantherPoint PCH ID
agp/intel: add Ivy Bridge support
drm/i915: ring support for Ivy Bridge
drm/i915: page flip support for Ivy Bridge
drm/i915: interrupt & vblank support for Ivy Bridge
drm/i915: treat Ivy Bridge watermarks like Sandy Bridge
drm/i915: manual FDI training for Ivy Bridge
drm/i915: add swizzle/tiling support for Ivy Bridge
drm/i915: Ivy Bridge has split display and pipe control
drm/i915: add IS_IVYBRIDGE macro for checks
drm/i915: add IS_GEN7 macro to cover Ivy Bridge and later
drm/i915: split enable/disable vblank code into chipset specific functions
...
Diffstat (limited to 'drivers')
115 files changed, 2944 insertions, 1490 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index b136c9c1e531..449c556274c0 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -943,6 +943,10 @@ static int acpi_bus_get_flags(struct acpi_device *device) | |||
943 | if (ACPI_SUCCESS(status)) | 943 | if (ACPI_SUCCESS(status)) |
944 | device->flags.lockable = 1; | 944 | device->flags.lockable = 1; |
945 | 945 | ||
946 | /* Power resources cannot be power manageable. */ | ||
947 | if (device->device_type == ACPI_BUS_TYPE_POWER) | ||
948 | return 0; | ||
949 | |||
946 | /* Presence of _PS0|_PR0 indicates 'power manageable' */ | 950 | /* Presence of _PS0|_PR0 indicates 'power manageable' */ |
947 | status = acpi_get_handle(device->handle, "_PS0", &temp); | 951 | status = acpi_get_handle(device->handle, "_PS0", &temp); |
948 | if (ACPI_FAILURE(status)) | 952 | if (ACPI_FAILURE(status)) |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index fbc5b6e7c591..abe3ab709e87 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -63,6 +63,7 @@ void device_pm_init(struct device *dev) | |||
63 | dev->power.wakeup = NULL; | 63 | dev->power.wakeup = NULL; |
64 | spin_lock_init(&dev->power.lock); | 64 | spin_lock_init(&dev->power.lock); |
65 | pm_runtime_init(dev); | 65 | pm_runtime_init(dev); |
66 | INIT_LIST_HEAD(&dev->power.entry); | ||
66 | } | 67 | } |
67 | 68 | ||
68 | /** | 69 | /** |
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 4573c83df6dd..abbbd33e8d8a 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c | |||
@@ -258,7 +258,7 @@ void device_set_wakeup_capable(struct device *dev, bool capable) | |||
258 | if (!!dev->power.can_wakeup == !!capable) | 258 | if (!!dev->power.can_wakeup == !!capable) |
259 | return; | 259 | return; |
260 | 260 | ||
261 | if (device_is_registered(dev)) { | 261 | if (device_is_registered(dev) && !list_empty(&dev->power.entry)) { |
262 | if (capable) { | 262 | if (capable) { |
263 | if (wakeup_sysfs_add(dev)) | 263 | if (wakeup_sysfs_add(dev)) |
264 | return; | 264 | return; |
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index b0a0dccc98c1..b427711be4be 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -903,6 +903,9 @@ static struct pci_device_id agp_intel_pci_table[] = { | |||
903 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB), | 903 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB), |
904 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB), | 904 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB), |
905 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_HB), | 905 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_HB), |
906 | ID(PCI_DEVICE_ID_INTEL_IVYBRIDGE_HB), | ||
907 | ID(PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_HB), | ||
908 | ID(PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_HB), | ||
906 | { } | 909 | { } |
907 | }; | 910 | }; |
908 | 911 | ||
diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h index 5feebe2800e9..999803ce10dc 100644 --- a/drivers/char/agp/intel-agp.h +++ b/drivers/char/agp/intel-agp.h | |||
@@ -225,6 +225,14 @@ | |||
225 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG 0x0126 | 225 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG 0x0126 |
226 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_HB 0x0108 /* Server */ | 226 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_HB 0x0108 /* Server */ |
227 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG 0x010A | 227 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG 0x010A |
228 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_HB 0x0150 /* Desktop */ | ||
229 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT1_IG 0x0152 | ||
230 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT2_IG 0x0162 | ||
231 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_HB 0x0154 /* Mobile */ | ||
232 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT1_IG 0x0156 | ||
233 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG 0x0166 | ||
234 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_HB 0x0158 /* Server */ | ||
235 | #define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG 0x015A | ||
228 | 236 | ||
229 | int intel_gmch_probe(struct pci_dev *pdev, | 237 | int intel_gmch_probe(struct pci_dev *pdev, |
230 | struct agp_bridge_data *bridge); | 238 | struct agp_bridge_data *bridge); |
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 0d09b537bb9a..85151019dde1 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -1420,6 +1420,16 @@ static const struct intel_gtt_driver_description { | |||
1420 | "Sandybridge", &sandybridge_gtt_driver }, | 1420 | "Sandybridge", &sandybridge_gtt_driver }, |
1421 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG, | 1421 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG, |
1422 | "Sandybridge", &sandybridge_gtt_driver }, | 1422 | "Sandybridge", &sandybridge_gtt_driver }, |
1423 | { PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT1_IG, | ||
1424 | "Ivybridge", &sandybridge_gtt_driver }, | ||
1425 | { PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT2_IG, | ||
1426 | "Ivybridge", &sandybridge_gtt_driver }, | ||
1427 | { PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT1_IG, | ||
1428 | "Ivybridge", &sandybridge_gtt_driver }, | ||
1429 | { PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG, | ||
1430 | "Ivybridge", &sandybridge_gtt_driver }, | ||
1431 | { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG, | ||
1432 | "Ivybridge", &sandybridge_gtt_driver }, | ||
1423 | { 0, NULL, NULL } | 1433 | { 0, NULL, NULL } |
1424 | }; | 1434 | }; |
1425 | 1435 | ||
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 0fc0a79852de..6db161f64ae0 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c | |||
@@ -32,10 +32,9 @@ static DEFINE_MUTEX(clocks_mutex); | |||
32 | * Then we take the most specific entry - with the following | 32 | * Then we take the most specific entry - with the following |
33 | * order of precedence: dev+con > dev only > con only. | 33 | * order of precedence: dev+con > dev only > con only. |
34 | */ | 34 | */ |
35 | static struct clk *clk_find(const char *dev_id, const char *con_id) | 35 | static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) |
36 | { | 36 | { |
37 | struct clk_lookup *p; | 37 | struct clk_lookup *p, *cl = NULL; |
38 | struct clk *clk = NULL; | ||
39 | int match, best = 0; | 38 | int match, best = 0; |
40 | 39 | ||
41 | list_for_each_entry(p, &clocks, node) { | 40 | list_for_each_entry(p, &clocks, node) { |
@@ -52,27 +51,27 @@ static struct clk *clk_find(const char *dev_id, const char *con_id) | |||
52 | } | 51 | } |
53 | 52 | ||
54 | if (match > best) { | 53 | if (match > best) { |
55 | clk = p->clk; | 54 | cl = p; |
56 | if (match != 3) | 55 | if (match != 3) |
57 | best = match; | 56 | best = match; |
58 | else | 57 | else |
59 | break; | 58 | break; |
60 | } | 59 | } |
61 | } | 60 | } |
62 | return clk; | 61 | return cl; |
63 | } | 62 | } |
64 | 63 | ||
65 | struct clk *clk_get_sys(const char *dev_id, const char *con_id) | 64 | struct clk *clk_get_sys(const char *dev_id, const char *con_id) |
66 | { | 65 | { |
67 | struct clk *clk; | 66 | struct clk_lookup *cl; |
68 | 67 | ||
69 | mutex_lock(&clocks_mutex); | 68 | mutex_lock(&clocks_mutex); |
70 | clk = clk_find(dev_id, con_id); | 69 | cl = clk_find(dev_id, con_id); |
71 | if (clk && !__clk_get(clk)) | 70 | if (cl && !__clk_get(cl->clk)) |
72 | clk = NULL; | 71 | cl = NULL; |
73 | mutex_unlock(&clocks_mutex); | 72 | mutex_unlock(&clocks_mutex); |
74 | 73 | ||
75 | return clk ? clk : ERR_PTR(-ENOENT); | 74 | return cl ? cl->clk : ERR_PTR(-ENOENT); |
76 | } | 75 | } |
77 | EXPORT_SYMBOL(clk_get_sys); | 76 | EXPORT_SYMBOL(clk_get_sys); |
78 | 77 | ||
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 62ced7554ba4..2022a5c966bb 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c | |||
@@ -933,11 +933,34 @@ EXPORT_SYMBOL(drm_vblank_put); | |||
933 | 933 | ||
934 | void drm_vblank_off(struct drm_device *dev, int crtc) | 934 | void drm_vblank_off(struct drm_device *dev, int crtc) |
935 | { | 935 | { |
936 | struct drm_pending_vblank_event *e, *t; | ||
937 | struct timeval now; | ||
936 | unsigned long irqflags; | 938 | unsigned long irqflags; |
939 | unsigned int seq; | ||
937 | 940 | ||
938 | spin_lock_irqsave(&dev->vbl_lock, irqflags); | 941 | spin_lock_irqsave(&dev->vbl_lock, irqflags); |
939 | vblank_disable_and_save(dev, crtc); | 942 | vblank_disable_and_save(dev, crtc); |
940 | DRM_WAKEUP(&dev->vbl_queue[crtc]); | 943 | DRM_WAKEUP(&dev->vbl_queue[crtc]); |
944 | |||
945 | /* Send any queued vblank events, lest the natives grow disquiet */ | ||
946 | seq = drm_vblank_count_and_time(dev, crtc, &now); | ||
947 | list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) { | ||
948 | if (e->pipe != crtc) | ||
949 | continue; | ||
950 | DRM_DEBUG("Sending premature vblank event on disable: \ | ||
951 | wanted %d, current %d\n", | ||
952 | e->event.sequence, seq); | ||
953 | |||
954 | e->event.sequence = seq; | ||
955 | e->event.tv_sec = now.tv_sec; | ||
956 | e->event.tv_usec = now.tv_usec; | ||
957 | drm_vblank_put(dev, e->pipe); | ||
958 | list_move_tail(&e->base.link, &e->base.file_priv->event_list); | ||
959 | wake_up_interruptible(&e->base.file_priv->event_wait); | ||
960 | trace_drm_vblank_event_delivered(e->base.pid, e->pipe, | ||
961 | e->event.sequence); | ||
962 | } | ||
963 | |||
941 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); | 964 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); |
942 | } | 965 | } |
943 | EXPORT_SYMBOL(drm_vblank_off); | 966 | EXPORT_SYMBOL(drm_vblank_off); |
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 87c8e29465e3..183eaac8980a 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -106,11 +106,12 @@ static const char *get_tiling_flag(struct drm_i915_gem_object *obj) | |||
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | static const char *agp_type_str(int type) | 109 | static const char *cache_level_str(int type) |
110 | { | 110 | { |
111 | switch (type) { | 111 | switch (type) { |
112 | case 0: return " uncached"; | 112 | case I915_CACHE_NONE: return " uncached"; |
113 | case 1: return " snooped"; | 113 | case I915_CACHE_LLC: return " snooped (LLC)"; |
114 | case I915_CACHE_LLC_MLC: return " snooped (LLC+MLC)"; | ||
114 | default: return ""; | 115 | default: return ""; |
115 | } | 116 | } |
116 | } | 117 | } |
@@ -127,7 +128,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj) | |||
127 | obj->base.write_domain, | 128 | obj->base.write_domain, |
128 | obj->last_rendering_seqno, | 129 | obj->last_rendering_seqno, |
129 | obj->last_fenced_seqno, | 130 | obj->last_fenced_seqno, |
130 | agp_type_str(obj->agp_type == AGP_USER_CACHED_MEMORY), | 131 | cache_level_str(obj->cache_level), |
131 | obj->dirty ? " dirty" : "", | 132 | obj->dirty ? " dirty" : "", |
132 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); | 133 | obj->madv == I915_MADV_DONTNEED ? " purgeable" : ""); |
133 | if (obj->base.name) | 134 | if (obj->base.name) |
@@ -714,7 +715,7 @@ static void print_error_buffers(struct seq_file *m, | |||
714 | dirty_flag(err->dirty), | 715 | dirty_flag(err->dirty), |
715 | purgeable_flag(err->purgeable), | 716 | purgeable_flag(err->purgeable), |
716 | ring_str(err->ring), | 717 | ring_str(err->ring), |
717 | agp_type_str(err->agp_type)); | 718 | cache_level_str(err->cache_level)); |
718 | 719 | ||
719 | if (err->name) | 720 | if (err->name) |
720 | seq_printf(m, " (name: %d)", err->name); | 721 | seq_printf(m, " (name: %d)", err->name); |
@@ -852,6 +853,7 @@ static int i915_cur_delayinfo(struct seq_file *m, void *unused) | |||
852 | struct drm_info_node *node = (struct drm_info_node *) m->private; | 853 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
853 | struct drm_device *dev = node->minor->dev; | 854 | struct drm_device *dev = node->minor->dev; |
854 | drm_i915_private_t *dev_priv = dev->dev_private; | 855 | drm_i915_private_t *dev_priv = dev->dev_private; |
856 | int ret; | ||
855 | 857 | ||
856 | if (IS_GEN5(dev)) { | 858 | if (IS_GEN5(dev)) { |
857 | u16 rgvswctl = I915_READ16(MEMSWCTL); | 859 | u16 rgvswctl = I915_READ16(MEMSWCTL); |
@@ -873,7 +875,11 @@ static int i915_cur_delayinfo(struct seq_file *m, void *unused) | |||
873 | int max_freq; | 875 | int max_freq; |
874 | 876 | ||
875 | /* RPSTAT1 is in the GT power well */ | 877 | /* RPSTAT1 is in the GT power well */ |
876 | __gen6_gt_force_wake_get(dev_priv); | 878 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
879 | if (ret) | ||
880 | return ret; | ||
881 | |||
882 | gen6_gt_force_wake_get(dev_priv); | ||
877 | 883 | ||
878 | rpstat = I915_READ(GEN6_RPSTAT1); | 884 | rpstat = I915_READ(GEN6_RPSTAT1); |
879 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); | 885 | rpupei = I915_READ(GEN6_RP_CUR_UP_EI); |
@@ -883,6 +889,9 @@ static int i915_cur_delayinfo(struct seq_file *m, void *unused) | |||
883 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); | 889 | rpcurdown = I915_READ(GEN6_RP_CUR_DOWN); |
884 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); | 890 | rpprevdown = I915_READ(GEN6_RP_PREV_DOWN); |
885 | 891 | ||
892 | gen6_gt_force_wake_put(dev_priv); | ||
893 | mutex_unlock(&dev->struct_mutex); | ||
894 | |||
886 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); | 895 | seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status); |
887 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); | 896 | seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat); |
888 | seq_printf(m, "Render p-state ratio: %d\n", | 897 | seq_printf(m, "Render p-state ratio: %d\n", |
@@ -917,8 +926,6 @@ static int i915_cur_delayinfo(struct seq_file *m, void *unused) | |||
917 | max_freq = rp_state_cap & 0xff; | 926 | max_freq = rp_state_cap & 0xff; |
918 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", | 927 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
919 | max_freq * 50); | 928 | max_freq * 50); |
920 | |||
921 | __gen6_gt_force_wake_put(dev_priv); | ||
922 | } else { | 929 | } else { |
923 | seq_printf(m, "no P-state info available\n"); | 930 | seq_printf(m, "no P-state info available\n"); |
924 | } | 931 | } |
@@ -1186,6 +1193,42 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data) | |||
1186 | return 0; | 1193 | return 0; |
1187 | } | 1194 | } |
1188 | 1195 | ||
1196 | static int i915_context_status(struct seq_file *m, void *unused) | ||
1197 | { | ||
1198 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
1199 | struct drm_device *dev = node->minor->dev; | ||
1200 | drm_i915_private_t *dev_priv = dev->dev_private; | ||
1201 | int ret; | ||
1202 | |||
1203 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); | ||
1204 | if (ret) | ||
1205 | return ret; | ||
1206 | |||
1207 | seq_printf(m, "power context "); | ||
1208 | describe_obj(m, dev_priv->pwrctx); | ||
1209 | seq_printf(m, "\n"); | ||
1210 | |||
1211 | seq_printf(m, "render context "); | ||
1212 | describe_obj(m, dev_priv->renderctx); | ||
1213 | seq_printf(m, "\n"); | ||
1214 | |||
1215 | mutex_unlock(&dev->mode_config.mutex); | ||
1216 | |||
1217 | return 0; | ||
1218 | } | ||
1219 | |||
1220 | static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data) | ||
1221 | { | ||
1222 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
1223 | struct drm_device *dev = node->minor->dev; | ||
1224 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1225 | |||
1226 | seq_printf(m, "forcewake count = %d\n", | ||
1227 | atomic_read(&dev_priv->forcewake_count)); | ||
1228 | |||
1229 | return 0; | ||
1230 | } | ||
1231 | |||
1189 | static int | 1232 | static int |
1190 | i915_wedged_open(struct inode *inode, | 1233 | i915_wedged_open(struct inode *inode, |
1191 | struct file *filp) | 1234 | struct file *filp) |
@@ -1288,6 +1331,67 @@ static int i915_wedged_create(struct dentry *root, struct drm_minor *minor) | |||
1288 | return drm_add_fake_info_node(minor, ent, &i915_wedged_fops); | 1331 | return drm_add_fake_info_node(minor, ent, &i915_wedged_fops); |
1289 | } | 1332 | } |
1290 | 1333 | ||
1334 | static int i915_forcewake_open(struct inode *inode, struct file *file) | ||
1335 | { | ||
1336 | struct drm_device *dev = inode->i_private; | ||
1337 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1338 | int ret; | ||
1339 | |||
1340 | if (!IS_GEN6(dev)) | ||
1341 | return 0; | ||
1342 | |||
1343 | ret = mutex_lock_interruptible(&dev->struct_mutex); | ||
1344 | if (ret) | ||
1345 | return ret; | ||
1346 | gen6_gt_force_wake_get(dev_priv); | ||
1347 | mutex_unlock(&dev->struct_mutex); | ||
1348 | |||
1349 | return 0; | ||
1350 | } | ||
1351 | |||
1352 | int i915_forcewake_release(struct inode *inode, struct file *file) | ||
1353 | { | ||
1354 | struct drm_device *dev = inode->i_private; | ||
1355 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1356 | |||
1357 | if (!IS_GEN6(dev)) | ||
1358 | return 0; | ||
1359 | |||
1360 | /* | ||
1361 | * It's bad that we can potentially hang userspace if struct_mutex gets | ||
1362 | * forever stuck. However, if we cannot acquire this lock it means that | ||
1363 | * almost certainly the driver has hung, is not unload-able. Therefore | ||
1364 | * hanging here is probably a minor inconvenience not to be seen my | ||
1365 | * almost every user. | ||
1366 | */ | ||
1367 | mutex_lock(&dev->struct_mutex); | ||
1368 | gen6_gt_force_wake_put(dev_priv); | ||
1369 | mutex_unlock(&dev->struct_mutex); | ||
1370 | |||
1371 | return 0; | ||
1372 | } | ||
1373 | |||
1374 | static const struct file_operations i915_forcewake_fops = { | ||
1375 | .owner = THIS_MODULE, | ||
1376 | .open = i915_forcewake_open, | ||
1377 | .release = i915_forcewake_release, | ||
1378 | }; | ||
1379 | |||
1380 | static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) | ||
1381 | { | ||
1382 | struct drm_device *dev = minor->dev; | ||
1383 | struct dentry *ent; | ||
1384 | |||
1385 | ent = debugfs_create_file("i915_forcewake_user", | ||
1386 | S_IRUSR, | ||
1387 | root, dev, | ||
1388 | &i915_forcewake_fops); | ||
1389 | if (IS_ERR(ent)) | ||
1390 | return PTR_ERR(ent); | ||
1391 | |||
1392 | return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); | ||
1393 | } | ||
1394 | |||
1291 | static struct drm_info_list i915_debugfs_list[] = { | 1395 | static struct drm_info_list i915_debugfs_list[] = { |
1292 | {"i915_capabilities", i915_capabilities, 0}, | 1396 | {"i915_capabilities", i915_capabilities, 0}, |
1293 | {"i915_gem_objects", i915_gem_object_info, 0}, | 1397 | {"i915_gem_objects", i915_gem_object_info, 0}, |
@@ -1324,6 +1428,8 @@ static struct drm_info_list i915_debugfs_list[] = { | |||
1324 | {"i915_sr_status", i915_sr_status, 0}, | 1428 | {"i915_sr_status", i915_sr_status, 0}, |
1325 | {"i915_opregion", i915_opregion, 0}, | 1429 | {"i915_opregion", i915_opregion, 0}, |
1326 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, | 1430 | {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, |
1431 | {"i915_context_status", i915_context_status, 0}, | ||
1432 | {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0}, | ||
1327 | }; | 1433 | }; |
1328 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) | 1434 | #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) |
1329 | 1435 | ||
@@ -1335,6 +1441,10 @@ int i915_debugfs_init(struct drm_minor *minor) | |||
1335 | if (ret) | 1441 | if (ret) |
1336 | return ret; | 1442 | return ret; |
1337 | 1443 | ||
1444 | ret = i915_forcewake_create(minor->debugfs_root, minor); | ||
1445 | if (ret) | ||
1446 | return ret; | ||
1447 | |||
1338 | return drm_debugfs_create_files(i915_debugfs_list, | 1448 | return drm_debugfs_create_files(i915_debugfs_list, |
1339 | I915_DEBUGFS_ENTRIES, | 1449 | I915_DEBUGFS_ENTRIES, |
1340 | minor->debugfs_root, minor); | 1450 | minor->debugfs_root, minor); |
@@ -1344,6 +1454,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor) | |||
1344 | { | 1454 | { |
1345 | drm_debugfs_remove_files(i915_debugfs_list, | 1455 | drm_debugfs_remove_files(i915_debugfs_list, |
1346 | I915_DEBUGFS_ENTRIES, minor); | 1456 | I915_DEBUGFS_ENTRIES, minor); |
1457 | drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops, | ||
1458 | 1, minor); | ||
1347 | drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, | 1459 | drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops, |
1348 | 1, minor); | 1460 | 1, minor); |
1349 | } | 1461 | } |
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 12876f2795d2..0239e9974bf2 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -571,7 +571,7 @@ static int i915_quiescent(struct drm_device *dev) | |||
571 | struct intel_ring_buffer *ring = LP_RING(dev->dev_private); | 571 | struct intel_ring_buffer *ring = LP_RING(dev->dev_private); |
572 | 572 | ||
573 | i915_kernel_lost_context(dev); | 573 | i915_kernel_lost_context(dev); |
574 | return intel_wait_ring_buffer(ring, ring->size - 8); | 574 | return intel_wait_ring_idle(ring); |
575 | } | 575 | } |
576 | 576 | ||
577 | static int i915_flush_ioctl(struct drm_device *dev, void *data, | 577 | static int i915_flush_ioctl(struct drm_device *dev, void *data, |
@@ -1176,11 +1176,11 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev) | |||
1176 | return can_switch; | 1176 | return can_switch; |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | static int i915_load_modeset_init(struct drm_device *dev) | 1179 | static int i915_load_gem_init(struct drm_device *dev) |
1180 | { | 1180 | { |
1181 | struct drm_i915_private *dev_priv = dev->dev_private; | 1181 | struct drm_i915_private *dev_priv = dev->dev_private; |
1182 | unsigned long prealloc_size, gtt_size, mappable_size; | 1182 | unsigned long prealloc_size, gtt_size, mappable_size; |
1183 | int ret = 0; | 1183 | int ret; |
1184 | 1184 | ||
1185 | prealloc_size = dev_priv->mm.gtt->stolen_size; | 1185 | prealloc_size = dev_priv->mm.gtt->stolen_size; |
1186 | gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT; | 1186 | gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT; |
@@ -1204,7 +1204,7 @@ static int i915_load_modeset_init(struct drm_device *dev) | |||
1204 | ret = i915_gem_init_ringbuffer(dev); | 1204 | ret = i915_gem_init_ringbuffer(dev); |
1205 | mutex_unlock(&dev->struct_mutex); | 1205 | mutex_unlock(&dev->struct_mutex); |
1206 | if (ret) | 1206 | if (ret) |
1207 | goto out; | 1207 | return ret; |
1208 | 1208 | ||
1209 | /* Try to set up FBC with a reasonable compressed buffer size */ | 1209 | /* Try to set up FBC with a reasonable compressed buffer size */ |
1210 | if (I915_HAS_FBC(dev) && i915_powersave) { | 1210 | if (I915_HAS_FBC(dev) && i915_powersave) { |
@@ -1222,6 +1222,13 @@ static int i915_load_modeset_init(struct drm_device *dev) | |||
1222 | 1222 | ||
1223 | /* Allow hardware batchbuffers unless told otherwise. */ | 1223 | /* Allow hardware batchbuffers unless told otherwise. */ |
1224 | dev_priv->allow_batchbuffer = 1; | 1224 | dev_priv->allow_batchbuffer = 1; |
1225 | return 0; | ||
1226 | } | ||
1227 | |||
1228 | static int i915_load_modeset_init(struct drm_device *dev) | ||
1229 | { | ||
1230 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1231 | int ret; | ||
1225 | 1232 | ||
1226 | ret = intel_parse_bios(dev); | 1233 | ret = intel_parse_bios(dev); |
1227 | if (ret) | 1234 | if (ret) |
@@ -1236,7 +1243,7 @@ static int i915_load_modeset_init(struct drm_device *dev) | |||
1236 | */ | 1243 | */ |
1237 | ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode); | 1244 | ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode); |
1238 | if (ret && ret != -ENODEV) | 1245 | if (ret && ret != -ENODEV) |
1239 | goto cleanup_ringbuffer; | 1246 | goto out; |
1240 | 1247 | ||
1241 | intel_register_dsm_handler(); | 1248 | intel_register_dsm_handler(); |
1242 | 1249 | ||
@@ -1253,10 +1260,40 @@ static int i915_load_modeset_init(struct drm_device *dev) | |||
1253 | 1260 | ||
1254 | intel_modeset_init(dev); | 1261 | intel_modeset_init(dev); |
1255 | 1262 | ||
1256 | ret = drm_irq_install(dev); | 1263 | ret = i915_load_gem_init(dev); |
1257 | if (ret) | 1264 | if (ret) |
1258 | goto cleanup_vga_switcheroo; | 1265 | goto cleanup_vga_switcheroo; |
1259 | 1266 | ||
1267 | intel_modeset_gem_init(dev); | ||
1268 | |||
1269 | if (IS_IVYBRIDGE(dev)) { | ||
1270 | /* Share pre & uninstall handlers with ILK/SNB */ | ||
1271 | dev->driver->irq_handler = ivybridge_irq_handler; | ||
1272 | dev->driver->irq_preinstall = ironlake_irq_preinstall; | ||
1273 | dev->driver->irq_postinstall = ivybridge_irq_postinstall; | ||
1274 | dev->driver->irq_uninstall = ironlake_irq_uninstall; | ||
1275 | dev->driver->enable_vblank = ivybridge_enable_vblank; | ||
1276 | dev->driver->disable_vblank = ivybridge_disable_vblank; | ||
1277 | } else if (HAS_PCH_SPLIT(dev)) { | ||
1278 | dev->driver->irq_handler = ironlake_irq_handler; | ||
1279 | dev->driver->irq_preinstall = ironlake_irq_preinstall; | ||
1280 | dev->driver->irq_postinstall = ironlake_irq_postinstall; | ||
1281 | dev->driver->irq_uninstall = ironlake_irq_uninstall; | ||
1282 | dev->driver->enable_vblank = ironlake_enable_vblank; | ||
1283 | dev->driver->disable_vblank = ironlake_disable_vblank; | ||
1284 | } else { | ||
1285 | dev->driver->irq_preinstall = i915_driver_irq_preinstall; | ||
1286 | dev->driver->irq_postinstall = i915_driver_irq_postinstall; | ||
1287 | dev->driver->irq_uninstall = i915_driver_irq_uninstall; | ||
1288 | dev->driver->irq_handler = i915_driver_irq_handler; | ||
1289 | dev->driver->enable_vblank = i915_enable_vblank; | ||
1290 | dev->driver->disable_vblank = i915_disable_vblank; | ||
1291 | } | ||
1292 | |||
1293 | ret = drm_irq_install(dev); | ||
1294 | if (ret) | ||
1295 | goto cleanup_gem; | ||
1296 | |||
1260 | /* Always safe in the mode setting case. */ | 1297 | /* Always safe in the mode setting case. */ |
1261 | /* FIXME: do pre/post-mode set stuff in core KMS code */ | 1298 | /* FIXME: do pre/post-mode set stuff in core KMS code */ |
1262 | dev->vblank_disable_allowed = 1; | 1299 | dev->vblank_disable_allowed = 1; |
@@ -1274,14 +1311,14 @@ static int i915_load_modeset_init(struct drm_device *dev) | |||
1274 | 1311 | ||
1275 | cleanup_irq: | 1312 | cleanup_irq: |
1276 | drm_irq_uninstall(dev); | 1313 | drm_irq_uninstall(dev); |
1314 | cleanup_gem: | ||
1315 | mutex_lock(&dev->struct_mutex); | ||
1316 | i915_gem_cleanup_ringbuffer(dev); | ||
1317 | mutex_unlock(&dev->struct_mutex); | ||
1277 | cleanup_vga_switcheroo: | 1318 | cleanup_vga_switcheroo: |
1278 | vga_switcheroo_unregister_client(dev->pdev); | 1319 | vga_switcheroo_unregister_client(dev->pdev); |
1279 | cleanup_vga_client: | 1320 | cleanup_vga_client: |
1280 | vga_client_register(dev->pdev, NULL, NULL, NULL); | 1321 | vga_client_register(dev->pdev, NULL, NULL, NULL); |
1281 | cleanup_ringbuffer: | ||
1282 | mutex_lock(&dev->struct_mutex); | ||
1283 | i915_gem_cleanup_ringbuffer(dev); | ||
1284 | mutex_unlock(&dev->struct_mutex); | ||
1285 | out: | 1322 | out: |
1286 | return ret; | 1323 | return ret; |
1287 | } | 1324 | } |
@@ -1982,7 +2019,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
1982 | 2019 | ||
1983 | dev->driver->get_vblank_counter = i915_get_vblank_counter; | 2020 | dev->driver->get_vblank_counter = i915_get_vblank_counter; |
1984 | dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ | 2021 | dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ |
1985 | if (IS_G4X(dev) || IS_GEN5(dev) || IS_GEN6(dev)) { | 2022 | if (IS_G4X(dev) || IS_GEN5(dev) || IS_GEN6(dev) || IS_IVYBRIDGE(dev)) { |
1986 | dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */ | 2023 | dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */ |
1987 | dev->driver->get_vblank_counter = gm45_get_vblank_counter; | 2024 | dev->driver->get_vblank_counter = gm45_get_vblank_counter; |
1988 | } | 2025 | } |
@@ -2025,6 +2062,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
2025 | 2062 | ||
2026 | spin_lock_init(&dev_priv->irq_lock); | 2063 | spin_lock_init(&dev_priv->irq_lock); |
2027 | spin_lock_init(&dev_priv->error_lock); | 2064 | spin_lock_init(&dev_priv->error_lock); |
2065 | spin_lock_init(&dev_priv->rps_lock); | ||
2028 | 2066 | ||
2029 | if (IS_MOBILE(dev) || !IS_GEN2(dev)) | 2067 | if (IS_MOBILE(dev) || !IS_GEN2(dev)) |
2030 | dev_priv->num_pipe = 2; | 2068 | dev_priv->num_pipe = 2; |
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index c34a8dd31d02..8c4fcbb8a4cb 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -188,6 +188,21 @@ static const struct intel_device_info intel_sandybridge_m_info = { | |||
188 | .has_blt_ring = 1, | 188 | .has_blt_ring = 1, |
189 | }; | 189 | }; |
190 | 190 | ||
191 | static const struct intel_device_info intel_ivybridge_d_info = { | ||
192 | .is_ivybridge = 1, .gen = 7, | ||
193 | .need_gfx_hws = 1, .has_hotplug = 1, | ||
194 | .has_bsd_ring = 1, | ||
195 | .has_blt_ring = 1, | ||
196 | }; | ||
197 | |||
198 | static const struct intel_device_info intel_ivybridge_m_info = { | ||
199 | .is_ivybridge = 1, .gen = 7, .is_mobile = 1, | ||
200 | .need_gfx_hws = 1, .has_hotplug = 1, | ||
201 | .has_fbc = 0, /* FBC is not enabled on Ivybridge mobile yet */ | ||
202 | .has_bsd_ring = 1, | ||
203 | .has_blt_ring = 1, | ||
204 | }; | ||
205 | |||
191 | static const struct pci_device_id pciidlist[] = { /* aka */ | 206 | static const struct pci_device_id pciidlist[] = { /* aka */ |
192 | INTEL_VGA_DEVICE(0x3577, &intel_i830_info), /* I830_M */ | 207 | INTEL_VGA_DEVICE(0x3577, &intel_i830_info), /* I830_M */ |
193 | INTEL_VGA_DEVICE(0x2562, &intel_845g_info), /* 845_G */ | 208 | INTEL_VGA_DEVICE(0x2562, &intel_845g_info), /* 845_G */ |
@@ -227,6 +242,11 @@ static const struct pci_device_id pciidlist[] = { /* aka */ | |||
227 | INTEL_VGA_DEVICE(0x0116, &intel_sandybridge_m_info), | 242 | INTEL_VGA_DEVICE(0x0116, &intel_sandybridge_m_info), |
228 | INTEL_VGA_DEVICE(0x0126, &intel_sandybridge_m_info), | 243 | INTEL_VGA_DEVICE(0x0126, &intel_sandybridge_m_info), |
229 | INTEL_VGA_DEVICE(0x010A, &intel_sandybridge_d_info), | 244 | INTEL_VGA_DEVICE(0x010A, &intel_sandybridge_d_info), |
245 | INTEL_VGA_DEVICE(0x0156, &intel_ivybridge_m_info), /* GT1 mobile */ | ||
246 | INTEL_VGA_DEVICE(0x0166, &intel_ivybridge_m_info), /* GT2 mobile */ | ||
247 | INTEL_VGA_DEVICE(0x0152, &intel_ivybridge_d_info), /* GT1 desktop */ | ||
248 | INTEL_VGA_DEVICE(0x0162, &intel_ivybridge_d_info), /* GT2 desktop */ | ||
249 | INTEL_VGA_DEVICE(0x015a, &intel_ivybridge_d_info), /* GT1 server */ | ||
230 | {0, 0, 0} | 250 | {0, 0, 0} |
231 | }; | 251 | }; |
232 | 252 | ||
@@ -235,7 +255,9 @@ MODULE_DEVICE_TABLE(pci, pciidlist); | |||
235 | #endif | 255 | #endif |
236 | 256 | ||
237 | #define INTEL_PCH_DEVICE_ID_MASK 0xff00 | 257 | #define INTEL_PCH_DEVICE_ID_MASK 0xff00 |
258 | #define INTEL_PCH_IBX_DEVICE_ID_TYPE 0x3b00 | ||
238 | #define INTEL_PCH_CPT_DEVICE_ID_TYPE 0x1c00 | 259 | #define INTEL_PCH_CPT_DEVICE_ID_TYPE 0x1c00 |
260 | #define INTEL_PCH_PPT_DEVICE_ID_TYPE 0x1e00 | ||
239 | 261 | ||
240 | void intel_detect_pch (struct drm_device *dev) | 262 | void intel_detect_pch (struct drm_device *dev) |
241 | { | 263 | { |
@@ -254,16 +276,23 @@ void intel_detect_pch (struct drm_device *dev) | |||
254 | int id; | 276 | int id; |
255 | id = pch->device & INTEL_PCH_DEVICE_ID_MASK; | 277 | id = pch->device & INTEL_PCH_DEVICE_ID_MASK; |
256 | 278 | ||
257 | if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) { | 279 | if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) { |
280 | dev_priv->pch_type = PCH_IBX; | ||
281 | DRM_DEBUG_KMS("Found Ibex Peak PCH\n"); | ||
282 | } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) { | ||
258 | dev_priv->pch_type = PCH_CPT; | 283 | dev_priv->pch_type = PCH_CPT; |
259 | DRM_DEBUG_KMS("Found CougarPoint PCH\n"); | 284 | DRM_DEBUG_KMS("Found CougarPoint PCH\n"); |
285 | } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) { | ||
286 | /* PantherPoint is CPT compatible */ | ||
287 | dev_priv->pch_type = PCH_CPT; | ||
288 | DRM_DEBUG_KMS("Found PatherPoint PCH\n"); | ||
260 | } | 289 | } |
261 | } | 290 | } |
262 | pci_dev_put(pch); | 291 | pci_dev_put(pch); |
263 | } | 292 | } |
264 | } | 293 | } |
265 | 294 | ||
266 | void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv) | 295 | static void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv) |
267 | { | 296 | { |
268 | int count; | 297 | int count; |
269 | 298 | ||
@@ -279,12 +308,38 @@ void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv) | |||
279 | udelay(10); | 308 | udelay(10); |
280 | } | 309 | } |
281 | 310 | ||
282 | void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv) | 311 | /* |
312 | * Generally this is called implicitly by the register read function. However, | ||
313 | * if some sequence requires the GT to not power down then this function should | ||
314 | * be called at the beginning of the sequence followed by a call to | ||
315 | * gen6_gt_force_wake_put() at the end of the sequence. | ||
316 | */ | ||
317 | void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv) | ||
318 | { | ||
319 | WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex)); | ||
320 | |||
321 | /* Forcewake is atomic in case we get in here without the lock */ | ||
322 | if (atomic_add_return(1, &dev_priv->forcewake_count) == 1) | ||
323 | __gen6_gt_force_wake_get(dev_priv); | ||
324 | } | ||
325 | |||
326 | static void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv) | ||
283 | { | 327 | { |
284 | I915_WRITE_NOTRACE(FORCEWAKE, 0); | 328 | I915_WRITE_NOTRACE(FORCEWAKE, 0); |
285 | POSTING_READ(FORCEWAKE); | 329 | POSTING_READ(FORCEWAKE); |
286 | } | 330 | } |
287 | 331 | ||
332 | /* | ||
333 | * see gen6_gt_force_wake_get() | ||
334 | */ | ||
335 | void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv) | ||
336 | { | ||
337 | WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex)); | ||
338 | |||
339 | if (atomic_dec_and_test(&dev_priv->forcewake_count)) | ||
340 | __gen6_gt_force_wake_put(dev_priv); | ||
341 | } | ||
342 | |||
288 | void __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv) | 343 | void __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv) |
289 | { | 344 | { |
290 | int loop = 500; | 345 | int loop = 500; |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 1c1b27c97e5c..3a1c27718065 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -188,7 +188,7 @@ struct drm_i915_error_state { | |||
188 | u32 dirty:1; | 188 | u32 dirty:1; |
189 | u32 purgeable:1; | 189 | u32 purgeable:1; |
190 | u32 ring:4; | 190 | u32 ring:4; |
191 | u32 agp_type:1; | 191 | u32 cache_level:2; |
192 | } *active_bo, *pinned_bo; | 192 | } *active_bo, *pinned_bo; |
193 | u32 active_bo_count, pinned_bo_count; | 193 | u32 active_bo_count, pinned_bo_count; |
194 | struct intel_overlay_error_state *overlay; | 194 | struct intel_overlay_error_state *overlay; |
@@ -203,12 +203,19 @@ struct drm_i915_display_funcs { | |||
203 | int (*get_display_clock_speed)(struct drm_device *dev); | 203 | int (*get_display_clock_speed)(struct drm_device *dev); |
204 | int (*get_fifo_size)(struct drm_device *dev, int plane); | 204 | int (*get_fifo_size)(struct drm_device *dev, int plane); |
205 | void (*update_wm)(struct drm_device *dev); | 205 | void (*update_wm)(struct drm_device *dev); |
206 | int (*crtc_mode_set)(struct drm_crtc *crtc, | ||
207 | struct drm_display_mode *mode, | ||
208 | struct drm_display_mode *adjusted_mode, | ||
209 | int x, int y, | ||
210 | struct drm_framebuffer *old_fb); | ||
211 | void (*fdi_link_train)(struct drm_crtc *crtc); | ||
212 | void (*init_clock_gating)(struct drm_device *dev); | ||
213 | void (*init_pch_clock_gating)(struct drm_device *dev); | ||
206 | /* clock updates for mode set */ | 214 | /* clock updates for mode set */ |
207 | /* cursor updates */ | 215 | /* cursor updates */ |
208 | /* render clock increase/decrease */ | 216 | /* render clock increase/decrease */ |
209 | /* display clock increase/decrease */ | 217 | /* display clock increase/decrease */ |
210 | /* pll clock increase/decrease */ | 218 | /* pll clock increase/decrease */ |
211 | /* clock gating init */ | ||
212 | }; | 219 | }; |
213 | 220 | ||
214 | struct intel_device_info { | 221 | struct intel_device_info { |
@@ -223,6 +230,7 @@ struct intel_device_info { | |||
223 | u8 is_pineview : 1; | 230 | u8 is_pineview : 1; |
224 | u8 is_broadwater : 1; | 231 | u8 is_broadwater : 1; |
225 | u8 is_crestline : 1; | 232 | u8 is_crestline : 1; |
233 | u8 is_ivybridge : 1; | ||
226 | u8 has_fbc : 1; | 234 | u8 has_fbc : 1; |
227 | u8 has_pipe_cxsr : 1; | 235 | u8 has_pipe_cxsr : 1; |
228 | u8 has_hotplug : 1; | 236 | u8 has_hotplug : 1; |
@@ -676,6 +684,10 @@ typedef struct drm_i915_private { | |||
676 | 684 | ||
677 | bool mchbar_need_disable; | 685 | bool mchbar_need_disable; |
678 | 686 | ||
687 | struct work_struct rps_work; | ||
688 | spinlock_t rps_lock; | ||
689 | u32 pm_iir; | ||
690 | |||
679 | u8 cur_delay; | 691 | u8 cur_delay; |
680 | u8 min_delay; | 692 | u8 min_delay; |
681 | u8 max_delay; | 693 | u8 max_delay; |
@@ -703,8 +715,16 @@ typedef struct drm_i915_private { | |||
703 | struct intel_fbdev *fbdev; | 715 | struct intel_fbdev *fbdev; |
704 | 716 | ||
705 | struct drm_property *broadcast_rgb_property; | 717 | struct drm_property *broadcast_rgb_property; |
718 | |||
719 | atomic_t forcewake_count; | ||
706 | } drm_i915_private_t; | 720 | } drm_i915_private_t; |
707 | 721 | ||
722 | enum i915_cache_level { | ||
723 | I915_CACHE_NONE, | ||
724 | I915_CACHE_LLC, | ||
725 | I915_CACHE_LLC_MLC, /* gen6+ */ | ||
726 | }; | ||
727 | |||
708 | struct drm_i915_gem_object { | 728 | struct drm_i915_gem_object { |
709 | struct drm_gem_object base; | 729 | struct drm_gem_object base; |
710 | 730 | ||
@@ -791,6 +811,8 @@ struct drm_i915_gem_object { | |||
791 | unsigned int pending_fenced_gpu_access:1; | 811 | unsigned int pending_fenced_gpu_access:1; |
792 | unsigned int fenced_gpu_access:1; | 812 | unsigned int fenced_gpu_access:1; |
793 | 813 | ||
814 | unsigned int cache_level:2; | ||
815 | |||
794 | struct page **pages; | 816 | struct page **pages; |
795 | 817 | ||
796 | /** | 818 | /** |
@@ -827,8 +849,6 @@ struct drm_i915_gem_object { | |||
827 | /** Record of address bit 17 of each page at last unbind. */ | 849 | /** Record of address bit 17 of each page at last unbind. */ |
828 | unsigned long *bit_17; | 850 | unsigned long *bit_17; |
829 | 851 | ||
830 | /** AGP mapping type (AGP_USER_MEMORY or AGP_USER_CACHED_MEMORY */ | ||
831 | uint32_t agp_type; | ||
832 | 852 | ||
833 | /** | 853 | /** |
834 | * If present, while GEM_DOMAIN_CPU is in the read domain this array | 854 | * If present, while GEM_DOMAIN_CPU is in the read domain this array |
@@ -915,13 +935,21 @@ enum intel_chip_family { | |||
915 | #define IS_G33(dev) (INTEL_INFO(dev)->is_g33) | 935 | #define IS_G33(dev) (INTEL_INFO(dev)->is_g33) |
916 | #define IS_IRONLAKE_D(dev) ((dev)->pci_device == 0x0042) | 936 | #define IS_IRONLAKE_D(dev) ((dev)->pci_device == 0x0042) |
917 | #define IS_IRONLAKE_M(dev) ((dev)->pci_device == 0x0046) | 937 | #define IS_IRONLAKE_M(dev) ((dev)->pci_device == 0x0046) |
938 | #define IS_IVYBRIDGE(dev) (INTEL_INFO(dev)->is_ivybridge) | ||
918 | #define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile) | 939 | #define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile) |
919 | 940 | ||
941 | /* | ||
942 | * The genX designation typically refers to the render engine, so render | ||
943 | * capability related checks should use IS_GEN, while display and other checks | ||
944 | * have their own (e.g. HAS_PCH_SPLIT for ILK+ display, IS_foo for particular | ||
945 | * chips, etc.). | ||
946 | */ | ||
920 | #define IS_GEN2(dev) (INTEL_INFO(dev)->gen == 2) | 947 | #define IS_GEN2(dev) (INTEL_INFO(dev)->gen == 2) |
921 | #define IS_GEN3(dev) (INTEL_INFO(dev)->gen == 3) | 948 | #define IS_GEN3(dev) (INTEL_INFO(dev)->gen == 3) |
922 | #define IS_GEN4(dev) (INTEL_INFO(dev)->gen == 4) | 949 | #define IS_GEN4(dev) (INTEL_INFO(dev)->gen == 4) |
923 | #define IS_GEN5(dev) (INTEL_INFO(dev)->gen == 5) | 950 | #define IS_GEN5(dev) (INTEL_INFO(dev)->gen == 5) |
924 | #define IS_GEN6(dev) (INTEL_INFO(dev)->gen == 6) | 951 | #define IS_GEN6(dev) (INTEL_INFO(dev)->gen == 6) |
952 | #define IS_GEN7(dev) (INTEL_INFO(dev)->gen == 7) | ||
925 | 953 | ||
926 | #define HAS_BSD(dev) (INTEL_INFO(dev)->has_bsd_ring) | 954 | #define HAS_BSD(dev) (INTEL_INFO(dev)->has_bsd_ring) |
927 | #define HAS_BLT(dev) (INTEL_INFO(dev)->has_blt_ring) | 955 | #define HAS_BLT(dev) (INTEL_INFO(dev)->has_blt_ring) |
@@ -948,8 +976,8 @@ enum intel_chip_family { | |||
948 | #define HAS_PIPE_CXSR(dev) (INTEL_INFO(dev)->has_pipe_cxsr) | 976 | #define HAS_PIPE_CXSR(dev) (INTEL_INFO(dev)->has_pipe_cxsr) |
949 | #define I915_HAS_FBC(dev) (INTEL_INFO(dev)->has_fbc) | 977 | #define I915_HAS_FBC(dev) (INTEL_INFO(dev)->has_fbc) |
950 | 978 | ||
951 | #define HAS_PCH_SPLIT(dev) (IS_GEN5(dev) || IS_GEN6(dev)) | 979 | #define HAS_PCH_SPLIT(dev) (IS_GEN5(dev) || IS_GEN6(dev) || IS_IVYBRIDGE(dev)) |
952 | #define HAS_PIPE_CONTROL(dev) (IS_GEN5(dev) || IS_GEN6(dev)) | 980 | #define HAS_PIPE_CONTROL(dev) (INTEL_INFO(dev)->gen >= 5) |
953 | 981 | ||
954 | #define INTEL_PCH_TYPE(dev) (((struct drm_i915_private *)(dev)->dev_private)->pch_type) | 982 | #define INTEL_PCH_TYPE(dev) (((struct drm_i915_private *)(dev)->dev_private)->pch_type) |
955 | #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT) | 983 | #define HAS_PCH_CPT(dev) (INTEL_PCH_TYPE(dev) == PCH_CPT) |
@@ -1010,12 +1038,27 @@ extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); | |||
1010 | extern void i915_driver_irq_preinstall(struct drm_device * dev); | 1038 | extern void i915_driver_irq_preinstall(struct drm_device * dev); |
1011 | extern int i915_driver_irq_postinstall(struct drm_device *dev); | 1039 | extern int i915_driver_irq_postinstall(struct drm_device *dev); |
1012 | extern void i915_driver_irq_uninstall(struct drm_device * dev); | 1040 | extern void i915_driver_irq_uninstall(struct drm_device * dev); |
1041 | |||
1042 | extern irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS); | ||
1043 | extern void ironlake_irq_preinstall(struct drm_device *dev); | ||
1044 | extern int ironlake_irq_postinstall(struct drm_device *dev); | ||
1045 | extern void ironlake_irq_uninstall(struct drm_device *dev); | ||
1046 | |||
1047 | extern irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS); | ||
1048 | extern void ivybridge_irq_preinstall(struct drm_device *dev); | ||
1049 | extern int ivybridge_irq_postinstall(struct drm_device *dev); | ||
1050 | extern void ivybridge_irq_uninstall(struct drm_device *dev); | ||
1051 | |||
1013 | extern int i915_vblank_pipe_set(struct drm_device *dev, void *data, | 1052 | extern int i915_vblank_pipe_set(struct drm_device *dev, void *data, |
1014 | struct drm_file *file_priv); | 1053 | struct drm_file *file_priv); |
1015 | extern int i915_vblank_pipe_get(struct drm_device *dev, void *data, | 1054 | extern int i915_vblank_pipe_get(struct drm_device *dev, void *data, |
1016 | struct drm_file *file_priv); | 1055 | struct drm_file *file_priv); |
1017 | extern int i915_enable_vblank(struct drm_device *dev, int crtc); | 1056 | extern int i915_enable_vblank(struct drm_device *dev, int crtc); |
1018 | extern void i915_disable_vblank(struct drm_device *dev, int crtc); | 1057 | extern void i915_disable_vblank(struct drm_device *dev, int crtc); |
1058 | extern int ironlake_enable_vblank(struct drm_device *dev, int crtc); | ||
1059 | extern void ironlake_disable_vblank(struct drm_device *dev, int crtc); | ||
1060 | extern int ivybridge_enable_vblank(struct drm_device *dev, int crtc); | ||
1061 | extern void ivybridge_disable_vblank(struct drm_device *dev, int crtc); | ||
1019 | extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc); | 1062 | extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc); |
1020 | extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc); | 1063 | extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc); |
1021 | extern int i915_vblank_swap(struct drm_device *dev, void *data, | 1064 | extern int i915_vblank_swap(struct drm_device *dev, void *data, |
@@ -1265,6 +1308,7 @@ static inline void intel_unregister_dsm_handler(void) { return; } | |||
1265 | 1308 | ||
1266 | /* modesetting */ | 1309 | /* modesetting */ |
1267 | extern void intel_modeset_init(struct drm_device *dev); | 1310 | extern void intel_modeset_init(struct drm_device *dev); |
1311 | extern void intel_modeset_gem_init(struct drm_device *dev); | ||
1268 | extern void intel_modeset_cleanup(struct drm_device *dev); | 1312 | extern void intel_modeset_cleanup(struct drm_device *dev); |
1269 | extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state); | 1313 | extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state); |
1270 | extern void i8xx_disable_fbc(struct drm_device *dev); | 1314 | extern void i8xx_disable_fbc(struct drm_device *dev); |
@@ -1312,13 +1356,34 @@ extern void intel_display_print_error_state(struct seq_file *m, | |||
1312 | LOCK_TEST_WITH_RETURN(dev, file); \ | 1356 | LOCK_TEST_WITH_RETURN(dev, file); \ |
1313 | } while (0) | 1357 | } while (0) |
1314 | 1358 | ||
1359 | /* On SNB platform, before reading ring registers forcewake bit | ||
1360 | * must be set to prevent GT core from power down and stale values being | ||
1361 | * returned. | ||
1362 | */ | ||
1363 | void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv); | ||
1364 | void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv); | ||
1365 | void __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv); | ||
1366 | |||
1367 | /* We give fast paths for the really cool registers */ | ||
1368 | #define NEEDS_FORCE_WAKE(dev_priv, reg) \ | ||
1369 | (((dev_priv)->info->gen >= 6) && \ | ||
1370 | ((reg) < 0x40000) && \ | ||
1371 | ((reg) != FORCEWAKE)) | ||
1315 | 1372 | ||
1316 | #define __i915_read(x, y) \ | 1373 | #define __i915_read(x, y) \ |
1317 | static inline u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ | 1374 | static inline u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ |
1318 | u##x val = read##y(dev_priv->regs + reg); \ | 1375 | u##x val = 0; \ |
1376 | if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ | ||
1377 | gen6_gt_force_wake_get(dev_priv); \ | ||
1378 | val = read##y(dev_priv->regs + reg); \ | ||
1379 | gen6_gt_force_wake_put(dev_priv); \ | ||
1380 | } else { \ | ||
1381 | val = read##y(dev_priv->regs + reg); \ | ||
1382 | } \ | ||
1319 | trace_i915_reg_rw(false, reg, val, sizeof(val)); \ | 1383 | trace_i915_reg_rw(false, reg, val, sizeof(val)); \ |
1320 | return val; \ | 1384 | return val; \ |
1321 | } | 1385 | } |
1386 | |||
1322 | __i915_read(8, b) | 1387 | __i915_read(8, b) |
1323 | __i915_read(16, w) | 1388 | __i915_read(16, w) |
1324 | __i915_read(32, l) | 1389 | __i915_read(32, l) |
@@ -1328,6 +1393,9 @@ __i915_read(64, q) | |||
1328 | #define __i915_write(x, y) \ | 1393 | #define __i915_write(x, y) \ |
1329 | static inline void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ | 1394 | static inline void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ |
1330 | trace_i915_reg_rw(true, reg, val, sizeof(val)); \ | 1395 | trace_i915_reg_rw(true, reg, val, sizeof(val)); \ |
1396 | if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ | ||
1397 | __gen6_gt_wait_for_fifo(dev_priv); \ | ||
1398 | } \ | ||
1331 | write##y(val, dev_priv->regs + reg); \ | 1399 | write##y(val, dev_priv->regs + reg); \ |
1332 | } | 1400 | } |
1333 | __i915_write(8, b) | 1401 | __i915_write(8, b) |
@@ -1356,33 +1424,4 @@ __i915_write(64, q) | |||
1356 | #define POSTING_READ16(reg) (void)I915_READ16_NOTRACE(reg) | 1424 | #define POSTING_READ16(reg) (void)I915_READ16_NOTRACE(reg) |
1357 | 1425 | ||
1358 | 1426 | ||
1359 | /* On SNB platform, before reading ring registers forcewake bit | ||
1360 | * must be set to prevent GT core from power down and stale values being | ||
1361 | * returned. | ||
1362 | */ | ||
1363 | void __gen6_gt_force_wake_get(struct drm_i915_private *dev_priv); | ||
1364 | void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv); | ||
1365 | void __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv); | ||
1366 | |||
1367 | static inline u32 i915_gt_read(struct drm_i915_private *dev_priv, u32 reg) | ||
1368 | { | ||
1369 | u32 val; | ||
1370 | |||
1371 | if (dev_priv->info->gen >= 6) { | ||
1372 | __gen6_gt_force_wake_get(dev_priv); | ||
1373 | val = I915_READ(reg); | ||
1374 | __gen6_gt_force_wake_put(dev_priv); | ||
1375 | } else | ||
1376 | val = I915_READ(reg); | ||
1377 | |||
1378 | return val; | ||
1379 | } | ||
1380 | |||
1381 | static inline void i915_gt_write(struct drm_i915_private *dev_priv, | ||
1382 | u32 reg, u32 val) | ||
1383 | { | ||
1384 | if (dev_priv->info->gen >= 6) | ||
1385 | __gen6_gt_wait_for_fifo(dev_priv); | ||
1386 | I915_WRITE(reg, val); | ||
1387 | } | ||
1388 | #endif | 1427 | #endif |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 7ce3f353af33..c6289034e29a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -2673,6 +2673,7 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj, | |||
2673 | update: | 2673 | update: |
2674 | obj->tiling_changed = false; | 2674 | obj->tiling_changed = false; |
2675 | switch (INTEL_INFO(dev)->gen) { | 2675 | switch (INTEL_INFO(dev)->gen) { |
2676 | case 7: | ||
2676 | case 6: | 2677 | case 6: |
2677 | ret = sandybridge_write_fence_reg(obj, pipelined); | 2678 | ret = sandybridge_write_fence_reg(obj, pipelined); |
2678 | break; | 2679 | break; |
@@ -2706,6 +2707,7 @@ i915_gem_clear_fence_reg(struct drm_device *dev, | |||
2706 | uint32_t fence_reg = reg - dev_priv->fence_regs; | 2707 | uint32_t fence_reg = reg - dev_priv->fence_regs; |
2707 | 2708 | ||
2708 | switch (INTEL_INFO(dev)->gen) { | 2709 | switch (INTEL_INFO(dev)->gen) { |
2710 | case 7: | ||
2709 | case 6: | 2711 | case 6: |
2710 | I915_WRITE64(FENCE_REG_SANDYBRIDGE_0 + fence_reg*8, 0); | 2712 | I915_WRITE64(FENCE_REG_SANDYBRIDGE_0 + fence_reg*8, 0); |
2711 | break; | 2713 | break; |
@@ -2878,6 +2880,17 @@ i915_gem_clflush_object(struct drm_i915_gem_object *obj) | |||
2878 | if (obj->pages == NULL) | 2880 | if (obj->pages == NULL) |
2879 | return; | 2881 | return; |
2880 | 2882 | ||
2883 | /* If the GPU is snooping the contents of the CPU cache, | ||
2884 | * we do not need to manually clear the CPU cache lines. However, | ||
2885 | * the caches are only snooped when the render cache is | ||
2886 | * flushed/invalidated. As we always have to emit invalidations | ||
2887 | * and flushes when moving into and out of the RENDER domain, correct | ||
2888 | * snooping behaviour occurs naturally as the result of our domain | ||
2889 | * tracking. | ||
2890 | */ | ||
2891 | if (obj->cache_level != I915_CACHE_NONE) | ||
2892 | return; | ||
2893 | |||
2881 | trace_i915_gem_object_clflush(obj); | 2894 | trace_i915_gem_object_clflush(obj); |
2882 | 2895 | ||
2883 | drm_clflush_pages(obj->pages, obj->base.size / PAGE_SIZE); | 2896 | drm_clflush_pages(obj->pages, obj->base.size / PAGE_SIZE); |
@@ -3569,7 +3582,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, | |||
3569 | obj->base.write_domain = I915_GEM_DOMAIN_CPU; | 3582 | obj->base.write_domain = I915_GEM_DOMAIN_CPU; |
3570 | obj->base.read_domains = I915_GEM_DOMAIN_CPU; | 3583 | obj->base.read_domains = I915_GEM_DOMAIN_CPU; |
3571 | 3584 | ||
3572 | obj->agp_type = AGP_USER_MEMORY; | 3585 | obj->cache_level = I915_CACHE_NONE; |
3573 | obj->base.driver_private = NULL; | 3586 | obj->base.driver_private = NULL; |
3574 | obj->fence_reg = I915_FENCE_REG_NONE; | 3587 | obj->fence_reg = I915_FENCE_REG_NONE; |
3575 | INIT_LIST_HEAD(&obj->mm_list); | 3588 | INIT_LIST_HEAD(&obj->mm_list); |
@@ -3845,25 +3858,10 @@ i915_gem_load(struct drm_device *dev) | |||
3845 | dev_priv->num_fence_regs = 8; | 3858 | dev_priv->num_fence_regs = 8; |
3846 | 3859 | ||
3847 | /* Initialize fence registers to zero */ | 3860 | /* Initialize fence registers to zero */ |
3848 | switch (INTEL_INFO(dev)->gen) { | 3861 | for (i = 0; i < dev_priv->num_fence_regs; i++) { |
3849 | case 6: | 3862 | i915_gem_clear_fence_reg(dev, &dev_priv->fence_regs[i]); |
3850 | for (i = 0; i < 16; i++) | ||
3851 | I915_WRITE64(FENCE_REG_SANDYBRIDGE_0 + (i * 8), 0); | ||
3852 | break; | ||
3853 | case 5: | ||
3854 | case 4: | ||
3855 | for (i = 0; i < 16; i++) | ||
3856 | I915_WRITE64(FENCE_REG_965_0 + (i * 8), 0); | ||
3857 | break; | ||
3858 | case 3: | ||
3859 | if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) | ||
3860 | for (i = 0; i < 8; i++) | ||
3861 | I915_WRITE(FENCE_REG_945_8 + (i * 4), 0); | ||
3862 | case 2: | ||
3863 | for (i = 0; i < 8; i++) | ||
3864 | I915_WRITE(FENCE_REG_830_0 + (i * 4), 0); | ||
3865 | break; | ||
3866 | } | 3863 | } |
3864 | |||
3867 | i915_gem_detect_bit_6_swizzle(dev); | 3865 | i915_gem_detect_bit_6_swizzle(dev); |
3868 | init_waitqueue_head(&dev_priv->pending_flip_queue); | 3866 | init_waitqueue_head(&dev_priv->pending_flip_queue); |
3869 | 3867 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index b0abdc64aa9f..e46b645773cf 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c | |||
@@ -29,6 +29,26 @@ | |||
29 | #include "i915_trace.h" | 29 | #include "i915_trace.h" |
30 | #include "intel_drv.h" | 30 | #include "intel_drv.h" |
31 | 31 | ||
32 | /* XXX kill agp_type! */ | ||
33 | static unsigned int cache_level_to_agp_type(struct drm_device *dev, | ||
34 | enum i915_cache_level cache_level) | ||
35 | { | ||
36 | switch (cache_level) { | ||
37 | case I915_CACHE_LLC_MLC: | ||
38 | if (INTEL_INFO(dev)->gen >= 6) | ||
39 | return AGP_USER_CACHED_MEMORY_LLC_MLC; | ||
40 | /* Older chipsets do not have this extra level of CPU | ||
41 | * cacheing, so fallthrough and request the PTE simply | ||
42 | * as cached. | ||
43 | */ | ||
44 | case I915_CACHE_LLC: | ||
45 | return AGP_USER_CACHED_MEMORY; | ||
46 | default: | ||
47 | case I915_CACHE_NONE: | ||
48 | return AGP_USER_MEMORY; | ||
49 | } | ||
50 | } | ||
51 | |||
32 | void i915_gem_restore_gtt_mappings(struct drm_device *dev) | 52 | void i915_gem_restore_gtt_mappings(struct drm_device *dev) |
33 | { | 53 | { |
34 | struct drm_i915_private *dev_priv = dev->dev_private; | 54 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -39,6 +59,9 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) | |||
39 | (dev_priv->mm.gtt_end - dev_priv->mm.gtt_start) / PAGE_SIZE); | 59 | (dev_priv->mm.gtt_end - dev_priv->mm.gtt_start) / PAGE_SIZE); |
40 | 60 | ||
41 | list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { | 61 | list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { |
62 | unsigned int agp_type = | ||
63 | cache_level_to_agp_type(dev, obj->cache_level); | ||
64 | |||
42 | i915_gem_clflush_object(obj); | 65 | i915_gem_clflush_object(obj); |
43 | 66 | ||
44 | if (dev_priv->mm.gtt->needs_dmar) { | 67 | if (dev_priv->mm.gtt->needs_dmar) { |
@@ -46,15 +69,14 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) | |||
46 | 69 | ||
47 | intel_gtt_insert_sg_entries(obj->sg_list, | 70 | intel_gtt_insert_sg_entries(obj->sg_list, |
48 | obj->num_sg, | 71 | obj->num_sg, |
49 | obj->gtt_space->start | 72 | obj->gtt_space->start >> PAGE_SHIFT, |
50 | >> PAGE_SHIFT, | 73 | agp_type); |
51 | obj->agp_type); | ||
52 | } else | 74 | } else |
53 | intel_gtt_insert_pages(obj->gtt_space->start | 75 | intel_gtt_insert_pages(obj->gtt_space->start |
54 | >> PAGE_SHIFT, | 76 | >> PAGE_SHIFT, |
55 | obj->base.size >> PAGE_SHIFT, | 77 | obj->base.size >> PAGE_SHIFT, |
56 | obj->pages, | 78 | obj->pages, |
57 | obj->agp_type); | 79 | agp_type); |
58 | } | 80 | } |
59 | 81 | ||
60 | intel_gtt_chipset_flush(); | 82 | intel_gtt_chipset_flush(); |
@@ -64,6 +86,7 @@ int i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj) | |||
64 | { | 86 | { |
65 | struct drm_device *dev = obj->base.dev; | 87 | struct drm_device *dev = obj->base.dev; |
66 | struct drm_i915_private *dev_priv = dev->dev_private; | 88 | struct drm_i915_private *dev_priv = dev->dev_private; |
89 | unsigned int agp_type = cache_level_to_agp_type(dev, obj->cache_level); | ||
67 | int ret; | 90 | int ret; |
68 | 91 | ||
69 | if (dev_priv->mm.gtt->needs_dmar) { | 92 | if (dev_priv->mm.gtt->needs_dmar) { |
@@ -77,12 +100,12 @@ int i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj) | |||
77 | intel_gtt_insert_sg_entries(obj->sg_list, | 100 | intel_gtt_insert_sg_entries(obj->sg_list, |
78 | obj->num_sg, | 101 | obj->num_sg, |
79 | obj->gtt_space->start >> PAGE_SHIFT, | 102 | obj->gtt_space->start >> PAGE_SHIFT, |
80 | obj->agp_type); | 103 | agp_type); |
81 | } else | 104 | } else |
82 | intel_gtt_insert_pages(obj->gtt_space->start >> PAGE_SHIFT, | 105 | intel_gtt_insert_pages(obj->gtt_space->start >> PAGE_SHIFT, |
83 | obj->base.size >> PAGE_SHIFT, | 106 | obj->base.size >> PAGE_SHIFT, |
84 | obj->pages, | 107 | obj->pages, |
85 | obj->agp_type); | 108 | agp_type); |
86 | 109 | ||
87 | return 0; | 110 | return 0; |
88 | } | 111 | } |
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c index 281ad3d6115d..82d70fd9e933 100644 --- a/drivers/gpu/drm/i915/i915_gem_tiling.c +++ b/drivers/gpu/drm/i915/i915_gem_tiling.c | |||
@@ -92,7 +92,7 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev) | |||
92 | uint32_t swizzle_x = I915_BIT_6_SWIZZLE_UNKNOWN; | 92 | uint32_t swizzle_x = I915_BIT_6_SWIZZLE_UNKNOWN; |
93 | uint32_t swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN; | 93 | uint32_t swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN; |
94 | 94 | ||
95 | if (IS_GEN5(dev) || IS_GEN6(dev)) { | 95 | if (INTEL_INFO(dev)->gen >= 5) { |
96 | /* On Ironlake whatever DRAM config, GPU always do | 96 | /* On Ironlake whatever DRAM config, GPU always do |
97 | * same swizzling setup. | 97 | * same swizzling setup. |
98 | */ | 98 | */ |
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 188b497e5076..349a03e48481 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c | |||
@@ -367,22 +367,30 @@ static void notify_ring(struct drm_device *dev, | |||
367 | jiffies + msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD)); | 367 | jiffies + msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD)); |
368 | } | 368 | } |
369 | 369 | ||
370 | static void gen6_pm_irq_handler(struct drm_device *dev) | 370 | static void gen6_pm_rps_work(struct work_struct *work) |
371 | { | 371 | { |
372 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 372 | drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t, |
373 | rps_work); | ||
373 | u8 new_delay = dev_priv->cur_delay; | 374 | u8 new_delay = dev_priv->cur_delay; |
374 | u32 pm_iir; | 375 | u32 pm_iir, pm_imr; |
376 | |||
377 | spin_lock_irq(&dev_priv->rps_lock); | ||
378 | pm_iir = dev_priv->pm_iir; | ||
379 | dev_priv->pm_iir = 0; | ||
380 | pm_imr = I915_READ(GEN6_PMIMR); | ||
381 | spin_unlock_irq(&dev_priv->rps_lock); | ||
375 | 382 | ||
376 | pm_iir = I915_READ(GEN6_PMIIR); | ||
377 | if (!pm_iir) | 383 | if (!pm_iir) |
378 | return; | 384 | return; |
379 | 385 | ||
386 | mutex_lock(&dev_priv->dev->struct_mutex); | ||
380 | if (pm_iir & GEN6_PM_RP_UP_THRESHOLD) { | 387 | if (pm_iir & GEN6_PM_RP_UP_THRESHOLD) { |
381 | if (dev_priv->cur_delay != dev_priv->max_delay) | 388 | if (dev_priv->cur_delay != dev_priv->max_delay) |
382 | new_delay = dev_priv->cur_delay + 1; | 389 | new_delay = dev_priv->cur_delay + 1; |
383 | if (new_delay > dev_priv->max_delay) | 390 | if (new_delay > dev_priv->max_delay) |
384 | new_delay = dev_priv->max_delay; | 391 | new_delay = dev_priv->max_delay; |
385 | } else if (pm_iir & (GEN6_PM_RP_DOWN_THRESHOLD | GEN6_PM_RP_DOWN_TIMEOUT)) { | 392 | } else if (pm_iir & (GEN6_PM_RP_DOWN_THRESHOLD | GEN6_PM_RP_DOWN_TIMEOUT)) { |
393 | gen6_gt_force_wake_get(dev_priv); | ||
386 | if (dev_priv->cur_delay != dev_priv->min_delay) | 394 | if (dev_priv->cur_delay != dev_priv->min_delay) |
387 | new_delay = dev_priv->cur_delay - 1; | 395 | new_delay = dev_priv->cur_delay - 1; |
388 | if (new_delay < dev_priv->min_delay) { | 396 | if (new_delay < dev_priv->min_delay) { |
@@ -396,13 +404,19 @@ static void gen6_pm_irq_handler(struct drm_device *dev) | |||
396 | I915_WRITE(GEN6_RP_INTERRUPT_LIMITS, | 404 | I915_WRITE(GEN6_RP_INTERRUPT_LIMITS, |
397 | I915_READ(GEN6_RP_INTERRUPT_LIMITS) & ~0x3f0000); | 405 | I915_READ(GEN6_RP_INTERRUPT_LIMITS) & ~0x3f0000); |
398 | } | 406 | } |
399 | 407 | gen6_gt_force_wake_put(dev_priv); | |
400 | } | 408 | } |
401 | 409 | ||
402 | gen6_set_rps(dev, new_delay); | 410 | gen6_set_rps(dev_priv->dev, new_delay); |
403 | dev_priv->cur_delay = new_delay; | 411 | dev_priv->cur_delay = new_delay; |
404 | 412 | ||
405 | I915_WRITE(GEN6_PMIIR, pm_iir); | 413 | /* |
414 | * rps_lock not held here because clearing is non-destructive. There is | ||
415 | * an *extremely* unlikely race with gen6_rps_enable() that is prevented | ||
416 | * by holding struct_mutex for the duration of the write. | ||
417 | */ | ||
418 | I915_WRITE(GEN6_PMIMR, pm_imr & ~pm_iir); | ||
419 | mutex_unlock(&dev_priv->dev->struct_mutex); | ||
406 | } | 420 | } |
407 | 421 | ||
408 | static void pch_irq_handler(struct drm_device *dev) | 422 | static void pch_irq_handler(struct drm_device *dev) |
@@ -448,8 +462,97 @@ static void pch_irq_handler(struct drm_device *dev) | |||
448 | DRM_DEBUG_DRIVER("PCH transcoder A underrun interrupt\n"); | 462 | DRM_DEBUG_DRIVER("PCH transcoder A underrun interrupt\n"); |
449 | } | 463 | } |
450 | 464 | ||
451 | static irqreturn_t ironlake_irq_handler(struct drm_device *dev) | 465 | irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS) |
466 | { | ||
467 | struct drm_device *dev = (struct drm_device *) arg; | ||
468 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | ||
469 | int ret = IRQ_NONE; | ||
470 | u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir; | ||
471 | struct drm_i915_master_private *master_priv; | ||
472 | |||
473 | atomic_inc(&dev_priv->irq_received); | ||
474 | |||
475 | /* disable master interrupt before clearing iir */ | ||
476 | de_ier = I915_READ(DEIER); | ||
477 | I915_WRITE(DEIER, de_ier & ~DE_MASTER_IRQ_CONTROL); | ||
478 | POSTING_READ(DEIER); | ||
479 | |||
480 | de_iir = I915_READ(DEIIR); | ||
481 | gt_iir = I915_READ(GTIIR); | ||
482 | pch_iir = I915_READ(SDEIIR); | ||
483 | pm_iir = I915_READ(GEN6_PMIIR); | ||
484 | |||
485 | if (de_iir == 0 && gt_iir == 0 && pch_iir == 0 && pm_iir == 0) | ||
486 | goto done; | ||
487 | |||
488 | ret = IRQ_HANDLED; | ||
489 | |||
490 | if (dev->primary->master) { | ||
491 | master_priv = dev->primary->master->driver_priv; | ||
492 | if (master_priv->sarea_priv) | ||
493 | master_priv->sarea_priv->last_dispatch = | ||
494 | READ_BREADCRUMB(dev_priv); | ||
495 | } | ||
496 | |||
497 | if (gt_iir & (GT_USER_INTERRUPT | GT_PIPE_NOTIFY)) | ||
498 | notify_ring(dev, &dev_priv->ring[RCS]); | ||
499 | if (gt_iir & GT_GEN6_BSD_USER_INTERRUPT) | ||
500 | notify_ring(dev, &dev_priv->ring[VCS]); | ||
501 | if (gt_iir & GT_BLT_USER_INTERRUPT) | ||
502 | notify_ring(dev, &dev_priv->ring[BCS]); | ||
503 | |||
504 | if (de_iir & DE_GSE_IVB) | ||
505 | intel_opregion_gse_intr(dev); | ||
506 | |||
507 | if (de_iir & DE_PLANEA_FLIP_DONE_IVB) { | ||
508 | intel_prepare_page_flip(dev, 0); | ||
509 | intel_finish_page_flip_plane(dev, 0); | ||
510 | } | ||
511 | |||
512 | if (de_iir & DE_PLANEB_FLIP_DONE_IVB) { | ||
513 | intel_prepare_page_flip(dev, 1); | ||
514 | intel_finish_page_flip_plane(dev, 1); | ||
515 | } | ||
516 | |||
517 | if (de_iir & DE_PIPEA_VBLANK_IVB) | ||
518 | drm_handle_vblank(dev, 0); | ||
519 | |||
520 | if (de_iir & DE_PIPEB_VBLANK_IVB); | ||
521 | drm_handle_vblank(dev, 1); | ||
522 | |||
523 | /* check event from PCH */ | ||
524 | if (de_iir & DE_PCH_EVENT_IVB) { | ||
525 | if (pch_iir & SDE_HOTPLUG_MASK_CPT) | ||
526 | queue_work(dev_priv->wq, &dev_priv->hotplug_work); | ||
527 | pch_irq_handler(dev); | ||
528 | } | ||
529 | |||
530 | if (pm_iir & GEN6_PM_DEFERRED_EVENTS) { | ||
531 | unsigned long flags; | ||
532 | spin_lock_irqsave(&dev_priv->rps_lock, flags); | ||
533 | WARN(dev_priv->pm_iir & pm_iir, "Missed a PM interrupt\n"); | ||
534 | I915_WRITE(GEN6_PMIMR, pm_iir); | ||
535 | dev_priv->pm_iir |= pm_iir; | ||
536 | spin_unlock_irqrestore(&dev_priv->rps_lock, flags); | ||
537 | queue_work(dev_priv->wq, &dev_priv->rps_work); | ||
538 | } | ||
539 | |||
540 | /* should clear PCH hotplug event before clear CPU irq */ | ||
541 | I915_WRITE(SDEIIR, pch_iir); | ||
542 | I915_WRITE(GTIIR, gt_iir); | ||
543 | I915_WRITE(DEIIR, de_iir); | ||
544 | I915_WRITE(GEN6_PMIIR, pm_iir); | ||
545 | |||
546 | done: | ||
547 | I915_WRITE(DEIER, de_ier); | ||
548 | POSTING_READ(DEIER); | ||
549 | |||
550 | return ret; | ||
551 | } | ||
552 | |||
553 | irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS) | ||
452 | { | 554 | { |
555 | struct drm_device *dev = (struct drm_device *) arg; | ||
453 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 556 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
454 | int ret = IRQ_NONE; | 557 | int ret = IRQ_NONE; |
455 | u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir; | 558 | u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir; |
@@ -457,6 +560,8 @@ static irqreturn_t ironlake_irq_handler(struct drm_device *dev) | |||
457 | struct drm_i915_master_private *master_priv; | 560 | struct drm_i915_master_private *master_priv; |
458 | u32 bsd_usr_interrupt = GT_BSD_USER_INTERRUPT; | 561 | u32 bsd_usr_interrupt = GT_BSD_USER_INTERRUPT; |
459 | 562 | ||
563 | atomic_inc(&dev_priv->irq_received); | ||
564 | |||
460 | if (IS_GEN6(dev)) | 565 | if (IS_GEN6(dev)) |
461 | bsd_usr_interrupt = GT_GEN6_BSD_USER_INTERRUPT; | 566 | bsd_usr_interrupt = GT_GEN6_BSD_USER_INTERRUPT; |
462 | 567 | ||
@@ -526,13 +631,30 @@ static irqreturn_t ironlake_irq_handler(struct drm_device *dev) | |||
526 | i915_handle_rps_change(dev); | 631 | i915_handle_rps_change(dev); |
527 | } | 632 | } |
528 | 633 | ||
529 | if (IS_GEN6(dev)) | 634 | if (IS_GEN6(dev) && pm_iir & GEN6_PM_DEFERRED_EVENTS) { |
530 | gen6_pm_irq_handler(dev); | 635 | /* |
636 | * IIR bits should never already be set because IMR should | ||
637 | * prevent an interrupt from being shown in IIR. The warning | ||
638 | * displays a case where we've unsafely cleared | ||
639 | * dev_priv->pm_iir. Although missing an interrupt of the same | ||
640 | * type is not a problem, it displays a problem in the logic. | ||
641 | * | ||
642 | * The mask bit in IMR is cleared by rps_work. | ||
643 | */ | ||
644 | unsigned long flags; | ||
645 | spin_lock_irqsave(&dev_priv->rps_lock, flags); | ||
646 | WARN(dev_priv->pm_iir & pm_iir, "Missed a PM interrupt\n"); | ||
647 | I915_WRITE(GEN6_PMIMR, pm_iir); | ||
648 | dev_priv->pm_iir |= pm_iir; | ||
649 | spin_unlock_irqrestore(&dev_priv->rps_lock, flags); | ||
650 | queue_work(dev_priv->wq, &dev_priv->rps_work); | ||
651 | } | ||
531 | 652 | ||
532 | /* should clear PCH hotplug event before clear CPU irq */ | 653 | /* should clear PCH hotplug event before clear CPU irq */ |
533 | I915_WRITE(SDEIIR, pch_iir); | 654 | I915_WRITE(SDEIIR, pch_iir); |
534 | I915_WRITE(GTIIR, gt_iir); | 655 | I915_WRITE(GTIIR, gt_iir); |
535 | I915_WRITE(DEIIR, de_iir); | 656 | I915_WRITE(DEIIR, de_iir); |
657 | I915_WRITE(GEN6_PMIIR, pm_iir); | ||
536 | 658 | ||
537 | done: | 659 | done: |
538 | I915_WRITE(DEIER, de_ier); | 660 | I915_WRITE(DEIER, de_ier); |
@@ -676,7 +798,7 @@ static u32 capture_bo_list(struct drm_i915_error_buffer *err, | |||
676 | err->dirty = obj->dirty; | 798 | err->dirty = obj->dirty; |
677 | err->purgeable = obj->madv != I915_MADV_WILLNEED; | 799 | err->purgeable = obj->madv != I915_MADV_WILLNEED; |
678 | err->ring = obj->ring ? obj->ring->id : 0; | 800 | err->ring = obj->ring ? obj->ring->id : 0; |
679 | err->agp_type = obj->agp_type == AGP_USER_CACHED_MEMORY; | 801 | err->cache_level = obj->cache_level; |
680 | 802 | ||
681 | if (++i == count) | 803 | if (++i == count) |
682 | break; | 804 | break; |
@@ -1103,9 +1225,6 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) | |||
1103 | 1225 | ||
1104 | atomic_inc(&dev_priv->irq_received); | 1226 | atomic_inc(&dev_priv->irq_received); |
1105 | 1227 | ||
1106 | if (HAS_PCH_SPLIT(dev)) | ||
1107 | return ironlake_irq_handler(dev); | ||
1108 | |||
1109 | iir = I915_READ(IIR); | 1228 | iir = I915_READ(IIR); |
1110 | 1229 | ||
1111 | if (INTEL_INFO(dev)->gen >= 4) | 1230 | if (INTEL_INFO(dev)->gen >= 4) |
@@ -1344,10 +1463,7 @@ int i915_enable_vblank(struct drm_device *dev, int pipe) | |||
1344 | return -EINVAL; | 1463 | return -EINVAL; |
1345 | 1464 | ||
1346 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); | 1465 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); |
1347 | if (HAS_PCH_SPLIT(dev)) | 1466 | if (INTEL_INFO(dev)->gen >= 4) |
1348 | ironlake_enable_display_irq(dev_priv, (pipe == 0) ? | ||
1349 | DE_PIPEA_VBLANK: DE_PIPEB_VBLANK); | ||
1350 | else if (INTEL_INFO(dev)->gen >= 4) | ||
1351 | i915_enable_pipestat(dev_priv, pipe, | 1467 | i915_enable_pipestat(dev_priv, pipe, |
1352 | PIPE_START_VBLANK_INTERRUPT_ENABLE); | 1468 | PIPE_START_VBLANK_INTERRUPT_ENABLE); |
1353 | else | 1469 | else |
@@ -1362,6 +1478,38 @@ int i915_enable_vblank(struct drm_device *dev, int pipe) | |||
1362 | return 0; | 1478 | return 0; |
1363 | } | 1479 | } |
1364 | 1480 | ||
1481 | int ironlake_enable_vblank(struct drm_device *dev, int pipe) | ||
1482 | { | ||
1483 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | ||
1484 | unsigned long irqflags; | ||
1485 | |||
1486 | if (!i915_pipe_enabled(dev, pipe)) | ||
1487 | return -EINVAL; | ||
1488 | |||
1489 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); | ||
1490 | ironlake_enable_display_irq(dev_priv, (pipe == 0) ? | ||
1491 | DE_PIPEA_VBLANK: DE_PIPEB_VBLANK); | ||
1492 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); | ||
1493 | |||
1494 | return 0; | ||
1495 | } | ||
1496 | |||
1497 | int ivybridge_enable_vblank(struct drm_device *dev, int pipe) | ||
1498 | { | ||
1499 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | ||
1500 | unsigned long irqflags; | ||
1501 | |||
1502 | if (!i915_pipe_enabled(dev, pipe)) | ||
1503 | return -EINVAL; | ||
1504 | |||
1505 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); | ||
1506 | ironlake_enable_display_irq(dev_priv, (pipe == 0) ? | ||
1507 | DE_PIPEA_VBLANK_IVB : DE_PIPEB_VBLANK_IVB); | ||
1508 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); | ||
1509 | |||
1510 | return 0; | ||
1511 | } | ||
1512 | |||
1365 | /* Called from drm generic code, passed 'crtc' which | 1513 | /* Called from drm generic code, passed 'crtc' which |
1366 | * we use as a pipe index | 1514 | * we use as a pipe index |
1367 | */ | 1515 | */ |
@@ -1375,13 +1523,31 @@ void i915_disable_vblank(struct drm_device *dev, int pipe) | |||
1375 | I915_WRITE(INSTPM, | 1523 | I915_WRITE(INSTPM, |
1376 | INSTPM_AGPBUSY_DIS << 16 | INSTPM_AGPBUSY_DIS); | 1524 | INSTPM_AGPBUSY_DIS << 16 | INSTPM_AGPBUSY_DIS); |
1377 | 1525 | ||
1378 | if (HAS_PCH_SPLIT(dev)) | 1526 | i915_disable_pipestat(dev_priv, pipe, |
1379 | ironlake_disable_display_irq(dev_priv, (pipe == 0) ? | 1527 | PIPE_VBLANK_INTERRUPT_ENABLE | |
1380 | DE_PIPEA_VBLANK: DE_PIPEB_VBLANK); | 1528 | PIPE_START_VBLANK_INTERRUPT_ENABLE); |
1381 | else | 1529 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
1382 | i915_disable_pipestat(dev_priv, pipe, | 1530 | } |
1383 | PIPE_VBLANK_INTERRUPT_ENABLE | | 1531 | |
1384 | PIPE_START_VBLANK_INTERRUPT_ENABLE); | 1532 | void ironlake_disable_vblank(struct drm_device *dev, int pipe) |
1533 | { | ||
1534 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | ||
1535 | unsigned long irqflags; | ||
1536 | |||
1537 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); | ||
1538 | ironlake_disable_display_irq(dev_priv, (pipe == 0) ? | ||
1539 | DE_PIPEA_VBLANK: DE_PIPEB_VBLANK); | ||
1540 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); | ||
1541 | } | ||
1542 | |||
1543 | void ivybridge_disable_vblank(struct drm_device *dev, int pipe) | ||
1544 | { | ||
1545 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | ||
1546 | unsigned long irqflags; | ||
1547 | |||
1548 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); | ||
1549 | ironlake_disable_display_irq(dev_priv, (pipe == 0) ? | ||
1550 | DE_PIPEA_VBLANK_IVB : DE_PIPEB_VBLANK_IVB); | ||
1385 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); | 1551 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); |
1386 | } | 1552 | } |
1387 | 1553 | ||
@@ -1562,10 +1728,15 @@ repeat: | |||
1562 | 1728 | ||
1563 | /* drm_dma.h hooks | 1729 | /* drm_dma.h hooks |
1564 | */ | 1730 | */ |
1565 | static void ironlake_irq_preinstall(struct drm_device *dev) | 1731 | void ironlake_irq_preinstall(struct drm_device *dev) |
1566 | { | 1732 | { |
1567 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 1733 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
1568 | 1734 | ||
1735 | atomic_set(&dev_priv->irq_received, 0); | ||
1736 | |||
1737 | INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func); | ||
1738 | INIT_WORK(&dev_priv->error_work, i915_error_work_func); | ||
1739 | |||
1569 | I915_WRITE(HWSTAM, 0xeffe); | 1740 | I915_WRITE(HWSTAM, 0xeffe); |
1570 | 1741 | ||
1571 | /* XXX hotplug from PCH */ | 1742 | /* XXX hotplug from PCH */ |
@@ -1585,7 +1756,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev) | |||
1585 | POSTING_READ(SDEIER); | 1756 | POSTING_READ(SDEIER); |
1586 | } | 1757 | } |
1587 | 1758 | ||
1588 | static int ironlake_irq_postinstall(struct drm_device *dev) | 1759 | int ironlake_irq_postinstall(struct drm_device *dev) |
1589 | { | 1760 | { |
1590 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 1761 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
1591 | /* enable kind of interrupts always enabled */ | 1762 | /* enable kind of interrupts always enabled */ |
@@ -1594,6 +1765,13 @@ static int ironlake_irq_postinstall(struct drm_device *dev) | |||
1594 | u32 render_irqs; | 1765 | u32 render_irqs; |
1595 | u32 hotplug_mask; | 1766 | u32 hotplug_mask; |
1596 | 1767 | ||
1768 | DRM_INIT_WAITQUEUE(&dev_priv->ring[RCS].irq_queue); | ||
1769 | if (HAS_BSD(dev)) | ||
1770 | DRM_INIT_WAITQUEUE(&dev_priv->ring[VCS].irq_queue); | ||
1771 | if (HAS_BLT(dev)) | ||
1772 | DRM_INIT_WAITQUEUE(&dev_priv->ring[BCS].irq_queue); | ||
1773 | |||
1774 | dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; | ||
1597 | dev_priv->irq_mask = ~display_mask; | 1775 | dev_priv->irq_mask = ~display_mask; |
1598 | 1776 | ||
1599 | /* should always can generate irq */ | 1777 | /* should always can generate irq */ |
@@ -1650,6 +1828,56 @@ static int ironlake_irq_postinstall(struct drm_device *dev) | |||
1650 | return 0; | 1828 | return 0; |
1651 | } | 1829 | } |
1652 | 1830 | ||
1831 | int ivybridge_irq_postinstall(struct drm_device *dev) | ||
1832 | { | ||
1833 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | ||
1834 | /* enable kind of interrupts always enabled */ | ||
1835 | u32 display_mask = DE_MASTER_IRQ_CONTROL | DE_GSE_IVB | | ||
1836 | DE_PCH_EVENT_IVB | DE_PLANEA_FLIP_DONE_IVB | | ||
1837 | DE_PLANEB_FLIP_DONE_IVB; | ||
1838 | u32 render_irqs; | ||
1839 | u32 hotplug_mask; | ||
1840 | |||
1841 | DRM_INIT_WAITQUEUE(&dev_priv->ring[RCS].irq_queue); | ||
1842 | if (HAS_BSD(dev)) | ||
1843 | DRM_INIT_WAITQUEUE(&dev_priv->ring[VCS].irq_queue); | ||
1844 | if (HAS_BLT(dev)) | ||
1845 | DRM_INIT_WAITQUEUE(&dev_priv->ring[BCS].irq_queue); | ||
1846 | |||
1847 | dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; | ||
1848 | dev_priv->irq_mask = ~display_mask; | ||
1849 | |||
1850 | /* should always can generate irq */ | ||
1851 | I915_WRITE(DEIIR, I915_READ(DEIIR)); | ||
1852 | I915_WRITE(DEIMR, dev_priv->irq_mask); | ||
1853 | I915_WRITE(DEIER, display_mask | DE_PIPEA_VBLANK_IVB | | ||
1854 | DE_PIPEB_VBLANK_IVB); | ||
1855 | POSTING_READ(DEIER); | ||
1856 | |||
1857 | dev_priv->gt_irq_mask = ~0; | ||
1858 | |||
1859 | I915_WRITE(GTIIR, I915_READ(GTIIR)); | ||
1860 | I915_WRITE(GTIMR, dev_priv->gt_irq_mask); | ||
1861 | |||
1862 | render_irqs = GT_USER_INTERRUPT | GT_GEN6_BSD_USER_INTERRUPT | | ||
1863 | GT_BLT_USER_INTERRUPT; | ||
1864 | I915_WRITE(GTIER, render_irqs); | ||
1865 | POSTING_READ(GTIER); | ||
1866 | |||
1867 | hotplug_mask = (SDE_CRT_HOTPLUG_CPT | | ||
1868 | SDE_PORTB_HOTPLUG_CPT | | ||
1869 | SDE_PORTC_HOTPLUG_CPT | | ||
1870 | SDE_PORTD_HOTPLUG_CPT); | ||
1871 | dev_priv->pch_irq_mask = ~hotplug_mask; | ||
1872 | |||
1873 | I915_WRITE(SDEIIR, I915_READ(SDEIIR)); | ||
1874 | I915_WRITE(SDEIMR, dev_priv->pch_irq_mask); | ||
1875 | I915_WRITE(SDEIER, hotplug_mask); | ||
1876 | POSTING_READ(SDEIER); | ||
1877 | |||
1878 | return 0; | ||
1879 | } | ||
1880 | |||
1653 | void i915_driver_irq_preinstall(struct drm_device * dev) | 1881 | void i915_driver_irq_preinstall(struct drm_device * dev) |
1654 | { | 1882 | { |
1655 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 1883 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
@@ -1659,11 +1887,7 @@ void i915_driver_irq_preinstall(struct drm_device * dev) | |||
1659 | 1887 | ||
1660 | INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func); | 1888 | INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func); |
1661 | INIT_WORK(&dev_priv->error_work, i915_error_work_func); | 1889 | INIT_WORK(&dev_priv->error_work, i915_error_work_func); |
1662 | 1890 | INIT_WORK(&dev_priv->rps_work, gen6_pm_rps_work); | |
1663 | if (HAS_PCH_SPLIT(dev)) { | ||
1664 | ironlake_irq_preinstall(dev); | ||
1665 | return; | ||
1666 | } | ||
1667 | 1891 | ||
1668 | if (I915_HAS_HOTPLUG(dev)) { | 1892 | if (I915_HAS_HOTPLUG(dev)) { |
1669 | I915_WRITE(PORT_HOTPLUG_EN, 0); | 1893 | I915_WRITE(PORT_HOTPLUG_EN, 0); |
@@ -1688,17 +1912,8 @@ int i915_driver_irq_postinstall(struct drm_device *dev) | |||
1688 | u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR; | 1912 | u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR; |
1689 | u32 error_mask; | 1913 | u32 error_mask; |
1690 | 1914 | ||
1691 | DRM_INIT_WAITQUEUE(&dev_priv->ring[RCS].irq_queue); | ||
1692 | if (HAS_BSD(dev)) | ||
1693 | DRM_INIT_WAITQUEUE(&dev_priv->ring[VCS].irq_queue); | ||
1694 | if (HAS_BLT(dev)) | ||
1695 | DRM_INIT_WAITQUEUE(&dev_priv->ring[BCS].irq_queue); | ||
1696 | |||
1697 | dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; | 1915 | dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; |
1698 | 1916 | ||
1699 | if (HAS_PCH_SPLIT(dev)) | ||
1700 | return ironlake_irq_postinstall(dev); | ||
1701 | |||
1702 | /* Unmask the interrupts that we always want on. */ | 1917 | /* Unmask the interrupts that we always want on. */ |
1703 | dev_priv->irq_mask = ~I915_INTERRUPT_ENABLE_FIX; | 1918 | dev_priv->irq_mask = ~I915_INTERRUPT_ENABLE_FIX; |
1704 | 1919 | ||
@@ -1767,9 +1982,15 @@ int i915_driver_irq_postinstall(struct drm_device *dev) | |||
1767 | return 0; | 1982 | return 0; |
1768 | } | 1983 | } |
1769 | 1984 | ||
1770 | static void ironlake_irq_uninstall(struct drm_device *dev) | 1985 | void ironlake_irq_uninstall(struct drm_device *dev) |
1771 | { | 1986 | { |
1772 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; | 1987 | drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; |
1988 | |||
1989 | if (!dev_priv) | ||
1990 | return; | ||
1991 | |||
1992 | dev_priv->vblank_pipe = 0; | ||
1993 | |||
1773 | I915_WRITE(HWSTAM, 0xffffffff); | 1994 | I915_WRITE(HWSTAM, 0xffffffff); |
1774 | 1995 | ||
1775 | I915_WRITE(DEIMR, 0xffffffff); | 1996 | I915_WRITE(DEIMR, 0xffffffff); |
@@ -1791,11 +2012,6 @@ void i915_driver_irq_uninstall(struct drm_device * dev) | |||
1791 | 2012 | ||
1792 | dev_priv->vblank_pipe = 0; | 2013 | dev_priv->vblank_pipe = 0; |
1793 | 2014 | ||
1794 | if (HAS_PCH_SPLIT(dev)) { | ||
1795 | ironlake_irq_uninstall(dev); | ||
1796 | return; | ||
1797 | } | ||
1798 | |||
1799 | if (I915_HAS_HOTPLUG(dev)) { | 2015 | if (I915_HAS_HOTPLUG(dev)) { |
1800 | I915_WRITE(PORT_HOTPLUG_EN, 0); | 2016 | I915_WRITE(PORT_HOTPLUG_EN, 0); |
1801 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); | 2017 | I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT)); |
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index f39ac3a0fa93..2f967af8e62e 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
@@ -291,6 +291,9 @@ | |||
291 | #define RING_MAX_IDLE(base) ((base)+0x54) | 291 | #define RING_MAX_IDLE(base) ((base)+0x54) |
292 | #define RING_HWS_PGA(base) ((base)+0x80) | 292 | #define RING_HWS_PGA(base) ((base)+0x80) |
293 | #define RING_HWS_PGA_GEN6(base) ((base)+0x2080) | 293 | #define RING_HWS_PGA_GEN6(base) ((base)+0x2080) |
294 | #define RENDER_HWS_PGA_GEN7 (0x04080) | ||
295 | #define BSD_HWS_PGA_GEN7 (0x04180) | ||
296 | #define BLT_HWS_PGA_GEN7 (0x04280) | ||
294 | #define RING_ACTHD(base) ((base)+0x74) | 297 | #define RING_ACTHD(base) ((base)+0x74) |
295 | #define RING_NOPID(base) ((base)+0x94) | 298 | #define RING_NOPID(base) ((base)+0x94) |
296 | #define RING_IMR(base) ((base)+0xa8) | 299 | #define RING_IMR(base) ((base)+0xa8) |
@@ -2778,6 +2781,19 @@ | |||
2778 | #define DE_PIPEA_VSYNC (1 << 3) | 2781 | #define DE_PIPEA_VSYNC (1 << 3) |
2779 | #define DE_PIPEA_FIFO_UNDERRUN (1 << 0) | 2782 | #define DE_PIPEA_FIFO_UNDERRUN (1 << 0) |
2780 | 2783 | ||
2784 | /* More Ivybridge lolz */ | ||
2785 | #define DE_ERR_DEBUG_IVB (1<<30) | ||
2786 | #define DE_GSE_IVB (1<<29) | ||
2787 | #define DE_PCH_EVENT_IVB (1<<28) | ||
2788 | #define DE_DP_A_HOTPLUG_IVB (1<<27) | ||
2789 | #define DE_AUX_CHANNEL_A_IVB (1<<26) | ||
2790 | #define DE_SPRITEB_FLIP_DONE_IVB (1<<9) | ||
2791 | #define DE_SPRITEA_FLIP_DONE_IVB (1<<4) | ||
2792 | #define DE_PLANEB_FLIP_DONE_IVB (1<<8) | ||
2793 | #define DE_PLANEA_FLIP_DONE_IVB (1<<3) | ||
2794 | #define DE_PIPEB_VBLANK_IVB (1<<5) | ||
2795 | #define DE_PIPEA_VBLANK_IVB (1<<0) | ||
2796 | |||
2781 | #define DEISR 0x44000 | 2797 | #define DEISR 0x44000 |
2782 | #define DEIMR 0x44004 | 2798 | #define DEIMR 0x44004 |
2783 | #define DEIIR 0x44008 | 2799 | #define DEIIR 0x44008 |
@@ -2809,6 +2825,7 @@ | |||
2809 | #define ILK_eDP_A_DISABLE (1<<24) | 2825 | #define ILK_eDP_A_DISABLE (1<<24) |
2810 | #define ILK_DESKTOP (1<<23) | 2826 | #define ILK_DESKTOP (1<<23) |
2811 | #define ILK_DSPCLK_GATE 0x42020 | 2827 | #define ILK_DSPCLK_GATE 0x42020 |
2828 | #define IVB_VRHUNIT_CLK_GATE (1<<28) | ||
2812 | #define ILK_DPARB_CLK_GATE (1<<5) | 2829 | #define ILK_DPARB_CLK_GATE (1<<5) |
2813 | #define ILK_DPFD_CLK_GATE (1<<7) | 2830 | #define ILK_DPFD_CLK_GATE (1<<7) |
2814 | 2831 | ||
@@ -3057,6 +3074,9 @@ | |||
3057 | #define TRANS_6BPC (2<<5) | 3074 | #define TRANS_6BPC (2<<5) |
3058 | #define TRANS_12BPC (3<<5) | 3075 | #define TRANS_12BPC (3<<5) |
3059 | 3076 | ||
3077 | #define SOUTH_CHICKEN2 0xc2004 | ||
3078 | #define DPLS_EDP_PPS_FIX_DIS (1<<0) | ||
3079 | |||
3060 | #define _FDI_RXA_CHICKEN 0xc200c | 3080 | #define _FDI_RXA_CHICKEN 0xc200c |
3061 | #define _FDI_RXB_CHICKEN 0xc2010 | 3081 | #define _FDI_RXB_CHICKEN 0xc2010 |
3062 | #define FDI_RX_PHASE_SYNC_POINTER_OVR (1<<1) | 3082 | #define FDI_RX_PHASE_SYNC_POINTER_OVR (1<<1) |
@@ -3104,7 +3124,15 @@ | |||
3104 | #define FDI_TX_ENHANCE_FRAME_ENABLE (1<<18) | 3124 | #define FDI_TX_ENHANCE_FRAME_ENABLE (1<<18) |
3105 | /* Ironlake: hardwired to 1 */ | 3125 | /* Ironlake: hardwired to 1 */ |
3106 | #define FDI_TX_PLL_ENABLE (1<<14) | 3126 | #define FDI_TX_PLL_ENABLE (1<<14) |
3127 | |||
3128 | /* Ivybridge has different bits for lolz */ | ||
3129 | #define FDI_LINK_TRAIN_PATTERN_1_IVB (0<<8) | ||
3130 | #define FDI_LINK_TRAIN_PATTERN_2_IVB (1<<8) | ||
3131 | #define FDI_LINK_TRAIN_PATTERN_IDLE_IVB (2<<8) | ||
3132 | #define FDI_LINK_TRAIN_NONE_IVB (3<<8) | ||
3133 | |||
3107 | /* both Tx and Rx */ | 3134 | /* both Tx and Rx */ |
3135 | #define FDI_LINK_TRAIN_AUTO (1<<10) | ||
3108 | #define FDI_SCRAMBLING_ENABLE (0<<7) | 3136 | #define FDI_SCRAMBLING_ENABLE (0<<7) |
3109 | #define FDI_SCRAMBLING_DISABLE (1<<7) | 3137 | #define FDI_SCRAMBLING_DISABLE (1<<7) |
3110 | 3138 | ||
@@ -3114,6 +3142,8 @@ | |||
3114 | #define FDI_RX_CTL(pipe) _PIPE(pipe, _FDI_RXA_CTL, _FDI_RXB_CTL) | 3142 | #define FDI_RX_CTL(pipe) _PIPE(pipe, _FDI_RXA_CTL, _FDI_RXB_CTL) |
3115 | #define FDI_RX_ENABLE (1<<31) | 3143 | #define FDI_RX_ENABLE (1<<31) |
3116 | /* train, dp width same as FDI_TX */ | 3144 | /* train, dp width same as FDI_TX */ |
3145 | #define FDI_FS_ERRC_ENABLE (1<<27) | ||
3146 | #define FDI_FE_ERRC_ENABLE (1<<26) | ||
3117 | #define FDI_DP_PORT_WIDTH_X8 (7<<19) | 3147 | #define FDI_DP_PORT_WIDTH_X8 (7<<19) |
3118 | #define FDI_8BPC (0<<16) | 3148 | #define FDI_8BPC (0<<16) |
3119 | #define FDI_10BPC (1<<16) | 3149 | #define FDI_10BPC (1<<16) |
@@ -3386,7 +3416,7 @@ | |||
3386 | #define GEN6_PMINTRMSK 0xA168 | 3416 | #define GEN6_PMINTRMSK 0xA168 |
3387 | 3417 | ||
3388 | #define GEN6_PMISR 0x44020 | 3418 | #define GEN6_PMISR 0x44020 |
3389 | #define GEN6_PMIMR 0x44024 | 3419 | #define GEN6_PMIMR 0x44024 /* rps_lock */ |
3390 | #define GEN6_PMIIR 0x44028 | 3420 | #define GEN6_PMIIR 0x44028 |
3391 | #define GEN6_PMIER 0x4402C | 3421 | #define GEN6_PMIER 0x4402C |
3392 | #define GEN6_PM_MBOX_EVENT (1<<25) | 3422 | #define GEN6_PM_MBOX_EVENT (1<<25) |
@@ -3396,6 +3426,9 @@ | |||
3396 | #define GEN6_PM_RP_DOWN_THRESHOLD (1<<4) | 3426 | #define GEN6_PM_RP_DOWN_THRESHOLD (1<<4) |
3397 | #define GEN6_PM_RP_UP_EI_EXPIRED (1<<2) | 3427 | #define GEN6_PM_RP_UP_EI_EXPIRED (1<<2) |
3398 | #define GEN6_PM_RP_DOWN_EI_EXPIRED (1<<1) | 3428 | #define GEN6_PM_RP_DOWN_EI_EXPIRED (1<<1) |
3429 | #define GEN6_PM_DEFERRED_EVENTS (GEN6_PM_RP_UP_THRESHOLD | \ | ||
3430 | GEN6_PM_RP_DOWN_THRESHOLD | \ | ||
3431 | GEN6_PM_RP_DOWN_TIMEOUT) | ||
3399 | 3432 | ||
3400 | #define GEN6_PCODE_MAILBOX 0x138124 | 3433 | #define GEN6_PCODE_MAILBOX 0x138124 |
3401 | #define GEN6_PCODE_READY (1<<31) | 3434 | #define GEN6_PCODE_READY (1<<31) |
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c index da474153a0a2..60a94d2b5264 100644 --- a/drivers/gpu/drm/i915/i915_suspend.c +++ b/drivers/gpu/drm/i915/i915_suspend.c | |||
@@ -863,8 +863,7 @@ int i915_restore_state(struct drm_device *dev) | |||
863 | I915_WRITE(IMR, dev_priv->saveIMR); | 863 | I915_WRITE(IMR, dev_priv->saveIMR); |
864 | } | 864 | } |
865 | 865 | ||
866 | /* Clock gating state */ | 866 | intel_init_clock_gating(dev); |
867 | intel_enable_clock_gating(dev); | ||
868 | 867 | ||
869 | if (IS_IRONLAKE_M(dev)) { | 868 | if (IS_IRONLAKE_M(dev)) { |
870 | ironlake_enable_drps(dev); | 869 | ironlake_enable_drps(dev); |
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index d03fc05b39c0..e93f93cc7e78 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c | |||
@@ -305,13 +305,11 @@ static bool intel_crt_detect_ddc(struct drm_connector *connector) | |||
305 | } | 305 | } |
306 | 306 | ||
307 | static enum drm_connector_status | 307 | static enum drm_connector_status |
308 | intel_crt_load_detect(struct drm_crtc *crtc, struct intel_crt *crt) | 308 | intel_crt_load_detect(struct intel_crt *crt) |
309 | { | 309 | { |
310 | struct drm_encoder *encoder = &crt->base.base; | 310 | struct drm_device *dev = crt->base.base.dev; |
311 | struct drm_device *dev = encoder->dev; | ||
312 | struct drm_i915_private *dev_priv = dev->dev_private; | 311 | struct drm_i915_private *dev_priv = dev->dev_private; |
313 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 312 | uint32_t pipe = to_intel_crtc(crt->base.base.crtc)->pipe; |
314 | uint32_t pipe = intel_crtc->pipe; | ||
315 | uint32_t save_bclrpat; | 313 | uint32_t save_bclrpat; |
316 | uint32_t save_vtotal; | 314 | uint32_t save_vtotal; |
317 | uint32_t vtotal, vactive; | 315 | uint32_t vtotal, vactive; |
@@ -432,7 +430,6 @@ intel_crt_detect(struct drm_connector *connector, bool force) | |||
432 | struct drm_device *dev = connector->dev; | 430 | struct drm_device *dev = connector->dev; |
433 | struct intel_crt *crt = intel_attached_crt(connector); | 431 | struct intel_crt *crt = intel_attached_crt(connector); |
434 | struct drm_crtc *crtc; | 432 | struct drm_crtc *crtc; |
435 | int dpms_mode; | ||
436 | enum drm_connector_status status; | 433 | enum drm_connector_status status; |
437 | 434 | ||
438 | if (I915_HAS_HOTPLUG(dev)) { | 435 | if (I915_HAS_HOTPLUG(dev)) { |
@@ -454,17 +451,18 @@ intel_crt_detect(struct drm_connector *connector, bool force) | |||
454 | /* for pre-945g platforms use load detect */ | 451 | /* for pre-945g platforms use load detect */ |
455 | crtc = crt->base.base.crtc; | 452 | crtc = crt->base.base.crtc; |
456 | if (crtc && crtc->enabled) { | 453 | if (crtc && crtc->enabled) { |
457 | status = intel_crt_load_detect(crtc, crt); | 454 | status = intel_crt_load_detect(crt); |
458 | } else { | 455 | } else { |
459 | crtc = intel_get_load_detect_pipe(&crt->base, connector, | 456 | struct intel_load_detect_pipe tmp; |
460 | NULL, &dpms_mode); | 457 | |
461 | if (crtc) { | 458 | if (intel_get_load_detect_pipe(&crt->base, connector, NULL, |
459 | &tmp)) { | ||
462 | if (intel_crt_detect_ddc(connector)) | 460 | if (intel_crt_detect_ddc(connector)) |
463 | status = connector_status_connected; | 461 | status = connector_status_connected; |
464 | else | 462 | else |
465 | status = intel_crt_load_detect(crtc, crt); | 463 | status = intel_crt_load_detect(crt); |
466 | intel_release_load_detect_pipe(&crt->base, | 464 | intel_release_load_detect_pipe(&crt->base, connector, |
467 | connector, dpms_mode); | 465 | &tmp); |
468 | } else | 466 | } else |
469 | status = connector_status_unknown; | 467 | status = connector_status_unknown; |
470 | } | 468 | } |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 21a7e70feacc..565eb2cc0042 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -76,255 +76,6 @@ struct intel_limit { | |||
76 | int, int, intel_clock_t *); | 76 | int, int, intel_clock_t *); |
77 | }; | 77 | }; |
78 | 78 | ||
79 | #define I8XX_DOT_MIN 25000 | ||
80 | #define I8XX_DOT_MAX 350000 | ||
81 | #define I8XX_VCO_MIN 930000 | ||
82 | #define I8XX_VCO_MAX 1400000 | ||
83 | #define I8XX_N_MIN 3 | ||
84 | #define I8XX_N_MAX 16 | ||
85 | #define I8XX_M_MIN 96 | ||
86 | #define I8XX_M_MAX 140 | ||
87 | #define I8XX_M1_MIN 18 | ||
88 | #define I8XX_M1_MAX 26 | ||
89 | #define I8XX_M2_MIN 6 | ||
90 | #define I8XX_M2_MAX 16 | ||
91 | #define I8XX_P_MIN 4 | ||
92 | #define I8XX_P_MAX 128 | ||
93 | #define I8XX_P1_MIN 2 | ||
94 | #define I8XX_P1_MAX 33 | ||
95 | #define I8XX_P1_LVDS_MIN 1 | ||
96 | #define I8XX_P1_LVDS_MAX 6 | ||
97 | #define I8XX_P2_SLOW 4 | ||
98 | #define I8XX_P2_FAST 2 | ||
99 | #define I8XX_P2_LVDS_SLOW 14 | ||
100 | #define I8XX_P2_LVDS_FAST 7 | ||
101 | #define I8XX_P2_SLOW_LIMIT 165000 | ||
102 | |||
103 | #define I9XX_DOT_MIN 20000 | ||
104 | #define I9XX_DOT_MAX 400000 | ||
105 | #define I9XX_VCO_MIN 1400000 | ||
106 | #define I9XX_VCO_MAX 2800000 | ||
107 | #define PINEVIEW_VCO_MIN 1700000 | ||
108 | #define PINEVIEW_VCO_MAX 3500000 | ||
109 | #define I9XX_N_MIN 1 | ||
110 | #define I9XX_N_MAX 6 | ||
111 | /* Pineview's Ncounter is a ring counter */ | ||
112 | #define PINEVIEW_N_MIN 3 | ||
113 | #define PINEVIEW_N_MAX 6 | ||
114 | #define I9XX_M_MIN 70 | ||
115 | #define I9XX_M_MAX 120 | ||
116 | #define PINEVIEW_M_MIN 2 | ||
117 | #define PINEVIEW_M_MAX 256 | ||
118 | #define I9XX_M1_MIN 10 | ||
119 | #define I9XX_M1_MAX 22 | ||
120 | #define I9XX_M2_MIN 5 | ||
121 | #define I9XX_M2_MAX 9 | ||
122 | /* Pineview M1 is reserved, and must be 0 */ | ||
123 | #define PINEVIEW_M1_MIN 0 | ||
124 | #define PINEVIEW_M1_MAX 0 | ||
125 | #define PINEVIEW_M2_MIN 0 | ||
126 | #define PINEVIEW_M2_MAX 254 | ||
127 | #define I9XX_P_SDVO_DAC_MIN 5 | ||
128 | #define I9XX_P_SDVO_DAC_MAX 80 | ||
129 | #define I9XX_P_LVDS_MIN 7 | ||
130 | #define I9XX_P_LVDS_MAX 98 | ||
131 | #define PINEVIEW_P_LVDS_MIN 7 | ||
132 | #define PINEVIEW_P_LVDS_MAX 112 | ||
133 | #define I9XX_P1_MIN 1 | ||
134 | #define I9XX_P1_MAX 8 | ||
135 | #define I9XX_P2_SDVO_DAC_SLOW 10 | ||
136 | #define I9XX_P2_SDVO_DAC_FAST 5 | ||
137 | #define I9XX_P2_SDVO_DAC_SLOW_LIMIT 200000 | ||
138 | #define I9XX_P2_LVDS_SLOW 14 | ||
139 | #define I9XX_P2_LVDS_FAST 7 | ||
140 | #define I9XX_P2_LVDS_SLOW_LIMIT 112000 | ||
141 | |||
142 | /*The parameter is for SDVO on G4x platform*/ | ||
143 | #define G4X_DOT_SDVO_MIN 25000 | ||
144 | #define G4X_DOT_SDVO_MAX 270000 | ||
145 | #define G4X_VCO_MIN 1750000 | ||
146 | #define G4X_VCO_MAX 3500000 | ||
147 | #define G4X_N_SDVO_MIN 1 | ||
148 | #define G4X_N_SDVO_MAX 4 | ||
149 | #define G4X_M_SDVO_MIN 104 | ||
150 | #define G4X_M_SDVO_MAX 138 | ||
151 | #define G4X_M1_SDVO_MIN 17 | ||
152 | #define G4X_M1_SDVO_MAX 23 | ||
153 | #define G4X_M2_SDVO_MIN 5 | ||
154 | #define G4X_M2_SDVO_MAX 11 | ||
155 | #define G4X_P_SDVO_MIN 10 | ||
156 | #define G4X_P_SDVO_MAX 30 | ||
157 | #define G4X_P1_SDVO_MIN 1 | ||
158 | #define G4X_P1_SDVO_MAX 3 | ||
159 | #define G4X_P2_SDVO_SLOW 10 | ||
160 | #define G4X_P2_SDVO_FAST 10 | ||
161 | #define G4X_P2_SDVO_LIMIT 270000 | ||
162 | |||
163 | /*The parameter is for HDMI_DAC on G4x platform*/ | ||
164 | #define G4X_DOT_HDMI_DAC_MIN 22000 | ||
165 | #define G4X_DOT_HDMI_DAC_MAX 400000 | ||
166 | #define G4X_N_HDMI_DAC_MIN 1 | ||
167 | #define G4X_N_HDMI_DAC_MAX 4 | ||
168 | #define G4X_M_HDMI_DAC_MIN 104 | ||
169 | #define G4X_M_HDMI_DAC_MAX 138 | ||
170 | #define G4X_M1_HDMI_DAC_MIN 16 | ||
171 | #define G4X_M1_HDMI_DAC_MAX 23 | ||
172 | #define G4X_M2_HDMI_DAC_MIN 5 | ||
173 | #define G4X_M2_HDMI_DAC_MAX 11 | ||
174 | #define G4X_P_HDMI_DAC_MIN 5 | ||
175 | #define G4X_P_HDMI_DAC_MAX 80 | ||
176 | #define G4X_P1_HDMI_DAC_MIN 1 | ||
177 | #define G4X_P1_HDMI_DAC_MAX 8 | ||
178 | #define G4X_P2_HDMI_DAC_SLOW 10 | ||
179 | #define G4X_P2_HDMI_DAC_FAST 5 | ||
180 | #define G4X_P2_HDMI_DAC_LIMIT 165000 | ||
181 | |||
182 | /*The parameter is for SINGLE_CHANNEL_LVDS on G4x platform*/ | ||
183 | #define G4X_DOT_SINGLE_CHANNEL_LVDS_MIN 20000 | ||
184 | #define G4X_DOT_SINGLE_CHANNEL_LVDS_MAX 115000 | ||
185 | #define G4X_N_SINGLE_CHANNEL_LVDS_MIN 1 | ||
186 | #define G4X_N_SINGLE_CHANNEL_LVDS_MAX 3 | ||
187 | #define G4X_M_SINGLE_CHANNEL_LVDS_MIN 104 | ||
188 | #define G4X_M_SINGLE_CHANNEL_LVDS_MAX 138 | ||
189 | #define G4X_M1_SINGLE_CHANNEL_LVDS_MIN 17 | ||
190 | #define G4X_M1_SINGLE_CHANNEL_LVDS_MAX 23 | ||
191 | #define G4X_M2_SINGLE_CHANNEL_LVDS_MIN 5 | ||
192 | #define G4X_M2_SINGLE_CHANNEL_LVDS_MAX 11 | ||
193 | #define G4X_P_SINGLE_CHANNEL_LVDS_MIN 28 | ||
194 | #define G4X_P_SINGLE_CHANNEL_LVDS_MAX 112 | ||
195 | #define G4X_P1_SINGLE_CHANNEL_LVDS_MIN 2 | ||
196 | #define G4X_P1_SINGLE_CHANNEL_LVDS_MAX 8 | ||
197 | #define G4X_P2_SINGLE_CHANNEL_LVDS_SLOW 14 | ||
198 | #define G4X_P2_SINGLE_CHANNEL_LVDS_FAST 14 | ||
199 | #define G4X_P2_SINGLE_CHANNEL_LVDS_LIMIT 0 | ||
200 | |||
201 | /*The parameter is for DUAL_CHANNEL_LVDS on G4x platform*/ | ||
202 | #define G4X_DOT_DUAL_CHANNEL_LVDS_MIN 80000 | ||
203 | #define G4X_DOT_DUAL_CHANNEL_LVDS_MAX 224000 | ||
204 | #define G4X_N_DUAL_CHANNEL_LVDS_MIN 1 | ||
205 | #define G4X_N_DUAL_CHANNEL_LVDS_MAX 3 | ||
206 | #define G4X_M_DUAL_CHANNEL_LVDS_MIN 104 | ||
207 | #define G4X_M_DUAL_CHANNEL_LVDS_MAX 138 | ||
208 | #define G4X_M1_DUAL_CHANNEL_LVDS_MIN 17 | ||
209 | #define G4X_M1_DUAL_CHANNEL_LVDS_MAX 23 | ||
210 | #define G4X_M2_DUAL_CHANNEL_LVDS_MIN 5 | ||
211 | #define G4X_M2_DUAL_CHANNEL_LVDS_MAX 11 | ||
212 | #define G4X_P_DUAL_CHANNEL_LVDS_MIN 14 | ||
213 | #define G4X_P_DUAL_CHANNEL_LVDS_MAX 42 | ||
214 | #define G4X_P1_DUAL_CHANNEL_LVDS_MIN 2 | ||
215 | #define G4X_P1_DUAL_CHANNEL_LVDS_MAX 6 | ||
216 | #define G4X_P2_DUAL_CHANNEL_LVDS_SLOW 7 | ||
217 | #define G4X_P2_DUAL_CHANNEL_LVDS_FAST 7 | ||
218 | #define G4X_P2_DUAL_CHANNEL_LVDS_LIMIT 0 | ||
219 | |||
220 | /*The parameter is for DISPLAY PORT on G4x platform*/ | ||
221 | #define G4X_DOT_DISPLAY_PORT_MIN 161670 | ||
222 | #define G4X_DOT_DISPLAY_PORT_MAX 227000 | ||
223 | #define G4X_N_DISPLAY_PORT_MIN 1 | ||
224 | #define G4X_N_DISPLAY_PORT_MAX 2 | ||
225 | #define G4X_M_DISPLAY_PORT_MIN 97 | ||
226 | #define G4X_M_DISPLAY_PORT_MAX 108 | ||
227 | #define G4X_M1_DISPLAY_PORT_MIN 0x10 | ||
228 | #define G4X_M1_DISPLAY_PORT_MAX 0x12 | ||
229 | #define G4X_M2_DISPLAY_PORT_MIN 0x05 | ||
230 | #define G4X_M2_DISPLAY_PORT_MAX 0x06 | ||
231 | #define G4X_P_DISPLAY_PORT_MIN 10 | ||
232 | #define G4X_P_DISPLAY_PORT_MAX 20 | ||
233 | #define G4X_P1_DISPLAY_PORT_MIN 1 | ||
234 | #define G4X_P1_DISPLAY_PORT_MAX 2 | ||
235 | #define G4X_P2_DISPLAY_PORT_SLOW 10 | ||
236 | #define G4X_P2_DISPLAY_PORT_FAST 10 | ||
237 | #define G4X_P2_DISPLAY_PORT_LIMIT 0 | ||
238 | |||
239 | /* Ironlake / Sandybridge */ | ||
240 | /* as we calculate clock using (register_value + 2) for | ||
241 | N/M1/M2, so here the range value for them is (actual_value-2). | ||
242 | */ | ||
243 | #define IRONLAKE_DOT_MIN 25000 | ||
244 | #define IRONLAKE_DOT_MAX 350000 | ||
245 | #define IRONLAKE_VCO_MIN 1760000 | ||
246 | #define IRONLAKE_VCO_MAX 3510000 | ||
247 | #define IRONLAKE_M1_MIN 12 | ||
248 | #define IRONLAKE_M1_MAX 22 | ||
249 | #define IRONLAKE_M2_MIN 5 | ||
250 | #define IRONLAKE_M2_MAX 9 | ||
251 | #define IRONLAKE_P2_DOT_LIMIT 225000 /* 225Mhz */ | ||
252 | |||
253 | /* We have parameter ranges for different type of outputs. */ | ||
254 | |||
255 | /* DAC & HDMI Refclk 120Mhz */ | ||
256 | #define IRONLAKE_DAC_N_MIN 1 | ||
257 | #define IRONLAKE_DAC_N_MAX 5 | ||
258 | #define IRONLAKE_DAC_M_MIN 79 | ||
259 | #define IRONLAKE_DAC_M_MAX 127 | ||
260 | #define IRONLAKE_DAC_P_MIN 5 | ||
261 | #define IRONLAKE_DAC_P_MAX 80 | ||
262 | #define IRONLAKE_DAC_P1_MIN 1 | ||
263 | #define IRONLAKE_DAC_P1_MAX 8 | ||
264 | #define IRONLAKE_DAC_P2_SLOW 10 | ||
265 | #define IRONLAKE_DAC_P2_FAST 5 | ||
266 | |||
267 | /* LVDS single-channel 120Mhz refclk */ | ||
268 | #define IRONLAKE_LVDS_S_N_MIN 1 | ||
269 | #define IRONLAKE_LVDS_S_N_MAX 3 | ||
270 | #define IRONLAKE_LVDS_S_M_MIN 79 | ||
271 | #define IRONLAKE_LVDS_S_M_MAX 118 | ||
272 | #define IRONLAKE_LVDS_S_P_MIN 28 | ||
273 | #define IRONLAKE_LVDS_S_P_MAX 112 | ||
274 | #define IRONLAKE_LVDS_S_P1_MIN 2 | ||
275 | #define IRONLAKE_LVDS_S_P1_MAX 8 | ||
276 | #define IRONLAKE_LVDS_S_P2_SLOW 14 | ||
277 | #define IRONLAKE_LVDS_S_P2_FAST 14 | ||
278 | |||
279 | /* LVDS dual-channel 120Mhz refclk */ | ||
280 | #define IRONLAKE_LVDS_D_N_MIN 1 | ||
281 | #define IRONLAKE_LVDS_D_N_MAX 3 | ||
282 | #define IRONLAKE_LVDS_D_M_MIN 79 | ||
283 | #define IRONLAKE_LVDS_D_M_MAX 127 | ||
284 | #define IRONLAKE_LVDS_D_P_MIN 14 | ||
285 | #define IRONLAKE_LVDS_D_P_MAX 56 | ||
286 | #define IRONLAKE_LVDS_D_P1_MIN 2 | ||
287 | #define IRONLAKE_LVDS_D_P1_MAX 8 | ||
288 | #define IRONLAKE_LVDS_D_P2_SLOW 7 | ||
289 | #define IRONLAKE_LVDS_D_P2_FAST 7 | ||
290 | |||
291 | /* LVDS single-channel 100Mhz refclk */ | ||
292 | #define IRONLAKE_LVDS_S_SSC_N_MIN 1 | ||
293 | #define IRONLAKE_LVDS_S_SSC_N_MAX 2 | ||
294 | #define IRONLAKE_LVDS_S_SSC_M_MIN 79 | ||
295 | #define IRONLAKE_LVDS_S_SSC_M_MAX 126 | ||
296 | #define IRONLAKE_LVDS_S_SSC_P_MIN 28 | ||
297 | #define IRONLAKE_LVDS_S_SSC_P_MAX 112 | ||
298 | #define IRONLAKE_LVDS_S_SSC_P1_MIN 2 | ||
299 | #define IRONLAKE_LVDS_S_SSC_P1_MAX 8 | ||
300 | #define IRONLAKE_LVDS_S_SSC_P2_SLOW 14 | ||
301 | #define IRONLAKE_LVDS_S_SSC_P2_FAST 14 | ||
302 | |||
303 | /* LVDS dual-channel 100Mhz refclk */ | ||
304 | #define IRONLAKE_LVDS_D_SSC_N_MIN 1 | ||
305 | #define IRONLAKE_LVDS_D_SSC_N_MAX 3 | ||
306 | #define IRONLAKE_LVDS_D_SSC_M_MIN 79 | ||
307 | #define IRONLAKE_LVDS_D_SSC_M_MAX 126 | ||
308 | #define IRONLAKE_LVDS_D_SSC_P_MIN 14 | ||
309 | #define IRONLAKE_LVDS_D_SSC_P_MAX 42 | ||
310 | #define IRONLAKE_LVDS_D_SSC_P1_MIN 2 | ||
311 | #define IRONLAKE_LVDS_D_SSC_P1_MAX 6 | ||
312 | #define IRONLAKE_LVDS_D_SSC_P2_SLOW 7 | ||
313 | #define IRONLAKE_LVDS_D_SSC_P2_FAST 7 | ||
314 | |||
315 | /* DisplayPort */ | ||
316 | #define IRONLAKE_DP_N_MIN 1 | ||
317 | #define IRONLAKE_DP_N_MAX 2 | ||
318 | #define IRONLAKE_DP_M_MIN 81 | ||
319 | #define IRONLAKE_DP_M_MAX 90 | ||
320 | #define IRONLAKE_DP_P_MIN 10 | ||
321 | #define IRONLAKE_DP_P_MAX 20 | ||
322 | #define IRONLAKE_DP_P2_FAST 10 | ||
323 | #define IRONLAKE_DP_P2_SLOW 10 | ||
324 | #define IRONLAKE_DP_P2_LIMIT 0 | ||
325 | #define IRONLAKE_DP_P1_MIN 1 | ||
326 | #define IRONLAKE_DP_P1_MAX 2 | ||
327 | |||
328 | /* FDI */ | 79 | /* FDI */ |
329 | #define IRONLAKE_FDI_FREQ 2700000 /* in kHz for mode->clock */ | 80 | #define IRONLAKE_FDI_FREQ 2700000 /* in kHz for mode->clock */ |
330 | 81 | ||
@@ -353,292 +104,253 @@ intel_fdi_link_freq(struct drm_device *dev) | |||
353 | } | 104 | } |
354 | 105 | ||
355 | static const intel_limit_t intel_limits_i8xx_dvo = { | 106 | static const intel_limit_t intel_limits_i8xx_dvo = { |
356 | .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX }, | 107 | .dot = { .min = 25000, .max = 350000 }, |
357 | .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX }, | 108 | .vco = { .min = 930000, .max = 1400000 }, |
358 | .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX }, | 109 | .n = { .min = 3, .max = 16 }, |
359 | .m = { .min = I8XX_M_MIN, .max = I8XX_M_MAX }, | 110 | .m = { .min = 96, .max = 140 }, |
360 | .m1 = { .min = I8XX_M1_MIN, .max = I8XX_M1_MAX }, | 111 | .m1 = { .min = 18, .max = 26 }, |
361 | .m2 = { .min = I8XX_M2_MIN, .max = I8XX_M2_MAX }, | 112 | .m2 = { .min = 6, .max = 16 }, |
362 | .p = { .min = I8XX_P_MIN, .max = I8XX_P_MAX }, | 113 | .p = { .min = 4, .max = 128 }, |
363 | .p1 = { .min = I8XX_P1_MIN, .max = I8XX_P1_MAX }, | 114 | .p1 = { .min = 2, .max = 33 }, |
364 | .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT, | 115 | .p2 = { .dot_limit = 165000, |
365 | .p2_slow = I8XX_P2_SLOW, .p2_fast = I8XX_P2_FAST }, | 116 | .p2_slow = 4, .p2_fast = 2 }, |
366 | .find_pll = intel_find_best_PLL, | 117 | .find_pll = intel_find_best_PLL, |
367 | }; | 118 | }; |
368 | 119 | ||
369 | static const intel_limit_t intel_limits_i8xx_lvds = { | 120 | static const intel_limit_t intel_limits_i8xx_lvds = { |
370 | .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX }, | 121 | .dot = { .min = 25000, .max = 350000 }, |
371 | .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX }, | 122 | .vco = { .min = 930000, .max = 1400000 }, |
372 | .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX }, | 123 | .n = { .min = 3, .max = 16 }, |
373 | .m = { .min = I8XX_M_MIN, .max = I8XX_M_MAX }, | 124 | .m = { .min = 96, .max = 140 }, |
374 | .m1 = { .min = I8XX_M1_MIN, .max = I8XX_M1_MAX }, | 125 | .m1 = { .min = 18, .max = 26 }, |
375 | .m2 = { .min = I8XX_M2_MIN, .max = I8XX_M2_MAX }, | 126 | .m2 = { .min = 6, .max = 16 }, |
376 | .p = { .min = I8XX_P_MIN, .max = I8XX_P_MAX }, | 127 | .p = { .min = 4, .max = 128 }, |
377 | .p1 = { .min = I8XX_P1_LVDS_MIN, .max = I8XX_P1_LVDS_MAX }, | 128 | .p1 = { .min = 1, .max = 6 }, |
378 | .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT, | 129 | .p2 = { .dot_limit = 165000, |
379 | .p2_slow = I8XX_P2_LVDS_SLOW, .p2_fast = I8XX_P2_LVDS_FAST }, | 130 | .p2_slow = 14, .p2_fast = 7 }, |
380 | .find_pll = intel_find_best_PLL, | 131 | .find_pll = intel_find_best_PLL, |
381 | }; | 132 | }; |
382 | 133 | ||
383 | static const intel_limit_t intel_limits_i9xx_sdvo = { | 134 | static const intel_limit_t intel_limits_i9xx_sdvo = { |
384 | .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX }, | 135 | .dot = { .min = 20000, .max = 400000 }, |
385 | .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX }, | 136 | .vco = { .min = 1400000, .max = 2800000 }, |
386 | .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX }, | 137 | .n = { .min = 1, .max = 6 }, |
387 | .m = { .min = I9XX_M_MIN, .max = I9XX_M_MAX }, | 138 | .m = { .min = 70, .max = 120 }, |
388 | .m1 = { .min = I9XX_M1_MIN, .max = I9XX_M1_MAX }, | 139 | .m1 = { .min = 10, .max = 22 }, |
389 | .m2 = { .min = I9XX_M2_MIN, .max = I9XX_M2_MAX }, | 140 | .m2 = { .min = 5, .max = 9 }, |
390 | .p = { .min = I9XX_P_SDVO_DAC_MIN, .max = I9XX_P_SDVO_DAC_MAX }, | 141 | .p = { .min = 5, .max = 80 }, |
391 | .p1 = { .min = I9XX_P1_MIN, .max = I9XX_P1_MAX }, | 142 | .p1 = { .min = 1, .max = 8 }, |
392 | .p2 = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT, | 143 | .p2 = { .dot_limit = 200000, |
393 | .p2_slow = I9XX_P2_SDVO_DAC_SLOW, .p2_fast = I9XX_P2_SDVO_DAC_FAST }, | 144 | .p2_slow = 10, .p2_fast = 5 }, |
394 | .find_pll = intel_find_best_PLL, | 145 | .find_pll = intel_find_best_PLL, |
395 | }; | 146 | }; |
396 | 147 | ||
397 | static const intel_limit_t intel_limits_i9xx_lvds = { | 148 | static const intel_limit_t intel_limits_i9xx_lvds = { |
398 | .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX }, | 149 | .dot = { .min = 20000, .max = 400000 }, |
399 | .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX }, | 150 | .vco = { .min = 1400000, .max = 2800000 }, |
400 | .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX }, | 151 | .n = { .min = 1, .max = 6 }, |
401 | .m = { .min = I9XX_M_MIN, .max = I9XX_M_MAX }, | 152 | .m = { .min = 70, .max = 120 }, |
402 | .m1 = { .min = I9XX_M1_MIN, .max = I9XX_M1_MAX }, | 153 | .m1 = { .min = 10, .max = 22 }, |
403 | .m2 = { .min = I9XX_M2_MIN, .max = I9XX_M2_MAX }, | 154 | .m2 = { .min = 5, .max = 9 }, |
404 | .p = { .min = I9XX_P_LVDS_MIN, .max = I9XX_P_LVDS_MAX }, | 155 | .p = { .min = 7, .max = 98 }, |
405 | .p1 = { .min = I9XX_P1_MIN, .max = I9XX_P1_MAX }, | 156 | .p1 = { .min = 1, .max = 8 }, |
406 | /* The single-channel range is 25-112Mhz, and dual-channel | 157 | .p2 = { .dot_limit = 112000, |
407 | * is 80-224Mhz. Prefer single channel as much as possible. | 158 | .p2_slow = 14, .p2_fast = 7 }, |
408 | */ | ||
409 | .p2 = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT, | ||
410 | .p2_slow = I9XX_P2_LVDS_SLOW, .p2_fast = I9XX_P2_LVDS_FAST }, | ||
411 | .find_pll = intel_find_best_PLL, | 159 | .find_pll = intel_find_best_PLL, |
412 | }; | 160 | }; |
413 | 161 | ||
414 | /* below parameter and function is for G4X Chipset Family*/ | 162 | |
415 | static const intel_limit_t intel_limits_g4x_sdvo = { | 163 | static const intel_limit_t intel_limits_g4x_sdvo = { |
416 | .dot = { .min = G4X_DOT_SDVO_MIN, .max = G4X_DOT_SDVO_MAX }, | 164 | .dot = { .min = 25000, .max = 270000 }, |
417 | .vco = { .min = G4X_VCO_MIN, .max = G4X_VCO_MAX}, | 165 | .vco = { .min = 1750000, .max = 3500000}, |
418 | .n = { .min = G4X_N_SDVO_MIN, .max = G4X_N_SDVO_MAX }, | 166 | .n = { .min = 1, .max = 4 }, |
419 | .m = { .min = G4X_M_SDVO_MIN, .max = G4X_M_SDVO_MAX }, | 167 | .m = { .min = 104, .max = 138 }, |
420 | .m1 = { .min = G4X_M1_SDVO_MIN, .max = G4X_M1_SDVO_MAX }, | 168 | .m1 = { .min = 17, .max = 23 }, |
421 | .m2 = { .min = G4X_M2_SDVO_MIN, .max = G4X_M2_SDVO_MAX }, | 169 | .m2 = { .min = 5, .max = 11 }, |
422 | .p = { .min = G4X_P_SDVO_MIN, .max = G4X_P_SDVO_MAX }, | 170 | .p = { .min = 10, .max = 30 }, |
423 | .p1 = { .min = G4X_P1_SDVO_MIN, .max = G4X_P1_SDVO_MAX}, | 171 | .p1 = { .min = 1, .max = 3}, |
424 | .p2 = { .dot_limit = G4X_P2_SDVO_LIMIT, | 172 | .p2 = { .dot_limit = 270000, |
425 | .p2_slow = G4X_P2_SDVO_SLOW, | 173 | .p2_slow = 10, |
426 | .p2_fast = G4X_P2_SDVO_FAST | 174 | .p2_fast = 10 |
427 | }, | 175 | }, |
428 | .find_pll = intel_g4x_find_best_PLL, | 176 | .find_pll = intel_g4x_find_best_PLL, |
429 | }; | 177 | }; |
430 | 178 | ||
431 | static const intel_limit_t intel_limits_g4x_hdmi = { | 179 | static const intel_limit_t intel_limits_g4x_hdmi = { |
432 | .dot = { .min = G4X_DOT_HDMI_DAC_MIN, .max = G4X_DOT_HDMI_DAC_MAX }, | 180 | .dot = { .min = 22000, .max = 400000 }, |
433 | .vco = { .min = G4X_VCO_MIN, .max = G4X_VCO_MAX}, | 181 | .vco = { .min = 1750000, .max = 3500000}, |
434 | .n = { .min = G4X_N_HDMI_DAC_MIN, .max = G4X_N_HDMI_DAC_MAX }, | 182 | .n = { .min = 1, .max = 4 }, |
435 | .m = { .min = G4X_M_HDMI_DAC_MIN, .max = G4X_M_HDMI_DAC_MAX }, | 183 | .m = { .min = 104, .max = 138 }, |
436 | .m1 = { .min = G4X_M1_HDMI_DAC_MIN, .max = G4X_M1_HDMI_DAC_MAX }, | 184 | .m1 = { .min = 16, .max = 23 }, |
437 | .m2 = { .min = G4X_M2_HDMI_DAC_MIN, .max = G4X_M2_HDMI_DAC_MAX }, | 185 | .m2 = { .min = 5, .max = 11 }, |
438 | .p = { .min = G4X_P_HDMI_DAC_MIN, .max = G4X_P_HDMI_DAC_MAX }, | 186 | .p = { .min = 5, .max = 80 }, |
439 | .p1 = { .min = G4X_P1_HDMI_DAC_MIN, .max = G4X_P1_HDMI_DAC_MAX}, | 187 | .p1 = { .min = 1, .max = 8}, |
440 | .p2 = { .dot_limit = G4X_P2_HDMI_DAC_LIMIT, | 188 | .p2 = { .dot_limit = 165000, |
441 | .p2_slow = G4X_P2_HDMI_DAC_SLOW, | 189 | .p2_slow = 10, .p2_fast = 5 }, |
442 | .p2_fast = G4X_P2_HDMI_DAC_FAST | ||
443 | }, | ||
444 | .find_pll = intel_g4x_find_best_PLL, | 190 | .find_pll = intel_g4x_find_best_PLL, |
445 | }; | 191 | }; |
446 | 192 | ||
447 | static const intel_limit_t intel_limits_g4x_single_channel_lvds = { | 193 | static const intel_limit_t intel_limits_g4x_single_channel_lvds = { |
448 | .dot = { .min = G4X_DOT_SINGLE_CHANNEL_LVDS_MIN, | 194 | .dot = { .min = 20000, .max = 115000 }, |
449 | .max = G4X_DOT_SINGLE_CHANNEL_LVDS_MAX }, | 195 | .vco = { .min = 1750000, .max = 3500000 }, |
450 | .vco = { .min = G4X_VCO_MIN, | 196 | .n = { .min = 1, .max = 3 }, |
451 | .max = G4X_VCO_MAX }, | 197 | .m = { .min = 104, .max = 138 }, |
452 | .n = { .min = G4X_N_SINGLE_CHANNEL_LVDS_MIN, | 198 | .m1 = { .min = 17, .max = 23 }, |
453 | .max = G4X_N_SINGLE_CHANNEL_LVDS_MAX }, | 199 | .m2 = { .min = 5, .max = 11 }, |
454 | .m = { .min = G4X_M_SINGLE_CHANNEL_LVDS_MIN, | 200 | .p = { .min = 28, .max = 112 }, |
455 | .max = G4X_M_SINGLE_CHANNEL_LVDS_MAX }, | 201 | .p1 = { .min = 2, .max = 8 }, |
456 | .m1 = { .min = G4X_M1_SINGLE_CHANNEL_LVDS_MIN, | 202 | .p2 = { .dot_limit = 0, |
457 | .max = G4X_M1_SINGLE_CHANNEL_LVDS_MAX }, | 203 | .p2_slow = 14, .p2_fast = 14 |
458 | .m2 = { .min = G4X_M2_SINGLE_CHANNEL_LVDS_MIN, | ||
459 | .max = G4X_M2_SINGLE_CHANNEL_LVDS_MAX }, | ||
460 | .p = { .min = G4X_P_SINGLE_CHANNEL_LVDS_MIN, | ||
461 | .max = G4X_P_SINGLE_CHANNEL_LVDS_MAX }, | ||
462 | .p1 = { .min = G4X_P1_SINGLE_CHANNEL_LVDS_MIN, | ||
463 | .max = G4X_P1_SINGLE_CHANNEL_LVDS_MAX }, | ||
464 | .p2 = { .dot_limit = G4X_P2_SINGLE_CHANNEL_LVDS_LIMIT, | ||
465 | .p2_slow = G4X_P2_SINGLE_CHANNEL_LVDS_SLOW, | ||
466 | .p2_fast = G4X_P2_SINGLE_CHANNEL_LVDS_FAST | ||
467 | }, | 204 | }, |
468 | .find_pll = intel_g4x_find_best_PLL, | 205 | .find_pll = intel_g4x_find_best_PLL, |
469 | }; | 206 | }; |
470 | 207 | ||
471 | static const intel_limit_t intel_limits_g4x_dual_channel_lvds = { | 208 | static const intel_limit_t intel_limits_g4x_dual_channel_lvds = { |
472 | .dot = { .min = G4X_DOT_DUAL_CHANNEL_LVDS_MIN, | 209 | .dot = { .min = 80000, .max = 224000 }, |
473 | .max = G4X_DOT_DUAL_CHANNEL_LVDS_MAX }, | 210 | .vco = { .min = 1750000, .max = 3500000 }, |
474 | .vco = { .min = G4X_VCO_MIN, | 211 | .n = { .min = 1, .max = 3 }, |
475 | .max = G4X_VCO_MAX }, | 212 | .m = { .min = 104, .max = 138 }, |
476 | .n = { .min = G4X_N_DUAL_CHANNEL_LVDS_MIN, | 213 | .m1 = { .min = 17, .max = 23 }, |
477 | .max = G4X_N_DUAL_CHANNEL_LVDS_MAX }, | 214 | .m2 = { .min = 5, .max = 11 }, |
478 | .m = { .min = G4X_M_DUAL_CHANNEL_LVDS_MIN, | 215 | .p = { .min = 14, .max = 42 }, |
479 | .max = G4X_M_DUAL_CHANNEL_LVDS_MAX }, | 216 | .p1 = { .min = 2, .max = 6 }, |
480 | .m1 = { .min = G4X_M1_DUAL_CHANNEL_LVDS_MIN, | 217 | .p2 = { .dot_limit = 0, |
481 | .max = G4X_M1_DUAL_CHANNEL_LVDS_MAX }, | 218 | .p2_slow = 7, .p2_fast = 7 |
482 | .m2 = { .min = G4X_M2_DUAL_CHANNEL_LVDS_MIN, | ||
483 | .max = G4X_M2_DUAL_CHANNEL_LVDS_MAX }, | ||
484 | .p = { .min = G4X_P_DUAL_CHANNEL_LVDS_MIN, | ||
485 | .max = G4X_P_DUAL_CHANNEL_LVDS_MAX }, | ||
486 | .p1 = { .min = G4X_P1_DUAL_CHANNEL_LVDS_MIN, | ||
487 | .max = G4X_P1_DUAL_CHANNEL_LVDS_MAX }, | ||
488 | .p2 = { .dot_limit = G4X_P2_DUAL_CHANNEL_LVDS_LIMIT, | ||
489 | .p2_slow = G4X_P2_DUAL_CHANNEL_LVDS_SLOW, | ||
490 | .p2_fast = G4X_P2_DUAL_CHANNEL_LVDS_FAST | ||
491 | }, | 219 | }, |
492 | .find_pll = intel_g4x_find_best_PLL, | 220 | .find_pll = intel_g4x_find_best_PLL, |
493 | }; | 221 | }; |
494 | 222 | ||
495 | static const intel_limit_t intel_limits_g4x_display_port = { | 223 | static const intel_limit_t intel_limits_g4x_display_port = { |
496 | .dot = { .min = G4X_DOT_DISPLAY_PORT_MIN, | 224 | .dot = { .min = 161670, .max = 227000 }, |
497 | .max = G4X_DOT_DISPLAY_PORT_MAX }, | 225 | .vco = { .min = 1750000, .max = 3500000}, |
498 | .vco = { .min = G4X_VCO_MIN, | 226 | .n = { .min = 1, .max = 2 }, |
499 | .max = G4X_VCO_MAX}, | 227 | .m = { .min = 97, .max = 108 }, |
500 | .n = { .min = G4X_N_DISPLAY_PORT_MIN, | 228 | .m1 = { .min = 0x10, .max = 0x12 }, |
501 | .max = G4X_N_DISPLAY_PORT_MAX }, | 229 | .m2 = { .min = 0x05, .max = 0x06 }, |
502 | .m = { .min = G4X_M_DISPLAY_PORT_MIN, | 230 | .p = { .min = 10, .max = 20 }, |
503 | .max = G4X_M_DISPLAY_PORT_MAX }, | 231 | .p1 = { .min = 1, .max = 2}, |
504 | .m1 = { .min = G4X_M1_DISPLAY_PORT_MIN, | 232 | .p2 = { .dot_limit = 0, |
505 | .max = G4X_M1_DISPLAY_PORT_MAX }, | 233 | .p2_slow = 10, .p2_fast = 10 }, |
506 | .m2 = { .min = G4X_M2_DISPLAY_PORT_MIN, | ||
507 | .max = G4X_M2_DISPLAY_PORT_MAX }, | ||
508 | .p = { .min = G4X_P_DISPLAY_PORT_MIN, | ||
509 | .max = G4X_P_DISPLAY_PORT_MAX }, | ||
510 | .p1 = { .min = G4X_P1_DISPLAY_PORT_MIN, | ||
511 | .max = G4X_P1_DISPLAY_PORT_MAX}, | ||
512 | .p2 = { .dot_limit = G4X_P2_DISPLAY_PORT_LIMIT, | ||
513 | .p2_slow = G4X_P2_DISPLAY_PORT_SLOW, | ||
514 | .p2_fast = G4X_P2_DISPLAY_PORT_FAST }, | ||
515 | .find_pll = intel_find_pll_g4x_dp, | 234 | .find_pll = intel_find_pll_g4x_dp, |
516 | }; | 235 | }; |
517 | 236 | ||
518 | static const intel_limit_t intel_limits_pineview_sdvo = { | 237 | static const intel_limit_t intel_limits_pineview_sdvo = { |
519 | .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX}, | 238 | .dot = { .min = 20000, .max = 400000}, |
520 | .vco = { .min = PINEVIEW_VCO_MIN, .max = PINEVIEW_VCO_MAX }, | 239 | .vco = { .min = 1700000, .max = 3500000 }, |
521 | .n = { .min = PINEVIEW_N_MIN, .max = PINEVIEW_N_MAX }, | 240 | /* Pineview's Ncounter is a ring counter */ |
522 | .m = { .min = PINEVIEW_M_MIN, .max = PINEVIEW_M_MAX }, | 241 | .n = { .min = 3, .max = 6 }, |
523 | .m1 = { .min = PINEVIEW_M1_MIN, .max = PINEVIEW_M1_MAX }, | 242 | .m = { .min = 2, .max = 256 }, |
524 | .m2 = { .min = PINEVIEW_M2_MIN, .max = PINEVIEW_M2_MAX }, | 243 | /* Pineview only has one combined m divider, which we treat as m2. */ |
525 | .p = { .min = I9XX_P_SDVO_DAC_MIN, .max = I9XX_P_SDVO_DAC_MAX }, | 244 | .m1 = { .min = 0, .max = 0 }, |
526 | .p1 = { .min = I9XX_P1_MIN, .max = I9XX_P1_MAX }, | 245 | .m2 = { .min = 0, .max = 254 }, |
527 | .p2 = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT, | 246 | .p = { .min = 5, .max = 80 }, |
528 | .p2_slow = I9XX_P2_SDVO_DAC_SLOW, .p2_fast = I9XX_P2_SDVO_DAC_FAST }, | 247 | .p1 = { .min = 1, .max = 8 }, |
248 | .p2 = { .dot_limit = 200000, | ||
249 | .p2_slow = 10, .p2_fast = 5 }, | ||
529 | .find_pll = intel_find_best_PLL, | 250 | .find_pll = intel_find_best_PLL, |
530 | }; | 251 | }; |
531 | 252 | ||
532 | static const intel_limit_t intel_limits_pineview_lvds = { | 253 | static const intel_limit_t intel_limits_pineview_lvds = { |
533 | .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX }, | 254 | .dot = { .min = 20000, .max = 400000 }, |
534 | .vco = { .min = PINEVIEW_VCO_MIN, .max = PINEVIEW_VCO_MAX }, | 255 | .vco = { .min = 1700000, .max = 3500000 }, |
535 | .n = { .min = PINEVIEW_N_MIN, .max = PINEVIEW_N_MAX }, | 256 | .n = { .min = 3, .max = 6 }, |
536 | .m = { .min = PINEVIEW_M_MIN, .max = PINEVIEW_M_MAX }, | 257 | .m = { .min = 2, .max = 256 }, |
537 | .m1 = { .min = PINEVIEW_M1_MIN, .max = PINEVIEW_M1_MAX }, | 258 | .m1 = { .min = 0, .max = 0 }, |
538 | .m2 = { .min = PINEVIEW_M2_MIN, .max = PINEVIEW_M2_MAX }, | 259 | .m2 = { .min = 0, .max = 254 }, |
539 | .p = { .min = PINEVIEW_P_LVDS_MIN, .max = PINEVIEW_P_LVDS_MAX }, | 260 | .p = { .min = 7, .max = 112 }, |
540 | .p1 = { .min = I9XX_P1_MIN, .max = I9XX_P1_MAX }, | 261 | .p1 = { .min = 1, .max = 8 }, |
541 | /* Pineview only supports single-channel mode. */ | 262 | .p2 = { .dot_limit = 112000, |
542 | .p2 = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT, | 263 | .p2_slow = 14, .p2_fast = 14 }, |
543 | .p2_slow = I9XX_P2_LVDS_SLOW, .p2_fast = I9XX_P2_LVDS_SLOW }, | ||
544 | .find_pll = intel_find_best_PLL, | 264 | .find_pll = intel_find_best_PLL, |
545 | }; | 265 | }; |
546 | 266 | ||
267 | /* Ironlake / Sandybridge | ||
268 | * | ||
269 | * We calculate clock using (register_value + 2) for N/M1/M2, so here | ||
270 | * the range value for them is (actual_value - 2). | ||
271 | */ | ||
547 | static const intel_limit_t intel_limits_ironlake_dac = { | 272 | static const intel_limit_t intel_limits_ironlake_dac = { |
548 | .dot = { .min = IRONLAKE_DOT_MIN, .max = IRONLAKE_DOT_MAX }, | 273 | .dot = { .min = 25000, .max = 350000 }, |
549 | .vco = { .min = IRONLAKE_VCO_MIN, .max = IRONLAKE_VCO_MAX }, | 274 | .vco = { .min = 1760000, .max = 3510000 }, |
550 | .n = { .min = IRONLAKE_DAC_N_MIN, .max = IRONLAKE_DAC_N_MAX }, | 275 | .n = { .min = 1, .max = 5 }, |
551 | .m = { .min = IRONLAKE_DAC_M_MIN, .max = IRONLAKE_DAC_M_MAX }, | 276 | .m = { .min = 79, .max = 127 }, |
552 | .m1 = { .min = IRONLAKE_M1_MIN, .max = IRONLAKE_M1_MAX }, | 277 | .m1 = { .min = 12, .max = 22 }, |
553 | .m2 = { .min = IRONLAKE_M2_MIN, .max = IRONLAKE_M2_MAX }, | 278 | .m2 = { .min = 5, .max = 9 }, |
554 | .p = { .min = IRONLAKE_DAC_P_MIN, .max = IRONLAKE_DAC_P_MAX }, | 279 | .p = { .min = 5, .max = 80 }, |
555 | .p1 = { .min = IRONLAKE_DAC_P1_MIN, .max = IRONLAKE_DAC_P1_MAX }, | 280 | .p1 = { .min = 1, .max = 8 }, |
556 | .p2 = { .dot_limit = IRONLAKE_P2_DOT_LIMIT, | 281 | .p2 = { .dot_limit = 225000, |
557 | .p2_slow = IRONLAKE_DAC_P2_SLOW, | 282 | .p2_slow = 10, .p2_fast = 5 }, |
558 | .p2_fast = IRONLAKE_DAC_P2_FAST }, | ||
559 | .find_pll = intel_g4x_find_best_PLL, | 283 | .find_pll = intel_g4x_find_best_PLL, |
560 | }; | 284 | }; |
561 | 285 | ||
562 | static const intel_limit_t intel_limits_ironlake_single_lvds = { | 286 | static const intel_limit_t intel_limits_ironlake_single_lvds = { |
563 | .dot = { .min = IRONLAKE_DOT_MIN, .max = IRONLAKE_DOT_MAX }, | 287 | .dot = { .min = 25000, .max = 350000 }, |
564 | .vco = { .min = IRONLAKE_VCO_MIN, .max = IRONLAKE_VCO_MAX }, | 288 | .vco = { .min = 1760000, .max = 3510000 }, |
565 | .n = { .min = IRONLAKE_LVDS_S_N_MIN, .max = IRONLAKE_LVDS_S_N_MAX }, | 289 | .n = { .min = 1, .max = 3 }, |
566 | .m = { .min = IRONLAKE_LVDS_S_M_MIN, .max = IRONLAKE_LVDS_S_M_MAX }, | 290 | .m = { .min = 79, .max = 118 }, |
567 | .m1 = { .min = IRONLAKE_M1_MIN, .max = IRONLAKE_M1_MAX }, | 291 | .m1 = { .min = 12, .max = 22 }, |
568 | .m2 = { .min = IRONLAKE_M2_MIN, .max = IRONLAKE_M2_MAX }, | 292 | .m2 = { .min = 5, .max = 9 }, |
569 | .p = { .min = IRONLAKE_LVDS_S_P_MIN, .max = IRONLAKE_LVDS_S_P_MAX }, | 293 | .p = { .min = 28, .max = 112 }, |
570 | .p1 = { .min = IRONLAKE_LVDS_S_P1_MIN, .max = IRONLAKE_LVDS_S_P1_MAX }, | 294 | .p1 = { .min = 2, .max = 8 }, |
571 | .p2 = { .dot_limit = IRONLAKE_P2_DOT_LIMIT, | 295 | .p2 = { .dot_limit = 225000, |
572 | .p2_slow = IRONLAKE_LVDS_S_P2_SLOW, | 296 | .p2_slow = 14, .p2_fast = 14 }, |
573 | .p2_fast = IRONLAKE_LVDS_S_P2_FAST }, | ||
574 | .find_pll = intel_g4x_find_best_PLL, | 297 | .find_pll = intel_g4x_find_best_PLL, |
575 | }; | 298 | }; |
576 | 299 | ||
577 | static const intel_limit_t intel_limits_ironlake_dual_lvds = { | 300 | static const intel_limit_t intel_limits_ironlake_dual_lvds = { |
578 | .dot = { .min = IRONLAKE_DOT_MIN, .max = IRONLAKE_DOT_MAX }, | 301 | .dot = { .min = 25000, .max = 350000 }, |
579 | .vco = { .min = IRONLAKE_VCO_MIN, .max = IRONLAKE_VCO_MAX }, | 302 | .vco = { .min = 1760000, .max = 3510000 }, |
580 | .n = { .min = IRONLAKE_LVDS_D_N_MIN, .max = IRONLAKE_LVDS_D_N_MAX }, | 303 | .n = { .min = 1, .max = 3 }, |
581 | .m = { .min = IRONLAKE_LVDS_D_M_MIN, .max = IRONLAKE_LVDS_D_M_MAX }, | 304 | .m = { .min = 79, .max = 127 }, |
582 | .m1 = { .min = IRONLAKE_M1_MIN, .max = IRONLAKE_M1_MAX }, | 305 | .m1 = { .min = 12, .max = 22 }, |
583 | .m2 = { .min = IRONLAKE_M2_MIN, .max = IRONLAKE_M2_MAX }, | 306 | .m2 = { .min = 5, .max = 9 }, |
584 | .p = { .min = IRONLAKE_LVDS_D_P_MIN, .max = IRONLAKE_LVDS_D_P_MAX }, | 307 | .p = { .min = 14, .max = 56 }, |
585 | .p1 = { .min = IRONLAKE_LVDS_D_P1_MIN, .max = IRONLAKE_LVDS_D_P1_MAX }, | 308 | .p1 = { .min = 2, .max = 8 }, |
586 | .p2 = { .dot_limit = IRONLAKE_P2_DOT_LIMIT, | 309 | .p2 = { .dot_limit = 225000, |
587 | .p2_slow = IRONLAKE_LVDS_D_P2_SLOW, | 310 | .p2_slow = 7, .p2_fast = 7 }, |
588 | .p2_fast = IRONLAKE_LVDS_D_P2_FAST }, | ||
589 | .find_pll = intel_g4x_find_best_PLL, | 311 | .find_pll = intel_g4x_find_best_PLL, |
590 | }; | 312 | }; |
591 | 313 | ||
314 | /* LVDS 100mhz refclk limits. */ | ||
592 | static const intel_limit_t intel_limits_ironlake_single_lvds_100m = { | 315 | static const intel_limit_t intel_limits_ironlake_single_lvds_100m = { |
593 | .dot = { .min = IRONLAKE_DOT_MIN, .max = IRONLAKE_DOT_MAX }, | 316 | .dot = { .min = 25000, .max = 350000 }, |
594 | .vco = { .min = IRONLAKE_VCO_MIN, .max = IRONLAKE_VCO_MAX }, | 317 | .vco = { .min = 1760000, .max = 3510000 }, |
595 | .n = { .min = IRONLAKE_LVDS_S_SSC_N_MIN, .max = IRONLAKE_LVDS_S_SSC_N_MAX }, | 318 | .n = { .min = 1, .max = 2 }, |
596 | .m = { .min = IRONLAKE_LVDS_S_SSC_M_MIN, .max = IRONLAKE_LVDS_S_SSC_M_MAX }, | 319 | .m = { .min = 79, .max = 126 }, |
597 | .m1 = { .min = IRONLAKE_M1_MIN, .max = IRONLAKE_M1_MAX }, | 320 | .m1 = { .min = 12, .max = 22 }, |
598 | .m2 = { .min = IRONLAKE_M2_MIN, .max = IRONLAKE_M2_MAX }, | 321 | .m2 = { .min = 5, .max = 9 }, |
599 | .p = { .min = IRONLAKE_LVDS_S_SSC_P_MIN, .max = IRONLAKE_LVDS_S_SSC_P_MAX }, | 322 | .p = { .min = 28, .max = 112 }, |
600 | .p1 = { .min = IRONLAKE_LVDS_S_SSC_P1_MIN,.max = IRONLAKE_LVDS_S_SSC_P1_MAX }, | 323 | .p1 = { .min = 2,.max = 8 }, |
601 | .p2 = { .dot_limit = IRONLAKE_P2_DOT_LIMIT, | 324 | .p2 = { .dot_limit = 225000, |
602 | .p2_slow = IRONLAKE_LVDS_S_SSC_P2_SLOW, | 325 | .p2_slow = 14, .p2_fast = 14 }, |
603 | .p2_fast = IRONLAKE_LVDS_S_SSC_P2_FAST }, | ||
604 | .find_pll = intel_g4x_find_best_PLL, | 326 | .find_pll = intel_g4x_find_best_PLL, |
605 | }; | 327 | }; |
606 | 328 | ||
607 | static const intel_limit_t intel_limits_ironlake_dual_lvds_100m = { | 329 | static const intel_limit_t intel_limits_ironlake_dual_lvds_100m = { |
608 | .dot = { .min = IRONLAKE_DOT_MIN, .max = IRONLAKE_DOT_MAX }, | 330 | .dot = { .min = 25000, .max = 350000 }, |
609 | .vco = { .min = IRONLAKE_VCO_MIN, .max = IRONLAKE_VCO_MAX }, | 331 | .vco = { .min = 1760000, .max = 3510000 }, |
610 | .n = { .min = IRONLAKE_LVDS_D_SSC_N_MIN, .max = IRONLAKE_LVDS_D_SSC_N_MAX }, | 332 | .n = { .min = 1, .max = 3 }, |
611 | .m = { .min = IRONLAKE_LVDS_D_SSC_M_MIN, .max = IRONLAKE_LVDS_D_SSC_M_MAX }, | 333 | .m = { .min = 79, .max = 126 }, |
612 | .m1 = { .min = IRONLAKE_M1_MIN, .max = IRONLAKE_M1_MAX }, | 334 | .m1 = { .min = 12, .max = 22 }, |
613 | .m2 = { .min = IRONLAKE_M2_MIN, .max = IRONLAKE_M2_MAX }, | 335 | .m2 = { .min = 5, .max = 9 }, |
614 | .p = { .min = IRONLAKE_LVDS_D_SSC_P_MIN, .max = IRONLAKE_LVDS_D_SSC_P_MAX }, | 336 | .p = { .min = 14, .max = 42 }, |
615 | .p1 = { .min = IRONLAKE_LVDS_D_SSC_P1_MIN,.max = IRONLAKE_LVDS_D_SSC_P1_MAX }, | 337 | .p1 = { .min = 2,.max = 6 }, |
616 | .p2 = { .dot_limit = IRONLAKE_P2_DOT_LIMIT, | 338 | .p2 = { .dot_limit = 225000, |
617 | .p2_slow = IRONLAKE_LVDS_D_SSC_P2_SLOW, | 339 | .p2_slow = 7, .p2_fast = 7 }, |
618 | .p2_fast = IRONLAKE_LVDS_D_SSC_P2_FAST }, | ||
619 | .find_pll = intel_g4x_find_best_PLL, | 340 | .find_pll = intel_g4x_find_best_PLL, |
620 | }; | 341 | }; |
621 | 342 | ||
622 | static const intel_limit_t intel_limits_ironlake_display_port = { | 343 | static const intel_limit_t intel_limits_ironlake_display_port = { |
623 | .dot = { .min = IRONLAKE_DOT_MIN, | 344 | .dot = { .min = 25000, .max = 350000 }, |
624 | .max = IRONLAKE_DOT_MAX }, | 345 | .vco = { .min = 1760000, .max = 3510000}, |
625 | .vco = { .min = IRONLAKE_VCO_MIN, | 346 | .n = { .min = 1, .max = 2 }, |
626 | .max = IRONLAKE_VCO_MAX}, | 347 | .m = { .min = 81, .max = 90 }, |
627 | .n = { .min = IRONLAKE_DP_N_MIN, | 348 | .m1 = { .min = 12, .max = 22 }, |
628 | .max = IRONLAKE_DP_N_MAX }, | 349 | .m2 = { .min = 5, .max = 9 }, |
629 | .m = { .min = IRONLAKE_DP_M_MIN, | 350 | .p = { .min = 10, .max = 20 }, |
630 | .max = IRONLAKE_DP_M_MAX }, | 351 | .p1 = { .min = 1, .max = 2}, |
631 | .m1 = { .min = IRONLAKE_M1_MIN, | 352 | .p2 = { .dot_limit = 0, |
632 | .max = IRONLAKE_M1_MAX }, | 353 | .p2_slow = 10, .p2_fast = 10 }, |
633 | .m2 = { .min = IRONLAKE_M2_MIN, | ||
634 | .max = IRONLAKE_M2_MAX }, | ||
635 | .p = { .min = IRONLAKE_DP_P_MIN, | ||
636 | .max = IRONLAKE_DP_P_MAX }, | ||
637 | .p1 = { .min = IRONLAKE_DP_P1_MIN, | ||
638 | .max = IRONLAKE_DP_P1_MAX}, | ||
639 | .p2 = { .dot_limit = IRONLAKE_DP_P2_LIMIT, | ||
640 | .p2_slow = IRONLAKE_DP_P2_SLOW, | ||
641 | .p2_fast = IRONLAKE_DP_P2_FAST }, | ||
642 | .find_pll = intel_find_pll_ironlake_dp, | 354 | .find_pll = intel_find_pll_ironlake_dp, |
643 | }; | 355 | }; |
644 | 356 | ||
@@ -1828,7 +1540,7 @@ static void sandybridge_blit_fbc_update(struct drm_device *dev) | |||
1828 | u32 blt_ecoskpd; | 1540 | u32 blt_ecoskpd; |
1829 | 1541 | ||
1830 | /* Make sure blitter notifies FBC of writes */ | 1542 | /* Make sure blitter notifies FBC of writes */ |
1831 | __gen6_gt_force_wake_get(dev_priv); | 1543 | gen6_gt_force_wake_get(dev_priv); |
1832 | blt_ecoskpd = I915_READ(GEN6_BLITTER_ECOSKPD); | 1544 | blt_ecoskpd = I915_READ(GEN6_BLITTER_ECOSKPD); |
1833 | blt_ecoskpd |= GEN6_BLITTER_FBC_NOTIFY << | 1545 | blt_ecoskpd |= GEN6_BLITTER_FBC_NOTIFY << |
1834 | GEN6_BLITTER_LOCK_SHIFT; | 1546 | GEN6_BLITTER_LOCK_SHIFT; |
@@ -1839,7 +1551,7 @@ static void sandybridge_blit_fbc_update(struct drm_device *dev) | |||
1839 | GEN6_BLITTER_LOCK_SHIFT); | 1551 | GEN6_BLITTER_LOCK_SHIFT); |
1840 | I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd); | 1552 | I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd); |
1841 | POSTING_READ(GEN6_BLITTER_ECOSKPD); | 1553 | POSTING_READ(GEN6_BLITTER_ECOSKPD); |
1842 | __gen6_gt_force_wake_put(dev_priv); | 1554 | gen6_gt_force_wake_put(dev_priv); |
1843 | } | 1555 | } |
1844 | 1556 | ||
1845 | static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) | 1557 | static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) |
@@ -2339,8 +2051,13 @@ static void intel_fdi_normal_train(struct drm_crtc *crtc) | |||
2339 | /* enable normal train */ | 2051 | /* enable normal train */ |
2340 | reg = FDI_TX_CTL(pipe); | 2052 | reg = FDI_TX_CTL(pipe); |
2341 | temp = I915_READ(reg); | 2053 | temp = I915_READ(reg); |
2342 | temp &= ~FDI_LINK_TRAIN_NONE; | 2054 | if (IS_GEN6(dev)) { |
2343 | temp |= FDI_LINK_TRAIN_NONE | FDI_TX_ENHANCE_FRAME_ENABLE; | 2055 | temp &= ~FDI_LINK_TRAIN_NONE; |
2056 | temp |= FDI_LINK_TRAIN_NONE | FDI_TX_ENHANCE_FRAME_ENABLE; | ||
2057 | } else if (IS_IVYBRIDGE(dev)) { | ||
2058 | temp &= ~FDI_LINK_TRAIN_NONE_IVB; | ||
2059 | temp |= FDI_LINK_TRAIN_NONE_IVB | FDI_TX_ENHANCE_FRAME_ENABLE; | ||
2060 | } | ||
2344 | I915_WRITE(reg, temp); | 2061 | I915_WRITE(reg, temp); |
2345 | 2062 | ||
2346 | reg = FDI_RX_CTL(pipe); | 2063 | reg = FDI_RX_CTL(pipe); |
@@ -2357,6 +2074,11 @@ static void intel_fdi_normal_train(struct drm_crtc *crtc) | |||
2357 | /* wait one idle pattern time */ | 2074 | /* wait one idle pattern time */ |
2358 | POSTING_READ(reg); | 2075 | POSTING_READ(reg); |
2359 | udelay(1000); | 2076 | udelay(1000); |
2077 | |||
2078 | /* IVB wants error correction enabled */ | ||
2079 | if (IS_IVYBRIDGE(dev)) | ||
2080 | I915_WRITE(reg, I915_READ(reg) | FDI_FS_ERRC_ENABLE | | ||
2081 | FDI_FE_ERRC_ENABLE); | ||
2360 | } | 2082 | } |
2361 | 2083 | ||
2362 | /* The FDI link training functions for ILK/Ibexpeak. */ | 2084 | /* The FDI link training functions for ILK/Ibexpeak. */ |
@@ -2584,7 +2306,116 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc) | |||
2584 | DRM_DEBUG_KMS("FDI train done.\n"); | 2306 | DRM_DEBUG_KMS("FDI train done.\n"); |
2585 | } | 2307 | } |
2586 | 2308 | ||
2587 | static void ironlake_fdi_enable(struct drm_crtc *crtc) | 2309 | /* Manual link training for Ivy Bridge A0 parts */ |
2310 | static void ivb_manual_fdi_link_train(struct drm_crtc *crtc) | ||
2311 | { | ||
2312 | struct drm_device *dev = crtc->dev; | ||
2313 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
2314 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
2315 | int pipe = intel_crtc->pipe; | ||
2316 | u32 reg, temp, i; | ||
2317 | |||
2318 | /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit | ||
2319 | for train result */ | ||
2320 | reg = FDI_RX_IMR(pipe); | ||
2321 | temp = I915_READ(reg); | ||
2322 | temp &= ~FDI_RX_SYMBOL_LOCK; | ||
2323 | temp &= ~FDI_RX_BIT_LOCK; | ||
2324 | I915_WRITE(reg, temp); | ||
2325 | |||
2326 | POSTING_READ(reg); | ||
2327 | udelay(150); | ||
2328 | |||
2329 | /* enable CPU FDI TX and PCH FDI RX */ | ||
2330 | reg = FDI_TX_CTL(pipe); | ||
2331 | temp = I915_READ(reg); | ||
2332 | temp &= ~(7 << 19); | ||
2333 | temp |= (intel_crtc->fdi_lanes - 1) << 19; | ||
2334 | temp &= ~(FDI_LINK_TRAIN_AUTO | FDI_LINK_TRAIN_NONE_IVB); | ||
2335 | temp |= FDI_LINK_TRAIN_PATTERN_1_IVB; | ||
2336 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; | ||
2337 | temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B; | ||
2338 | I915_WRITE(reg, temp | FDI_TX_ENABLE); | ||
2339 | |||
2340 | reg = FDI_RX_CTL(pipe); | ||
2341 | temp = I915_READ(reg); | ||
2342 | temp &= ~FDI_LINK_TRAIN_AUTO; | ||
2343 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; | ||
2344 | temp |= FDI_LINK_TRAIN_PATTERN_1_CPT; | ||
2345 | I915_WRITE(reg, temp | FDI_RX_ENABLE); | ||
2346 | |||
2347 | POSTING_READ(reg); | ||
2348 | udelay(150); | ||
2349 | |||
2350 | for (i = 0; i < 4; i++ ) { | ||
2351 | reg = FDI_TX_CTL(pipe); | ||
2352 | temp = I915_READ(reg); | ||
2353 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; | ||
2354 | temp |= snb_b_fdi_train_param[i]; | ||
2355 | I915_WRITE(reg, temp); | ||
2356 | |||
2357 | POSTING_READ(reg); | ||
2358 | udelay(500); | ||
2359 | |||
2360 | reg = FDI_RX_IIR(pipe); | ||
2361 | temp = I915_READ(reg); | ||
2362 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); | ||
2363 | |||
2364 | if (temp & FDI_RX_BIT_LOCK || | ||
2365 | (I915_READ(reg) & FDI_RX_BIT_LOCK)) { | ||
2366 | I915_WRITE(reg, temp | FDI_RX_BIT_LOCK); | ||
2367 | DRM_DEBUG_KMS("FDI train 1 done.\n"); | ||
2368 | break; | ||
2369 | } | ||
2370 | } | ||
2371 | if (i == 4) | ||
2372 | DRM_ERROR("FDI train 1 fail!\n"); | ||
2373 | |||
2374 | /* Train 2 */ | ||
2375 | reg = FDI_TX_CTL(pipe); | ||
2376 | temp = I915_READ(reg); | ||
2377 | temp &= ~FDI_LINK_TRAIN_NONE_IVB; | ||
2378 | temp |= FDI_LINK_TRAIN_PATTERN_2_IVB; | ||
2379 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; | ||
2380 | temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B; | ||
2381 | I915_WRITE(reg, temp); | ||
2382 | |||
2383 | reg = FDI_RX_CTL(pipe); | ||
2384 | temp = I915_READ(reg); | ||
2385 | temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT; | ||
2386 | temp |= FDI_LINK_TRAIN_PATTERN_2_CPT; | ||
2387 | I915_WRITE(reg, temp); | ||
2388 | |||
2389 | POSTING_READ(reg); | ||
2390 | udelay(150); | ||
2391 | |||
2392 | for (i = 0; i < 4; i++ ) { | ||
2393 | reg = FDI_TX_CTL(pipe); | ||
2394 | temp = I915_READ(reg); | ||
2395 | temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK; | ||
2396 | temp |= snb_b_fdi_train_param[i]; | ||
2397 | I915_WRITE(reg, temp); | ||
2398 | |||
2399 | POSTING_READ(reg); | ||
2400 | udelay(500); | ||
2401 | |||
2402 | reg = FDI_RX_IIR(pipe); | ||
2403 | temp = I915_READ(reg); | ||
2404 | DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp); | ||
2405 | |||
2406 | if (temp & FDI_RX_SYMBOL_LOCK) { | ||
2407 | I915_WRITE(reg, temp | FDI_RX_SYMBOL_LOCK); | ||
2408 | DRM_DEBUG_KMS("FDI train 2 done.\n"); | ||
2409 | break; | ||
2410 | } | ||
2411 | } | ||
2412 | if (i == 4) | ||
2413 | DRM_ERROR("FDI train 2 fail!\n"); | ||
2414 | |||
2415 | DRM_DEBUG_KMS("FDI train done.\n"); | ||
2416 | } | ||
2417 | |||
2418 | static void ironlake_fdi_pll_enable(struct drm_crtc *crtc) | ||
2588 | { | 2419 | { |
2589 | struct drm_device *dev = crtc->dev; | 2420 | struct drm_device *dev = crtc->dev; |
2590 | struct drm_i915_private *dev_priv = dev->dev_private; | 2421 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -2757,10 +2588,7 @@ static void ironlake_pch_enable(struct drm_crtc *crtc) | |||
2757 | u32 reg, temp; | 2588 | u32 reg, temp; |
2758 | 2589 | ||
2759 | /* For PCH output, training FDI link */ | 2590 | /* For PCH output, training FDI link */ |
2760 | if (IS_GEN6(dev)) | 2591 | dev_priv->display.fdi_link_train(crtc); |
2761 | gen6_fdi_link_train(crtc); | ||
2762 | else | ||
2763 | ironlake_fdi_link_train(crtc); | ||
2764 | 2592 | ||
2765 | intel_enable_pch_pll(dev_priv, pipe); | 2593 | intel_enable_pch_pll(dev_priv, pipe); |
2766 | 2594 | ||
@@ -2850,7 +2678,7 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
2850 | is_pch_port = intel_crtc_driving_pch(crtc); | 2678 | is_pch_port = intel_crtc_driving_pch(crtc); |
2851 | 2679 | ||
2852 | if (is_pch_port) | 2680 | if (is_pch_port) |
2853 | ironlake_fdi_enable(crtc); | 2681 | ironlake_fdi_pll_enable(crtc); |
2854 | else | 2682 | else |
2855 | ironlake_fdi_disable(crtc); | 2683 | ironlake_fdi_disable(crtc); |
2856 | 2684 | ||
@@ -2873,7 +2701,11 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
2873 | ironlake_pch_enable(crtc); | 2701 | ironlake_pch_enable(crtc); |
2874 | 2702 | ||
2875 | intel_crtc_load_lut(crtc); | 2703 | intel_crtc_load_lut(crtc); |
2704 | |||
2705 | mutex_lock(&dev->struct_mutex); | ||
2876 | intel_update_fbc(dev); | 2706 | intel_update_fbc(dev); |
2707 | mutex_unlock(&dev->struct_mutex); | ||
2708 | |||
2877 | intel_crtc_update_cursor(crtc, true); | 2709 | intel_crtc_update_cursor(crtc, true); |
2878 | } | 2710 | } |
2879 | 2711 | ||
@@ -2969,8 +2801,11 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) | |||
2969 | 2801 | ||
2970 | intel_crtc->active = false; | 2802 | intel_crtc->active = false; |
2971 | intel_update_watermarks(dev); | 2803 | intel_update_watermarks(dev); |
2804 | |||
2805 | mutex_lock(&dev->struct_mutex); | ||
2972 | intel_update_fbc(dev); | 2806 | intel_update_fbc(dev); |
2973 | intel_clear_scanline_wait(dev); | 2807 | intel_clear_scanline_wait(dev); |
2808 | mutex_unlock(&dev->struct_mutex); | ||
2974 | } | 2809 | } |
2975 | 2810 | ||
2976 | static void ironlake_crtc_dpms(struct drm_crtc *crtc, int mode) | 2811 | static void ironlake_crtc_dpms(struct drm_crtc *crtc, int mode) |
@@ -4516,34 +4351,28 @@ static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv) | |||
4516 | return dev_priv->lvds_use_ssc && i915_panel_use_ssc; | 4351 | return dev_priv->lvds_use_ssc && i915_panel_use_ssc; |
4517 | } | 4352 | } |
4518 | 4353 | ||
4519 | static int intel_crtc_mode_set(struct drm_crtc *crtc, | 4354 | static int i9xx_crtc_mode_set(struct drm_crtc *crtc, |
4520 | struct drm_display_mode *mode, | 4355 | struct drm_display_mode *mode, |
4521 | struct drm_display_mode *adjusted_mode, | 4356 | struct drm_display_mode *adjusted_mode, |
4522 | int x, int y, | 4357 | int x, int y, |
4523 | struct drm_framebuffer *old_fb) | 4358 | struct drm_framebuffer *old_fb) |
4524 | { | 4359 | { |
4525 | struct drm_device *dev = crtc->dev; | 4360 | struct drm_device *dev = crtc->dev; |
4526 | struct drm_i915_private *dev_priv = dev->dev_private; | 4361 | struct drm_i915_private *dev_priv = dev->dev_private; |
4527 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 4362 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4528 | int pipe = intel_crtc->pipe; | 4363 | int pipe = intel_crtc->pipe; |
4529 | int plane = intel_crtc->plane; | 4364 | int plane = intel_crtc->plane; |
4530 | u32 fp_reg, dpll_reg; | ||
4531 | int refclk, num_connectors = 0; | 4365 | int refclk, num_connectors = 0; |
4532 | intel_clock_t clock, reduced_clock; | 4366 | intel_clock_t clock, reduced_clock; |
4533 | u32 dpll, fp = 0, fp2 = 0, dspcntr, pipeconf; | 4367 | u32 dpll, fp = 0, fp2 = 0, dspcntr, pipeconf; |
4534 | bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; | 4368 | bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; |
4535 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; | 4369 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; |
4536 | struct intel_encoder *has_edp_encoder = NULL; | ||
4537 | struct drm_mode_config *mode_config = &dev->mode_config; | 4370 | struct drm_mode_config *mode_config = &dev->mode_config; |
4538 | struct intel_encoder *encoder; | 4371 | struct intel_encoder *encoder; |
4539 | const intel_limit_t *limit; | 4372 | const intel_limit_t *limit; |
4540 | int ret; | 4373 | int ret; |
4541 | struct fdi_m_n m_n = {0}; | 4374 | u32 temp; |
4542 | u32 reg, temp; | ||
4543 | u32 lvds_sync = 0; | 4375 | u32 lvds_sync = 0; |
4544 | int target_clock; | ||
4545 | |||
4546 | drm_vblank_pre_modeset(dev, pipe); | ||
4547 | 4376 | ||
4548 | list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { | 4377 | list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { |
4549 | if (encoder->base.crtc != crtc) | 4378 | if (encoder->base.crtc != crtc) |
@@ -4571,9 +4400,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4571 | case INTEL_OUTPUT_DISPLAYPORT: | 4400 | case INTEL_OUTPUT_DISPLAYPORT: |
4572 | is_dp = true; | 4401 | is_dp = true; |
4573 | break; | 4402 | break; |
4574 | case INTEL_OUTPUT_EDP: | ||
4575 | has_edp_encoder = encoder; | ||
4576 | break; | ||
4577 | } | 4403 | } |
4578 | 4404 | ||
4579 | num_connectors++; | 4405 | num_connectors++; |
@@ -4585,9 +4411,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4585 | refclk / 1000); | 4411 | refclk / 1000); |
4586 | } else if (!IS_GEN2(dev)) { | 4412 | } else if (!IS_GEN2(dev)) { |
4587 | refclk = 96000; | 4413 | refclk = 96000; |
4588 | if (HAS_PCH_SPLIT(dev) && | ||
4589 | (!has_edp_encoder || intel_encoder_is_pch_edp(&has_edp_encoder->base))) | ||
4590 | refclk = 120000; /* 120Mhz refclk */ | ||
4591 | } else { | 4414 | } else { |
4592 | refclk = 48000; | 4415 | refclk = 48000; |
4593 | } | 4416 | } |
@@ -4601,7 +4424,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4601 | ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk, &clock); | 4424 | ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk, &clock); |
4602 | if (!ok) { | 4425 | if (!ok) { |
4603 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); | 4426 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); |
4604 | drm_vblank_post_modeset(dev, pipe); | ||
4605 | return -EINVAL; | 4427 | return -EINVAL; |
4606 | } | 4428 | } |
4607 | 4429 | ||
@@ -4645,143 +4467,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4645 | } | 4467 | } |
4646 | } | 4468 | } |
4647 | 4469 | ||
4648 | /* FDI link */ | ||
4649 | if (HAS_PCH_SPLIT(dev)) { | ||
4650 | int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); | ||
4651 | int lane = 0, link_bw, bpp; | ||
4652 | /* CPU eDP doesn't require FDI link, so just set DP M/N | ||
4653 | according to current link config */ | ||
4654 | if (has_edp_encoder && !intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | ||
4655 | target_clock = mode->clock; | ||
4656 | intel_edp_link_config(has_edp_encoder, | ||
4657 | &lane, &link_bw); | ||
4658 | } else { | ||
4659 | /* [e]DP over FDI requires target mode clock | ||
4660 | instead of link clock */ | ||
4661 | if (is_dp || intel_encoder_is_pch_edp(&has_edp_encoder->base)) | ||
4662 | target_clock = mode->clock; | ||
4663 | else | ||
4664 | target_clock = adjusted_mode->clock; | ||
4665 | |||
4666 | /* FDI is a binary signal running at ~2.7GHz, encoding | ||
4667 | * each output octet as 10 bits. The actual frequency | ||
4668 | * is stored as a divider into a 100MHz clock, and the | ||
4669 | * mode pixel clock is stored in units of 1KHz. | ||
4670 | * Hence the bw of each lane in terms of the mode signal | ||
4671 | * is: | ||
4672 | */ | ||
4673 | link_bw = intel_fdi_link_freq(dev) * MHz(100)/KHz(1)/10; | ||
4674 | } | ||
4675 | |||
4676 | /* determine panel color depth */ | ||
4677 | temp = I915_READ(PIPECONF(pipe)); | ||
4678 | temp &= ~PIPE_BPC_MASK; | ||
4679 | if (is_lvds) { | ||
4680 | /* the BPC will be 6 if it is 18-bit LVDS panel */ | ||
4681 | if ((I915_READ(PCH_LVDS) & LVDS_A3_POWER_MASK) == LVDS_A3_POWER_UP) | ||
4682 | temp |= PIPE_8BPC; | ||
4683 | else | ||
4684 | temp |= PIPE_6BPC; | ||
4685 | } else if (has_edp_encoder) { | ||
4686 | switch (dev_priv->edp.bpp/3) { | ||
4687 | case 8: | ||
4688 | temp |= PIPE_8BPC; | ||
4689 | break; | ||
4690 | case 10: | ||
4691 | temp |= PIPE_10BPC; | ||
4692 | break; | ||
4693 | case 6: | ||
4694 | temp |= PIPE_6BPC; | ||
4695 | break; | ||
4696 | case 12: | ||
4697 | temp |= PIPE_12BPC; | ||
4698 | break; | ||
4699 | } | ||
4700 | } else | ||
4701 | temp |= PIPE_8BPC; | ||
4702 | I915_WRITE(PIPECONF(pipe), temp); | ||
4703 | |||
4704 | switch (temp & PIPE_BPC_MASK) { | ||
4705 | case PIPE_8BPC: | ||
4706 | bpp = 24; | ||
4707 | break; | ||
4708 | case PIPE_10BPC: | ||
4709 | bpp = 30; | ||
4710 | break; | ||
4711 | case PIPE_6BPC: | ||
4712 | bpp = 18; | ||
4713 | break; | ||
4714 | case PIPE_12BPC: | ||
4715 | bpp = 36; | ||
4716 | break; | ||
4717 | default: | ||
4718 | DRM_ERROR("unknown pipe bpc value\n"); | ||
4719 | bpp = 24; | ||
4720 | } | ||
4721 | |||
4722 | if (!lane) { | ||
4723 | /* | ||
4724 | * Account for spread spectrum to avoid | ||
4725 | * oversubscribing the link. Max center spread | ||
4726 | * is 2.5%; use 5% for safety's sake. | ||
4727 | */ | ||
4728 | u32 bps = target_clock * bpp * 21 / 20; | ||
4729 | lane = bps / (link_bw * 8) + 1; | ||
4730 | } | ||
4731 | |||
4732 | intel_crtc->fdi_lanes = lane; | ||
4733 | |||
4734 | if (pixel_multiplier > 1) | ||
4735 | link_bw *= pixel_multiplier; | ||
4736 | ironlake_compute_m_n(bpp, lane, target_clock, link_bw, &m_n); | ||
4737 | } | ||
4738 | |||
4739 | /* Ironlake: try to setup display ref clock before DPLL | ||
4740 | * enabling. This is only under driver's control after | ||
4741 | * PCH B stepping, previous chipset stepping should be | ||
4742 | * ignoring this setting. | ||
4743 | */ | ||
4744 | if (HAS_PCH_SPLIT(dev)) { | ||
4745 | temp = I915_READ(PCH_DREF_CONTROL); | ||
4746 | /* Always enable nonspread source */ | ||
4747 | temp &= ~DREF_NONSPREAD_SOURCE_MASK; | ||
4748 | temp |= DREF_NONSPREAD_SOURCE_ENABLE; | ||
4749 | temp &= ~DREF_SSC_SOURCE_MASK; | ||
4750 | temp |= DREF_SSC_SOURCE_ENABLE; | ||
4751 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
4752 | |||
4753 | POSTING_READ(PCH_DREF_CONTROL); | ||
4754 | udelay(200); | ||
4755 | |||
4756 | if (has_edp_encoder) { | ||
4757 | if (intel_panel_use_ssc(dev_priv)) { | ||
4758 | temp |= DREF_SSC1_ENABLE; | ||
4759 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
4760 | |||
4761 | POSTING_READ(PCH_DREF_CONTROL); | ||
4762 | udelay(200); | ||
4763 | } | ||
4764 | temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK; | ||
4765 | |||
4766 | /* Enable CPU source on CPU attached eDP */ | ||
4767 | if (!intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | ||
4768 | if (intel_panel_use_ssc(dev_priv)) | ||
4769 | temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD; | ||
4770 | else | ||
4771 | temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD; | ||
4772 | } else { | ||
4773 | /* Enable SSC on PCH eDP if needed */ | ||
4774 | if (intel_panel_use_ssc(dev_priv)) { | ||
4775 | DRM_ERROR("enabling SSC on PCH\n"); | ||
4776 | temp |= DREF_SUPERSPREAD_SOURCE_ENABLE; | ||
4777 | } | ||
4778 | } | ||
4779 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
4780 | POSTING_READ(PCH_DREF_CONTROL); | ||
4781 | udelay(200); | ||
4782 | } | ||
4783 | } | ||
4784 | |||
4785 | if (IS_PINEVIEW(dev)) { | 4470 | if (IS_PINEVIEW(dev)) { |
4786 | fp = (1 << clock.n) << 16 | clock.m1 << 8 | clock.m2; | 4471 | fp = (1 << clock.n) << 16 | clock.m1 << 8 | clock.m2; |
4787 | if (has_reduced_clock) | 4472 | if (has_reduced_clock) |
@@ -4794,25 +4479,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4794 | reduced_clock.m2; | 4479 | reduced_clock.m2; |
4795 | } | 4480 | } |
4796 | 4481 | ||
4797 | /* Enable autotuning of the PLL clock (if permissible) */ | 4482 | dpll = DPLL_VGA_MODE_DIS; |
4798 | if (HAS_PCH_SPLIT(dev)) { | ||
4799 | int factor = 21; | ||
4800 | |||
4801 | if (is_lvds) { | ||
4802 | if ((intel_panel_use_ssc(dev_priv) && | ||
4803 | dev_priv->lvds_ssc_freq == 100) || | ||
4804 | (I915_READ(PCH_LVDS) & LVDS_CLKB_POWER_MASK) == LVDS_CLKB_POWER_UP) | ||
4805 | factor = 25; | ||
4806 | } else if (is_sdvo && is_tv) | ||
4807 | factor = 20; | ||
4808 | |||
4809 | if (clock.m1 < factor * clock.n) | ||
4810 | fp |= FP_CB_TUNE; | ||
4811 | } | ||
4812 | |||
4813 | dpll = 0; | ||
4814 | if (!HAS_PCH_SPLIT(dev)) | ||
4815 | dpll = DPLL_VGA_MODE_DIS; | ||
4816 | 4483 | ||
4817 | if (!IS_GEN2(dev)) { | 4484 | if (!IS_GEN2(dev)) { |
4818 | if (is_lvds) | 4485 | if (is_lvds) |
@@ -4824,12 +4491,10 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4824 | if (pixel_multiplier > 1) { | 4491 | if (pixel_multiplier > 1) { |
4825 | if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) | 4492 | if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) |
4826 | dpll |= (pixel_multiplier - 1) << SDVO_MULTIPLIER_SHIFT_HIRES; | 4493 | dpll |= (pixel_multiplier - 1) << SDVO_MULTIPLIER_SHIFT_HIRES; |
4827 | else if (HAS_PCH_SPLIT(dev)) | ||
4828 | dpll |= (pixel_multiplier - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; | ||
4829 | } | 4494 | } |
4830 | dpll |= DPLL_DVO_HIGH_SPEED; | 4495 | dpll |= DPLL_DVO_HIGH_SPEED; |
4831 | } | 4496 | } |
4832 | if (is_dp || intel_encoder_is_pch_edp(&has_edp_encoder->base)) | 4497 | if (is_dp) |
4833 | dpll |= DPLL_DVO_HIGH_SPEED; | 4498 | dpll |= DPLL_DVO_HIGH_SPEED; |
4834 | 4499 | ||
4835 | /* compute bitmask from p1 value */ | 4500 | /* compute bitmask from p1 value */ |
@@ -4837,9 +4502,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4837 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT_PINEVIEW; | 4502 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT_PINEVIEW; |
4838 | else { | 4503 | else { |
4839 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; | 4504 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
4840 | /* also FPA1 */ | ||
4841 | if (HAS_PCH_SPLIT(dev)) | ||
4842 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; | ||
4843 | if (IS_G4X(dev) && has_reduced_clock) | 4505 | if (IS_G4X(dev) && has_reduced_clock) |
4844 | dpll |= (1 << (reduced_clock.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; | 4506 | dpll |= (1 << (reduced_clock.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; |
4845 | } | 4507 | } |
@@ -4857,7 +4519,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4857 | dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14; | 4519 | dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14; |
4858 | break; | 4520 | break; |
4859 | } | 4521 | } |
4860 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) | 4522 | if (INTEL_INFO(dev)->gen >= 4) |
4861 | dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT); | 4523 | dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT); |
4862 | } else { | 4524 | } else { |
4863 | if (is_lvds) { | 4525 | if (is_lvds) { |
@@ -4891,12 +4553,10 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4891 | 4553 | ||
4892 | /* Ironlake's plane is forced to pipe, bit 24 is to | 4554 | /* Ironlake's plane is forced to pipe, bit 24 is to |
4893 | enable color space conversion */ | 4555 | enable color space conversion */ |
4894 | if (!HAS_PCH_SPLIT(dev)) { | 4556 | if (pipe == 0) |
4895 | if (pipe == 0) | 4557 | dspcntr &= ~DISPPLANE_SEL_PIPE_MASK; |
4896 | dspcntr &= ~DISPPLANE_SEL_PIPE_MASK; | 4558 | else |
4897 | else | 4559 | dspcntr |= DISPPLANE_SEL_PIPE_B; |
4898 | dspcntr |= DISPPLANE_SEL_PIPE_B; | ||
4899 | } | ||
4900 | 4560 | ||
4901 | if (pipe == 0 && INTEL_INFO(dev)->gen < 4) { | 4561 | if (pipe == 0 && INTEL_INFO(dev)->gen < 4) { |
4902 | /* Enable pixel doubling when the dot clock is > 90% of the (display) | 4562 | /* Enable pixel doubling when the dot clock is > 90% of the (display) |
@@ -4912,27 +4572,506 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4912 | pipeconf &= ~PIPECONF_DOUBLE_WIDE; | 4572 | pipeconf &= ~PIPECONF_DOUBLE_WIDE; |
4913 | } | 4573 | } |
4914 | 4574 | ||
4915 | if (!HAS_PCH_SPLIT(dev)) | 4575 | dpll |= DPLL_VCO_ENABLE; |
4916 | dpll |= DPLL_VCO_ENABLE; | ||
4917 | 4576 | ||
4918 | DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); | 4577 | DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); |
4919 | drm_mode_debug_printmodeline(mode); | 4578 | drm_mode_debug_printmodeline(mode); |
4920 | 4579 | ||
4921 | /* assign to Ironlake registers */ | 4580 | I915_WRITE(FP0(pipe), fp); |
4922 | if (HAS_PCH_SPLIT(dev)) { | 4581 | I915_WRITE(DPLL(pipe), dpll & ~DPLL_VCO_ENABLE); |
4923 | fp_reg = PCH_FP0(pipe); | 4582 | |
4924 | dpll_reg = PCH_DPLL(pipe); | 4583 | POSTING_READ(DPLL(pipe)); |
4584 | udelay(150); | ||
4585 | |||
4586 | /* The LVDS pin pair needs to be on before the DPLLs are enabled. | ||
4587 | * This is an exception to the general rule that mode_set doesn't turn | ||
4588 | * things on. | ||
4589 | */ | ||
4590 | if (is_lvds) { | ||
4591 | temp = I915_READ(LVDS); | ||
4592 | temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP; | ||
4593 | if (pipe == 1) { | ||
4594 | temp |= LVDS_PIPEB_SELECT; | ||
4595 | } else { | ||
4596 | temp &= ~LVDS_PIPEB_SELECT; | ||
4597 | } | ||
4598 | /* set the corresponsding LVDS_BORDER bit */ | ||
4599 | temp |= dev_priv->lvds_border_bits; | ||
4600 | /* Set the B0-B3 data pairs corresponding to whether we're going to | ||
4601 | * set the DPLLs for dual-channel mode or not. | ||
4602 | */ | ||
4603 | if (clock.p2 == 7) | ||
4604 | temp |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP; | ||
4605 | else | ||
4606 | temp &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP); | ||
4607 | |||
4608 | /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP) | ||
4609 | * appropriately here, but we need to look more thoroughly into how | ||
4610 | * panels behave in the two modes. | ||
4611 | */ | ||
4612 | /* set the dithering flag on LVDS as needed */ | ||
4613 | if (INTEL_INFO(dev)->gen >= 4) { | ||
4614 | if (dev_priv->lvds_dither) | ||
4615 | temp |= LVDS_ENABLE_DITHER; | ||
4616 | else | ||
4617 | temp &= ~LVDS_ENABLE_DITHER; | ||
4618 | } | ||
4619 | if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) | ||
4620 | lvds_sync |= LVDS_HSYNC_POLARITY; | ||
4621 | if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC) | ||
4622 | lvds_sync |= LVDS_VSYNC_POLARITY; | ||
4623 | if ((temp & (LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY)) | ||
4624 | != lvds_sync) { | ||
4625 | char flags[2] = "-+"; | ||
4626 | DRM_INFO("Changing LVDS panel from " | ||
4627 | "(%chsync, %cvsync) to (%chsync, %cvsync)\n", | ||
4628 | flags[!(temp & LVDS_HSYNC_POLARITY)], | ||
4629 | flags[!(temp & LVDS_VSYNC_POLARITY)], | ||
4630 | flags[!(lvds_sync & LVDS_HSYNC_POLARITY)], | ||
4631 | flags[!(lvds_sync & LVDS_VSYNC_POLARITY)]); | ||
4632 | temp &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY); | ||
4633 | temp |= lvds_sync; | ||
4634 | } | ||
4635 | I915_WRITE(LVDS, temp); | ||
4636 | } | ||
4637 | |||
4638 | if (is_dp) { | ||
4639 | intel_dp_set_m_n(crtc, mode, adjusted_mode); | ||
4640 | } | ||
4641 | |||
4642 | I915_WRITE(DPLL(pipe), dpll); | ||
4643 | |||
4644 | /* Wait for the clocks to stabilize. */ | ||
4645 | POSTING_READ(DPLL(pipe)); | ||
4646 | udelay(150); | ||
4647 | |||
4648 | if (INTEL_INFO(dev)->gen >= 4) { | ||
4649 | temp = 0; | ||
4650 | if (is_sdvo) { | ||
4651 | temp = intel_mode_get_pixel_multiplier(adjusted_mode); | ||
4652 | if (temp > 1) | ||
4653 | temp = (temp - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT; | ||
4654 | else | ||
4655 | temp = 0; | ||
4656 | } | ||
4657 | I915_WRITE(DPLL_MD(pipe), temp); | ||
4925 | } else { | 4658 | } else { |
4926 | fp_reg = FP0(pipe); | 4659 | /* The pixel multiplier can only be updated once the |
4927 | dpll_reg = DPLL(pipe); | 4660 | * DPLL is enabled and the clocks are stable. |
4661 | * | ||
4662 | * So write it again. | ||
4663 | */ | ||
4664 | I915_WRITE(DPLL(pipe), dpll); | ||
4665 | } | ||
4666 | |||
4667 | intel_crtc->lowfreq_avail = false; | ||
4668 | if (is_lvds && has_reduced_clock && i915_powersave) { | ||
4669 | I915_WRITE(FP1(pipe), fp2); | ||
4670 | intel_crtc->lowfreq_avail = true; | ||
4671 | if (HAS_PIPE_CXSR(dev)) { | ||
4672 | DRM_DEBUG_KMS("enabling CxSR downclocking\n"); | ||
4673 | pipeconf |= PIPECONF_CXSR_DOWNCLOCK; | ||
4674 | } | ||
4675 | } else { | ||
4676 | I915_WRITE(FP1(pipe), fp); | ||
4677 | if (HAS_PIPE_CXSR(dev)) { | ||
4678 | DRM_DEBUG_KMS("disabling CxSR downclocking\n"); | ||
4679 | pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK; | ||
4680 | } | ||
4928 | } | 4681 | } |
4929 | 4682 | ||
4683 | if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) { | ||
4684 | pipeconf |= PIPECONF_INTERLACE_W_FIELD_INDICATION; | ||
4685 | /* the chip adds 2 halflines automatically */ | ||
4686 | adjusted_mode->crtc_vdisplay -= 1; | ||
4687 | adjusted_mode->crtc_vtotal -= 1; | ||
4688 | adjusted_mode->crtc_vblank_start -= 1; | ||
4689 | adjusted_mode->crtc_vblank_end -= 1; | ||
4690 | adjusted_mode->crtc_vsync_end -= 1; | ||
4691 | adjusted_mode->crtc_vsync_start -= 1; | ||
4692 | } else | ||
4693 | pipeconf &= ~PIPECONF_INTERLACE_W_FIELD_INDICATION; /* progressive */ | ||
4694 | |||
4695 | I915_WRITE(HTOTAL(pipe), | ||
4696 | (adjusted_mode->crtc_hdisplay - 1) | | ||
4697 | ((adjusted_mode->crtc_htotal - 1) << 16)); | ||
4698 | I915_WRITE(HBLANK(pipe), | ||
4699 | (adjusted_mode->crtc_hblank_start - 1) | | ||
4700 | ((adjusted_mode->crtc_hblank_end - 1) << 16)); | ||
4701 | I915_WRITE(HSYNC(pipe), | ||
4702 | (adjusted_mode->crtc_hsync_start - 1) | | ||
4703 | ((adjusted_mode->crtc_hsync_end - 1) << 16)); | ||
4704 | |||
4705 | I915_WRITE(VTOTAL(pipe), | ||
4706 | (adjusted_mode->crtc_vdisplay - 1) | | ||
4707 | ((adjusted_mode->crtc_vtotal - 1) << 16)); | ||
4708 | I915_WRITE(VBLANK(pipe), | ||
4709 | (adjusted_mode->crtc_vblank_start - 1) | | ||
4710 | ((adjusted_mode->crtc_vblank_end - 1) << 16)); | ||
4711 | I915_WRITE(VSYNC(pipe), | ||
4712 | (adjusted_mode->crtc_vsync_start - 1) | | ||
4713 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); | ||
4714 | |||
4715 | /* pipesrc and dspsize control the size that is scaled from, | ||
4716 | * which should always be the user's requested size. | ||
4717 | */ | ||
4718 | I915_WRITE(DSPSIZE(plane), | ||
4719 | ((mode->vdisplay - 1) << 16) | | ||
4720 | (mode->hdisplay - 1)); | ||
4721 | I915_WRITE(DSPPOS(plane), 0); | ||
4722 | I915_WRITE(PIPESRC(pipe), | ||
4723 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | ||
4724 | |||
4725 | I915_WRITE(PIPECONF(pipe), pipeconf); | ||
4726 | POSTING_READ(PIPECONF(pipe)); | ||
4727 | intel_enable_pipe(dev_priv, pipe, false); | ||
4728 | |||
4729 | intel_wait_for_vblank(dev, pipe); | ||
4730 | |||
4731 | I915_WRITE(DSPCNTR(plane), dspcntr); | ||
4732 | POSTING_READ(DSPCNTR(plane)); | ||
4733 | |||
4734 | ret = intel_pipe_set_base(crtc, x, y, old_fb); | ||
4735 | |||
4736 | intel_update_watermarks(dev); | ||
4737 | |||
4738 | return ret; | ||
4739 | } | ||
4740 | |||
4741 | static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | ||
4742 | struct drm_display_mode *mode, | ||
4743 | struct drm_display_mode *adjusted_mode, | ||
4744 | int x, int y, | ||
4745 | struct drm_framebuffer *old_fb) | ||
4746 | { | ||
4747 | struct drm_device *dev = crtc->dev; | ||
4748 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
4749 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
4750 | int pipe = intel_crtc->pipe; | ||
4751 | int plane = intel_crtc->plane; | ||
4752 | int refclk, num_connectors = 0; | ||
4753 | intel_clock_t clock, reduced_clock; | ||
4754 | u32 dpll, fp = 0, fp2 = 0, dspcntr, pipeconf; | ||
4755 | bool ok, has_reduced_clock = false, is_sdvo = false; | ||
4756 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; | ||
4757 | struct intel_encoder *has_edp_encoder = NULL; | ||
4758 | struct drm_mode_config *mode_config = &dev->mode_config; | ||
4759 | struct intel_encoder *encoder; | ||
4760 | const intel_limit_t *limit; | ||
4761 | int ret; | ||
4762 | struct fdi_m_n m_n = {0}; | ||
4763 | u32 temp; | ||
4764 | u32 lvds_sync = 0; | ||
4765 | int target_clock, pixel_multiplier, lane, link_bw, bpp, factor; | ||
4766 | |||
4767 | list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { | ||
4768 | if (encoder->base.crtc != crtc) | ||
4769 | continue; | ||
4770 | |||
4771 | switch (encoder->type) { | ||
4772 | case INTEL_OUTPUT_LVDS: | ||
4773 | is_lvds = true; | ||
4774 | break; | ||
4775 | case INTEL_OUTPUT_SDVO: | ||
4776 | case INTEL_OUTPUT_HDMI: | ||
4777 | is_sdvo = true; | ||
4778 | if (encoder->needs_tv_clock) | ||
4779 | is_tv = true; | ||
4780 | break; | ||
4781 | case INTEL_OUTPUT_TVOUT: | ||
4782 | is_tv = true; | ||
4783 | break; | ||
4784 | case INTEL_OUTPUT_ANALOG: | ||
4785 | is_crt = true; | ||
4786 | break; | ||
4787 | case INTEL_OUTPUT_DISPLAYPORT: | ||
4788 | is_dp = true; | ||
4789 | break; | ||
4790 | case INTEL_OUTPUT_EDP: | ||
4791 | has_edp_encoder = encoder; | ||
4792 | break; | ||
4793 | } | ||
4794 | |||
4795 | num_connectors++; | ||
4796 | } | ||
4797 | |||
4798 | if (is_lvds && intel_panel_use_ssc(dev_priv) && num_connectors < 2) { | ||
4799 | refclk = dev_priv->lvds_ssc_freq * 1000; | ||
4800 | DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n", | ||
4801 | refclk / 1000); | ||
4802 | } else { | ||
4803 | refclk = 96000; | ||
4804 | if (!has_edp_encoder || | ||
4805 | intel_encoder_is_pch_edp(&has_edp_encoder->base)) | ||
4806 | refclk = 120000; /* 120Mhz refclk */ | ||
4807 | } | ||
4808 | |||
4809 | /* | ||
4810 | * Returns a set of divisors for the desired target clock with the given | ||
4811 | * refclk, or FALSE. The returned values represent the clock equation: | ||
4812 | * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2. | ||
4813 | */ | ||
4814 | limit = intel_limit(crtc, refclk); | ||
4815 | ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk, &clock); | ||
4816 | if (!ok) { | ||
4817 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); | ||
4818 | return -EINVAL; | ||
4819 | } | ||
4820 | |||
4821 | /* Ensure that the cursor is valid for the new mode before changing... */ | ||
4822 | intel_crtc_update_cursor(crtc, true); | ||
4823 | |||
4824 | if (is_lvds && dev_priv->lvds_downclock_avail) { | ||
4825 | has_reduced_clock = limit->find_pll(limit, crtc, | ||
4826 | dev_priv->lvds_downclock, | ||
4827 | refclk, | ||
4828 | &reduced_clock); | ||
4829 | if (has_reduced_clock && (clock.p != reduced_clock.p)) { | ||
4830 | /* | ||
4831 | * If the different P is found, it means that we can't | ||
4832 | * switch the display clock by using the FP0/FP1. | ||
4833 | * In such case we will disable the LVDS downclock | ||
4834 | * feature. | ||
4835 | */ | ||
4836 | DRM_DEBUG_KMS("Different P is found for " | ||
4837 | "LVDS clock/downclock\n"); | ||
4838 | has_reduced_clock = 0; | ||
4839 | } | ||
4840 | } | ||
4841 | /* SDVO TV has fixed PLL values depend on its clock range, | ||
4842 | this mirrors vbios setting. */ | ||
4843 | if (is_sdvo && is_tv) { | ||
4844 | if (adjusted_mode->clock >= 100000 | ||
4845 | && adjusted_mode->clock < 140500) { | ||
4846 | clock.p1 = 2; | ||
4847 | clock.p2 = 10; | ||
4848 | clock.n = 3; | ||
4849 | clock.m1 = 16; | ||
4850 | clock.m2 = 8; | ||
4851 | } else if (adjusted_mode->clock >= 140500 | ||
4852 | && adjusted_mode->clock <= 200000) { | ||
4853 | clock.p1 = 1; | ||
4854 | clock.p2 = 10; | ||
4855 | clock.n = 6; | ||
4856 | clock.m1 = 12; | ||
4857 | clock.m2 = 8; | ||
4858 | } | ||
4859 | } | ||
4860 | |||
4861 | /* FDI link */ | ||
4862 | pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); | ||
4863 | lane = 0; | ||
4864 | /* CPU eDP doesn't require FDI link, so just set DP M/N | ||
4865 | according to current link config */ | ||
4866 | if (has_edp_encoder && | ||
4867 | !intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | ||
4868 | target_clock = mode->clock; | ||
4869 | intel_edp_link_config(has_edp_encoder, | ||
4870 | &lane, &link_bw); | ||
4871 | } else { | ||
4872 | /* [e]DP over FDI requires target mode clock | ||
4873 | instead of link clock */ | ||
4874 | if (is_dp || intel_encoder_is_pch_edp(&has_edp_encoder->base)) | ||
4875 | target_clock = mode->clock; | ||
4876 | else | ||
4877 | target_clock = adjusted_mode->clock; | ||
4878 | |||
4879 | /* FDI is a binary signal running at ~2.7GHz, encoding | ||
4880 | * each output octet as 10 bits. The actual frequency | ||
4881 | * is stored as a divider into a 100MHz clock, and the | ||
4882 | * mode pixel clock is stored in units of 1KHz. | ||
4883 | * Hence the bw of each lane in terms of the mode signal | ||
4884 | * is: | ||
4885 | */ | ||
4886 | link_bw = intel_fdi_link_freq(dev) * MHz(100)/KHz(1)/10; | ||
4887 | } | ||
4888 | |||
4889 | /* determine panel color depth */ | ||
4890 | temp = I915_READ(PIPECONF(pipe)); | ||
4891 | temp &= ~PIPE_BPC_MASK; | ||
4892 | if (is_lvds) { | ||
4893 | /* the BPC will be 6 if it is 18-bit LVDS panel */ | ||
4894 | if ((I915_READ(PCH_LVDS) & LVDS_A3_POWER_MASK) == LVDS_A3_POWER_UP) | ||
4895 | temp |= PIPE_8BPC; | ||
4896 | else | ||
4897 | temp |= PIPE_6BPC; | ||
4898 | } else if (has_edp_encoder) { | ||
4899 | switch (dev_priv->edp.bpp/3) { | ||
4900 | case 8: | ||
4901 | temp |= PIPE_8BPC; | ||
4902 | break; | ||
4903 | case 10: | ||
4904 | temp |= PIPE_10BPC; | ||
4905 | break; | ||
4906 | case 6: | ||
4907 | temp |= PIPE_6BPC; | ||
4908 | break; | ||
4909 | case 12: | ||
4910 | temp |= PIPE_12BPC; | ||
4911 | break; | ||
4912 | } | ||
4913 | } else | ||
4914 | temp |= PIPE_8BPC; | ||
4915 | I915_WRITE(PIPECONF(pipe), temp); | ||
4916 | |||
4917 | switch (temp & PIPE_BPC_MASK) { | ||
4918 | case PIPE_8BPC: | ||
4919 | bpp = 24; | ||
4920 | break; | ||
4921 | case PIPE_10BPC: | ||
4922 | bpp = 30; | ||
4923 | break; | ||
4924 | case PIPE_6BPC: | ||
4925 | bpp = 18; | ||
4926 | break; | ||
4927 | case PIPE_12BPC: | ||
4928 | bpp = 36; | ||
4929 | break; | ||
4930 | default: | ||
4931 | DRM_ERROR("unknown pipe bpc value\n"); | ||
4932 | bpp = 24; | ||
4933 | } | ||
4934 | |||
4935 | if (!lane) { | ||
4936 | /* | ||
4937 | * Account for spread spectrum to avoid | ||
4938 | * oversubscribing the link. Max center spread | ||
4939 | * is 2.5%; use 5% for safety's sake. | ||
4940 | */ | ||
4941 | u32 bps = target_clock * bpp * 21 / 20; | ||
4942 | lane = bps / (link_bw * 8) + 1; | ||
4943 | } | ||
4944 | |||
4945 | intel_crtc->fdi_lanes = lane; | ||
4946 | |||
4947 | if (pixel_multiplier > 1) | ||
4948 | link_bw *= pixel_multiplier; | ||
4949 | ironlake_compute_m_n(bpp, lane, target_clock, link_bw, &m_n); | ||
4950 | |||
4951 | /* Ironlake: try to setup display ref clock before DPLL | ||
4952 | * enabling. This is only under driver's control after | ||
4953 | * PCH B stepping, previous chipset stepping should be | ||
4954 | * ignoring this setting. | ||
4955 | */ | ||
4956 | temp = I915_READ(PCH_DREF_CONTROL); | ||
4957 | /* Always enable nonspread source */ | ||
4958 | temp &= ~DREF_NONSPREAD_SOURCE_MASK; | ||
4959 | temp |= DREF_NONSPREAD_SOURCE_ENABLE; | ||
4960 | temp &= ~DREF_SSC_SOURCE_MASK; | ||
4961 | temp |= DREF_SSC_SOURCE_ENABLE; | ||
4962 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
4963 | |||
4964 | POSTING_READ(PCH_DREF_CONTROL); | ||
4965 | udelay(200); | ||
4966 | |||
4967 | if (has_edp_encoder) { | ||
4968 | if (intel_panel_use_ssc(dev_priv)) { | ||
4969 | temp |= DREF_SSC1_ENABLE; | ||
4970 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
4971 | |||
4972 | POSTING_READ(PCH_DREF_CONTROL); | ||
4973 | udelay(200); | ||
4974 | } | ||
4975 | temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK; | ||
4976 | |||
4977 | /* Enable CPU source on CPU attached eDP */ | ||
4978 | if (!intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | ||
4979 | if (intel_panel_use_ssc(dev_priv)) | ||
4980 | temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD; | ||
4981 | else | ||
4982 | temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD; | ||
4983 | } else { | ||
4984 | /* Enable SSC on PCH eDP if needed */ | ||
4985 | if (intel_panel_use_ssc(dev_priv)) { | ||
4986 | DRM_ERROR("enabling SSC on PCH\n"); | ||
4987 | temp |= DREF_SUPERSPREAD_SOURCE_ENABLE; | ||
4988 | } | ||
4989 | } | ||
4990 | I915_WRITE(PCH_DREF_CONTROL, temp); | ||
4991 | POSTING_READ(PCH_DREF_CONTROL); | ||
4992 | udelay(200); | ||
4993 | } | ||
4994 | |||
4995 | fp = clock.n << 16 | clock.m1 << 8 | clock.m2; | ||
4996 | if (has_reduced_clock) | ||
4997 | fp2 = reduced_clock.n << 16 | reduced_clock.m1 << 8 | | ||
4998 | reduced_clock.m2; | ||
4999 | |||
5000 | /* Enable autotuning of the PLL clock (if permissible) */ | ||
5001 | factor = 21; | ||
5002 | if (is_lvds) { | ||
5003 | if ((intel_panel_use_ssc(dev_priv) && | ||
5004 | dev_priv->lvds_ssc_freq == 100) || | ||
5005 | (I915_READ(PCH_LVDS) & LVDS_CLKB_POWER_MASK) == LVDS_CLKB_POWER_UP) | ||
5006 | factor = 25; | ||
5007 | } else if (is_sdvo && is_tv) | ||
5008 | factor = 20; | ||
5009 | |||
5010 | if (clock.m1 < factor * clock.n) | ||
5011 | fp |= FP_CB_TUNE; | ||
5012 | |||
5013 | dpll = 0; | ||
5014 | |||
5015 | if (is_lvds) | ||
5016 | dpll |= DPLLB_MODE_LVDS; | ||
5017 | else | ||
5018 | dpll |= DPLLB_MODE_DAC_SERIAL; | ||
5019 | if (is_sdvo) { | ||
5020 | int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); | ||
5021 | if (pixel_multiplier > 1) { | ||
5022 | dpll |= (pixel_multiplier - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; | ||
5023 | } | ||
5024 | dpll |= DPLL_DVO_HIGH_SPEED; | ||
5025 | } | ||
5026 | if (is_dp || intel_encoder_is_pch_edp(&has_edp_encoder->base)) | ||
5027 | dpll |= DPLL_DVO_HIGH_SPEED; | ||
5028 | |||
5029 | /* compute bitmask from p1 value */ | ||
5030 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; | ||
5031 | /* also FPA1 */ | ||
5032 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; | ||
5033 | |||
5034 | switch (clock.p2) { | ||
5035 | case 5: | ||
5036 | dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5; | ||
5037 | break; | ||
5038 | case 7: | ||
5039 | dpll |= DPLLB_LVDS_P2_CLOCK_DIV_7; | ||
5040 | break; | ||
5041 | case 10: | ||
5042 | dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_10; | ||
5043 | break; | ||
5044 | case 14: | ||
5045 | dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14; | ||
5046 | break; | ||
5047 | } | ||
5048 | |||
5049 | if (is_sdvo && is_tv) | ||
5050 | dpll |= PLL_REF_INPUT_TVCLKINBC; | ||
5051 | else if (is_tv) | ||
5052 | /* XXX: just matching BIOS for now */ | ||
5053 | /* dpll |= PLL_REF_INPUT_TVCLKINBC; */ | ||
5054 | dpll |= 3; | ||
5055 | else if (is_lvds && intel_panel_use_ssc(dev_priv) && num_connectors < 2) | ||
5056 | dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN; | ||
5057 | else | ||
5058 | dpll |= PLL_REF_INPUT_DREFCLK; | ||
5059 | |||
5060 | /* setup pipeconf */ | ||
5061 | pipeconf = I915_READ(PIPECONF(pipe)); | ||
5062 | |||
5063 | /* Set up the display plane register */ | ||
5064 | dspcntr = DISPPLANE_GAMMA_ENABLE; | ||
5065 | |||
5066 | DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); | ||
5067 | drm_mode_debug_printmodeline(mode); | ||
5068 | |||
4930 | /* PCH eDP needs FDI, but CPU eDP does not */ | 5069 | /* PCH eDP needs FDI, but CPU eDP does not */ |
4931 | if (!has_edp_encoder || intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | 5070 | if (!has_edp_encoder || intel_encoder_is_pch_edp(&has_edp_encoder->base)) { |
4932 | I915_WRITE(fp_reg, fp); | 5071 | I915_WRITE(PCH_FP0(pipe), fp); |
4933 | I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE); | 5072 | I915_WRITE(PCH_DPLL(pipe), dpll & ~DPLL_VCO_ENABLE); |
4934 | 5073 | ||
4935 | POSTING_READ(dpll_reg); | 5074 | POSTING_READ(PCH_DPLL(pipe)); |
4936 | udelay(150); | 5075 | udelay(150); |
4937 | } | 5076 | } |
4938 | 5077 | ||
@@ -4964,11 +5103,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4964 | * things on. | 5103 | * things on. |
4965 | */ | 5104 | */ |
4966 | if (is_lvds) { | 5105 | if (is_lvds) { |
4967 | reg = LVDS; | 5106 | temp = I915_READ(PCH_LVDS); |
4968 | if (HAS_PCH_SPLIT(dev)) | ||
4969 | reg = PCH_LVDS; | ||
4970 | |||
4971 | temp = I915_READ(reg); | ||
4972 | temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP; | 5107 | temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP; |
4973 | if (pipe == 1) { | 5108 | if (pipe == 1) { |
4974 | if (HAS_PCH_CPT(dev)) | 5109 | if (HAS_PCH_CPT(dev)) |
@@ -4995,13 +5130,6 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4995 | * appropriately here, but we need to look more thoroughly into how | 5130 | * appropriately here, but we need to look more thoroughly into how |
4996 | * panels behave in the two modes. | 5131 | * panels behave in the two modes. |
4997 | */ | 5132 | */ |
4998 | /* set the dithering flag on non-PCH LVDS as needed */ | ||
4999 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) { | ||
5000 | if (dev_priv->lvds_dither) | ||
5001 | temp |= LVDS_ENABLE_DITHER; | ||
5002 | else | ||
5003 | temp &= ~LVDS_ENABLE_DITHER; | ||
5004 | } | ||
5005 | if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) | 5133 | if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) |
5006 | lvds_sync |= LVDS_HSYNC_POLARITY; | 5134 | lvds_sync |= LVDS_HSYNC_POLARITY; |
5007 | if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC) | 5135 | if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC) |
@@ -5018,22 +5146,20 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
5018 | temp &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY); | 5146 | temp &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY); |
5019 | temp |= lvds_sync; | 5147 | temp |= lvds_sync; |
5020 | } | 5148 | } |
5021 | I915_WRITE(reg, temp); | 5149 | I915_WRITE(PCH_LVDS, temp); |
5022 | } | 5150 | } |
5023 | 5151 | ||
5024 | /* set the dithering flag and clear for anything other than a panel. */ | 5152 | /* set the dithering flag and clear for anything other than a panel. */ |
5025 | if (HAS_PCH_SPLIT(dev)) { | 5153 | pipeconf &= ~PIPECONF_DITHER_EN; |
5026 | pipeconf &= ~PIPECONF_DITHER_EN; | 5154 | pipeconf &= ~PIPECONF_DITHER_TYPE_MASK; |
5027 | pipeconf &= ~PIPECONF_DITHER_TYPE_MASK; | 5155 | if (dev_priv->lvds_dither && (is_lvds || has_edp_encoder)) { |
5028 | if (dev_priv->lvds_dither && (is_lvds || has_edp_encoder)) { | 5156 | pipeconf |= PIPECONF_DITHER_EN; |
5029 | pipeconf |= PIPECONF_DITHER_EN; | 5157 | pipeconf |= PIPECONF_DITHER_TYPE_ST1; |
5030 | pipeconf |= PIPECONF_DITHER_TYPE_ST1; | ||
5031 | } | ||
5032 | } | 5158 | } |
5033 | 5159 | ||
5034 | if (is_dp || intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | 5160 | if (is_dp || intel_encoder_is_pch_edp(&has_edp_encoder->base)) { |
5035 | intel_dp_set_m_n(crtc, mode, adjusted_mode); | 5161 | intel_dp_set_m_n(crtc, mode, adjusted_mode); |
5036 | } else if (HAS_PCH_SPLIT(dev)) { | 5162 | } else { |
5037 | /* For non-DP output, clear any trans DP clock recovery setting.*/ | 5163 | /* For non-DP output, clear any trans DP clock recovery setting.*/ |
5038 | I915_WRITE(TRANSDATA_M1(pipe), 0); | 5164 | I915_WRITE(TRANSDATA_M1(pipe), 0); |
5039 | I915_WRITE(TRANSDATA_N1(pipe), 0); | 5165 | I915_WRITE(TRANSDATA_N1(pipe), 0); |
@@ -5041,43 +5167,32 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
5041 | I915_WRITE(TRANSDPLINK_N1(pipe), 0); | 5167 | I915_WRITE(TRANSDPLINK_N1(pipe), 0); |
5042 | } | 5168 | } |
5043 | 5169 | ||
5044 | if (!has_edp_encoder || intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | 5170 | if (!has_edp_encoder || |
5045 | I915_WRITE(dpll_reg, dpll); | 5171 | intel_encoder_is_pch_edp(&has_edp_encoder->base)) { |
5172 | I915_WRITE(PCH_DPLL(pipe), dpll); | ||
5046 | 5173 | ||
5047 | /* Wait for the clocks to stabilize. */ | 5174 | /* Wait for the clocks to stabilize. */ |
5048 | POSTING_READ(dpll_reg); | 5175 | POSTING_READ(PCH_DPLL(pipe)); |
5049 | udelay(150); | 5176 | udelay(150); |
5050 | 5177 | ||
5051 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) { | 5178 | /* The pixel multiplier can only be updated once the |
5052 | temp = 0; | 5179 | * DPLL is enabled and the clocks are stable. |
5053 | if (is_sdvo) { | 5180 | * |
5054 | temp = intel_mode_get_pixel_multiplier(adjusted_mode); | 5181 | * So write it again. |
5055 | if (temp > 1) | 5182 | */ |
5056 | temp = (temp - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT; | 5183 | I915_WRITE(PCH_DPLL(pipe), dpll); |
5057 | else | ||
5058 | temp = 0; | ||
5059 | } | ||
5060 | I915_WRITE(DPLL_MD(pipe), temp); | ||
5061 | } else { | ||
5062 | /* The pixel multiplier can only be updated once the | ||
5063 | * DPLL is enabled and the clocks are stable. | ||
5064 | * | ||
5065 | * So write it again. | ||
5066 | */ | ||
5067 | I915_WRITE(dpll_reg, dpll); | ||
5068 | } | ||
5069 | } | 5184 | } |
5070 | 5185 | ||
5071 | intel_crtc->lowfreq_avail = false; | 5186 | intel_crtc->lowfreq_avail = false; |
5072 | if (is_lvds && has_reduced_clock && i915_powersave) { | 5187 | if (is_lvds && has_reduced_clock && i915_powersave) { |
5073 | I915_WRITE(fp_reg + 4, fp2); | 5188 | I915_WRITE(PCH_FP1(pipe), fp2); |
5074 | intel_crtc->lowfreq_avail = true; | 5189 | intel_crtc->lowfreq_avail = true; |
5075 | if (HAS_PIPE_CXSR(dev)) { | 5190 | if (HAS_PIPE_CXSR(dev)) { |
5076 | DRM_DEBUG_KMS("enabling CxSR downclocking\n"); | 5191 | DRM_DEBUG_KMS("enabling CxSR downclocking\n"); |
5077 | pipeconf |= PIPECONF_CXSR_DOWNCLOCK; | 5192 | pipeconf |= PIPECONF_CXSR_DOWNCLOCK; |
5078 | } | 5193 | } |
5079 | } else { | 5194 | } else { |
5080 | I915_WRITE(fp_reg + 4, fp); | 5195 | I915_WRITE(PCH_FP1(pipe), fp); |
5081 | if (HAS_PIPE_CXSR(dev)) { | 5196 | if (HAS_PIPE_CXSR(dev)) { |
5082 | DRM_DEBUG_KMS("disabling CxSR downclocking\n"); | 5197 | DRM_DEBUG_KMS("disabling CxSR downclocking\n"); |
5083 | pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK; | 5198 | pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK; |
@@ -5116,33 +5231,24 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
5116 | (adjusted_mode->crtc_vsync_start - 1) | | 5231 | (adjusted_mode->crtc_vsync_start - 1) | |
5117 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); | 5232 | ((adjusted_mode->crtc_vsync_end - 1) << 16)); |
5118 | 5233 | ||
5119 | /* pipesrc and dspsize control the size that is scaled from, | 5234 | /* pipesrc controls the size that is scaled from, which should |
5120 | * which should always be the user's requested size. | 5235 | * always be the user's requested size. |
5121 | */ | 5236 | */ |
5122 | if (!HAS_PCH_SPLIT(dev)) { | ||
5123 | I915_WRITE(DSPSIZE(plane), | ||
5124 | ((mode->vdisplay - 1) << 16) | | ||
5125 | (mode->hdisplay - 1)); | ||
5126 | I915_WRITE(DSPPOS(plane), 0); | ||
5127 | } | ||
5128 | I915_WRITE(PIPESRC(pipe), | 5237 | I915_WRITE(PIPESRC(pipe), |
5129 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 5238 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); |
5130 | 5239 | ||
5131 | if (HAS_PCH_SPLIT(dev)) { | 5240 | I915_WRITE(PIPE_DATA_M1(pipe), TU_SIZE(m_n.tu) | m_n.gmch_m); |
5132 | I915_WRITE(PIPE_DATA_M1(pipe), TU_SIZE(m_n.tu) | m_n.gmch_m); | 5241 | I915_WRITE(PIPE_DATA_N1(pipe), m_n.gmch_n); |
5133 | I915_WRITE(PIPE_DATA_N1(pipe), m_n.gmch_n); | 5242 | I915_WRITE(PIPE_LINK_M1(pipe), m_n.link_m); |
5134 | I915_WRITE(PIPE_LINK_M1(pipe), m_n.link_m); | 5243 | I915_WRITE(PIPE_LINK_N1(pipe), m_n.link_n); |
5135 | I915_WRITE(PIPE_LINK_N1(pipe), m_n.link_n); | ||
5136 | 5244 | ||
5137 | if (has_edp_encoder && !intel_encoder_is_pch_edp(&has_edp_encoder->base)) { | 5245 | if (has_edp_encoder && |
5138 | ironlake_set_pll_edp(crtc, adjusted_mode->clock); | 5246 | !intel_encoder_is_pch_edp(&has_edp_encoder->base)) { |
5139 | } | 5247 | ironlake_set_pll_edp(crtc, adjusted_mode->clock); |
5140 | } | 5248 | } |
5141 | 5249 | ||
5142 | I915_WRITE(PIPECONF(pipe), pipeconf); | 5250 | I915_WRITE(PIPECONF(pipe), pipeconf); |
5143 | POSTING_READ(PIPECONF(pipe)); | 5251 | POSTING_READ(PIPECONF(pipe)); |
5144 | if (!HAS_PCH_SPLIT(dev)) | ||
5145 | intel_enable_pipe(dev_priv, pipe, false); | ||
5146 | 5252 | ||
5147 | intel_wait_for_vblank(dev, pipe); | 5253 | intel_wait_for_vblank(dev, pipe); |
5148 | 5254 | ||
@@ -5154,13 +5260,31 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
5154 | 5260 | ||
5155 | I915_WRITE(DSPCNTR(plane), dspcntr); | 5261 | I915_WRITE(DSPCNTR(plane), dspcntr); |
5156 | POSTING_READ(DSPCNTR(plane)); | 5262 | POSTING_READ(DSPCNTR(plane)); |
5157 | if (!HAS_PCH_SPLIT(dev)) | ||
5158 | intel_enable_plane(dev_priv, plane, pipe); | ||
5159 | 5263 | ||
5160 | ret = intel_pipe_set_base(crtc, x, y, old_fb); | 5264 | ret = intel_pipe_set_base(crtc, x, y, old_fb); |
5161 | 5265 | ||
5162 | intel_update_watermarks(dev); | 5266 | intel_update_watermarks(dev); |
5163 | 5267 | ||
5268 | return ret; | ||
5269 | } | ||
5270 | |||
5271 | static int intel_crtc_mode_set(struct drm_crtc *crtc, | ||
5272 | struct drm_display_mode *mode, | ||
5273 | struct drm_display_mode *adjusted_mode, | ||
5274 | int x, int y, | ||
5275 | struct drm_framebuffer *old_fb) | ||
5276 | { | ||
5277 | struct drm_device *dev = crtc->dev; | ||
5278 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
5279 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
5280 | int pipe = intel_crtc->pipe; | ||
5281 | int ret; | ||
5282 | |||
5283 | drm_vblank_pre_modeset(dev, pipe); | ||
5284 | |||
5285 | ret = dev_priv->display.crtc_mode_set(crtc, mode, adjusted_mode, | ||
5286 | x, y, old_fb); | ||
5287 | |||
5164 | drm_vblank_post_modeset(dev, pipe); | 5288 | drm_vblank_post_modeset(dev, pipe); |
5165 | 5289 | ||
5166 | return ret; | 5290 | return ret; |
@@ -5483,43 +5607,140 @@ static struct drm_display_mode load_detect_mode = { | |||
5483 | 704, 832, 0, 480, 489, 491, 520, 0, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), | 5607 | 704, 832, 0, 480, 489, 491, 520, 0, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
5484 | }; | 5608 | }; |
5485 | 5609 | ||
5486 | struct drm_crtc *intel_get_load_detect_pipe(struct intel_encoder *intel_encoder, | 5610 | static struct drm_framebuffer * |
5487 | struct drm_connector *connector, | 5611 | intel_framebuffer_create(struct drm_device *dev, |
5488 | struct drm_display_mode *mode, | 5612 | struct drm_mode_fb_cmd *mode_cmd, |
5489 | int *dpms_mode) | 5613 | struct drm_i915_gem_object *obj) |
5614 | { | ||
5615 | struct intel_framebuffer *intel_fb; | ||
5616 | int ret; | ||
5617 | |||
5618 | intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); | ||
5619 | if (!intel_fb) { | ||
5620 | drm_gem_object_unreference_unlocked(&obj->base); | ||
5621 | return ERR_PTR(-ENOMEM); | ||
5622 | } | ||
5623 | |||
5624 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); | ||
5625 | if (ret) { | ||
5626 | drm_gem_object_unreference_unlocked(&obj->base); | ||
5627 | kfree(intel_fb); | ||
5628 | return ERR_PTR(ret); | ||
5629 | } | ||
5630 | |||
5631 | return &intel_fb->base; | ||
5632 | } | ||
5633 | |||
5634 | static u32 | ||
5635 | intel_framebuffer_pitch_for_width(int width, int bpp) | ||
5636 | { | ||
5637 | u32 pitch = DIV_ROUND_UP(width * bpp, 8); | ||
5638 | return ALIGN(pitch, 64); | ||
5639 | } | ||
5640 | |||
5641 | static u32 | ||
5642 | intel_framebuffer_size_for_mode(struct drm_display_mode *mode, int bpp) | ||
5643 | { | ||
5644 | u32 pitch = intel_framebuffer_pitch_for_width(mode->hdisplay, bpp); | ||
5645 | return ALIGN(pitch * mode->vdisplay, PAGE_SIZE); | ||
5646 | } | ||
5647 | |||
5648 | static struct drm_framebuffer * | ||
5649 | intel_framebuffer_create_for_mode(struct drm_device *dev, | ||
5650 | struct drm_display_mode *mode, | ||
5651 | int depth, int bpp) | ||
5652 | { | ||
5653 | struct drm_i915_gem_object *obj; | ||
5654 | struct drm_mode_fb_cmd mode_cmd; | ||
5655 | |||
5656 | obj = i915_gem_alloc_object(dev, | ||
5657 | intel_framebuffer_size_for_mode(mode, bpp)); | ||
5658 | if (obj == NULL) | ||
5659 | return ERR_PTR(-ENOMEM); | ||
5660 | |||
5661 | mode_cmd.width = mode->hdisplay; | ||
5662 | mode_cmd.height = mode->vdisplay; | ||
5663 | mode_cmd.depth = depth; | ||
5664 | mode_cmd.bpp = bpp; | ||
5665 | mode_cmd.pitch = intel_framebuffer_pitch_for_width(mode_cmd.width, bpp); | ||
5666 | |||
5667 | return intel_framebuffer_create(dev, &mode_cmd, obj); | ||
5668 | } | ||
5669 | |||
5670 | static struct drm_framebuffer * | ||
5671 | mode_fits_in_fbdev(struct drm_device *dev, | ||
5672 | struct drm_display_mode *mode) | ||
5673 | { | ||
5674 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
5675 | struct drm_i915_gem_object *obj; | ||
5676 | struct drm_framebuffer *fb; | ||
5677 | |||
5678 | if (dev_priv->fbdev == NULL) | ||
5679 | return NULL; | ||
5680 | |||
5681 | obj = dev_priv->fbdev->ifb.obj; | ||
5682 | if (obj == NULL) | ||
5683 | return NULL; | ||
5684 | |||
5685 | fb = &dev_priv->fbdev->ifb.base; | ||
5686 | if (fb->pitch < intel_framebuffer_pitch_for_width(mode->hdisplay, | ||
5687 | fb->bits_per_pixel)) | ||
5688 | return NULL; | ||
5689 | |||
5690 | if (obj->base.size < mode->vdisplay * fb->pitch) | ||
5691 | return NULL; | ||
5692 | |||
5693 | return fb; | ||
5694 | } | ||
5695 | |||
5696 | bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder, | ||
5697 | struct drm_connector *connector, | ||
5698 | struct drm_display_mode *mode, | ||
5699 | struct intel_load_detect_pipe *old) | ||
5490 | { | 5700 | { |
5491 | struct intel_crtc *intel_crtc; | 5701 | struct intel_crtc *intel_crtc; |
5492 | struct drm_crtc *possible_crtc; | 5702 | struct drm_crtc *possible_crtc; |
5493 | struct drm_crtc *supported_crtc =NULL; | ||
5494 | struct drm_encoder *encoder = &intel_encoder->base; | 5703 | struct drm_encoder *encoder = &intel_encoder->base; |
5495 | struct drm_crtc *crtc = NULL; | 5704 | struct drm_crtc *crtc = NULL; |
5496 | struct drm_device *dev = encoder->dev; | 5705 | struct drm_device *dev = encoder->dev; |
5497 | struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; | 5706 | struct drm_framebuffer *old_fb; |
5498 | struct drm_crtc_helper_funcs *crtc_funcs; | ||
5499 | int i = -1; | 5707 | int i = -1; |
5500 | 5708 | ||
5709 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", | ||
5710 | connector->base.id, drm_get_connector_name(connector), | ||
5711 | encoder->base.id, drm_get_encoder_name(encoder)); | ||
5712 | |||
5501 | /* | 5713 | /* |
5502 | * Algorithm gets a little messy: | 5714 | * Algorithm gets a little messy: |
5715 | * | ||
5503 | * - if the connector already has an assigned crtc, use it (but make | 5716 | * - if the connector already has an assigned crtc, use it (but make |
5504 | * sure it's on first) | 5717 | * sure it's on first) |
5718 | * | ||
5505 | * - try to find the first unused crtc that can drive this connector, | 5719 | * - try to find the first unused crtc that can drive this connector, |
5506 | * and use that if we find one | 5720 | * and use that if we find one |
5507 | * - if there are no unused crtcs available, try to use the first | ||
5508 | * one we found that supports the connector | ||
5509 | */ | 5721 | */ |
5510 | 5722 | ||
5511 | /* See if we already have a CRTC for this connector */ | 5723 | /* See if we already have a CRTC for this connector */ |
5512 | if (encoder->crtc) { | 5724 | if (encoder->crtc) { |
5513 | crtc = encoder->crtc; | 5725 | crtc = encoder->crtc; |
5514 | /* Make sure the crtc and connector are running */ | 5726 | |
5515 | intel_crtc = to_intel_crtc(crtc); | 5727 | intel_crtc = to_intel_crtc(crtc); |
5516 | *dpms_mode = intel_crtc->dpms_mode; | 5728 | old->dpms_mode = intel_crtc->dpms_mode; |
5729 | old->load_detect_temp = false; | ||
5730 | |||
5731 | /* Make sure the crtc and connector are running */ | ||
5517 | if (intel_crtc->dpms_mode != DRM_MODE_DPMS_ON) { | 5732 | if (intel_crtc->dpms_mode != DRM_MODE_DPMS_ON) { |
5733 | struct drm_encoder_helper_funcs *encoder_funcs; | ||
5734 | struct drm_crtc_helper_funcs *crtc_funcs; | ||
5735 | |||
5518 | crtc_funcs = crtc->helper_private; | 5736 | crtc_funcs = crtc->helper_private; |
5519 | crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON); | 5737 | crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON); |
5738 | |||
5739 | encoder_funcs = encoder->helper_private; | ||
5520 | encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON); | 5740 | encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON); |
5521 | } | 5741 | } |
5522 | return crtc; | 5742 | |
5743 | return true; | ||
5523 | } | 5744 | } |
5524 | 5745 | ||
5525 | /* Find an unused one (if possible) */ | 5746 | /* Find an unused one (if possible) */ |
@@ -5531,46 +5752,66 @@ struct drm_crtc *intel_get_load_detect_pipe(struct intel_encoder *intel_encoder, | |||
5531 | crtc = possible_crtc; | 5752 | crtc = possible_crtc; |
5532 | break; | 5753 | break; |
5533 | } | 5754 | } |
5534 | if (!supported_crtc) | ||
5535 | supported_crtc = possible_crtc; | ||
5536 | } | 5755 | } |
5537 | 5756 | ||
5538 | /* | 5757 | /* |
5539 | * If we didn't find an unused CRTC, don't use any. | 5758 | * If we didn't find an unused CRTC, don't use any. |
5540 | */ | 5759 | */ |
5541 | if (!crtc) { | 5760 | if (!crtc) { |
5542 | return NULL; | 5761 | DRM_DEBUG_KMS("no pipe available for load-detect\n"); |
5762 | return false; | ||
5543 | } | 5763 | } |
5544 | 5764 | ||
5545 | encoder->crtc = crtc; | 5765 | encoder->crtc = crtc; |
5546 | connector->encoder = encoder; | 5766 | connector->encoder = encoder; |
5547 | intel_encoder->load_detect_temp = true; | ||
5548 | 5767 | ||
5549 | intel_crtc = to_intel_crtc(crtc); | 5768 | intel_crtc = to_intel_crtc(crtc); |
5550 | *dpms_mode = intel_crtc->dpms_mode; | 5769 | old->dpms_mode = intel_crtc->dpms_mode; |
5770 | old->load_detect_temp = true; | ||
5771 | old->release_fb = NULL; | ||
5551 | 5772 | ||
5552 | if (!crtc->enabled) { | 5773 | if (!mode) |
5553 | if (!mode) | 5774 | mode = &load_detect_mode; |
5554 | mode = &load_detect_mode; | 5775 | |
5555 | drm_crtc_helper_set_mode(crtc, mode, 0, 0, crtc->fb); | 5776 | old_fb = crtc->fb; |
5556 | } else { | ||
5557 | if (intel_crtc->dpms_mode != DRM_MODE_DPMS_ON) { | ||
5558 | crtc_funcs = crtc->helper_private; | ||
5559 | crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON); | ||
5560 | } | ||
5561 | 5777 | ||
5562 | /* Add this connector to the crtc */ | 5778 | /* We need a framebuffer large enough to accommodate all accesses |
5563 | encoder_funcs->mode_set(encoder, &crtc->mode, &crtc->mode); | 5779 | * that the plane may generate whilst we perform load detection. |
5564 | encoder_funcs->commit(encoder); | 5780 | * We can not rely on the fbcon either being present (we get called |
5781 | * during its initialisation to detect all boot displays, or it may | ||
5782 | * not even exist) or that it is large enough to satisfy the | ||
5783 | * requested mode. | ||
5784 | */ | ||
5785 | crtc->fb = mode_fits_in_fbdev(dev, mode); | ||
5786 | if (crtc->fb == NULL) { | ||
5787 | DRM_DEBUG_KMS("creating tmp fb for load-detection\n"); | ||
5788 | crtc->fb = intel_framebuffer_create_for_mode(dev, mode, 24, 32); | ||
5789 | old->release_fb = crtc->fb; | ||
5790 | } else | ||
5791 | DRM_DEBUG_KMS("reusing fbdev for load-detection framebuffer\n"); | ||
5792 | if (IS_ERR(crtc->fb)) { | ||
5793 | DRM_DEBUG_KMS("failed to allocate framebuffer for load-detection\n"); | ||
5794 | crtc->fb = old_fb; | ||
5795 | return false; | ||
5565 | } | 5796 | } |
5797 | |||
5798 | if (!drm_crtc_helper_set_mode(crtc, mode, 0, 0, old_fb)) { | ||
5799 | DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n"); | ||
5800 | if (old->release_fb) | ||
5801 | old->release_fb->funcs->destroy(old->release_fb); | ||
5802 | crtc->fb = old_fb; | ||
5803 | return false; | ||
5804 | } | ||
5805 | |||
5566 | /* let the connector get through one full cycle before testing */ | 5806 | /* let the connector get through one full cycle before testing */ |
5567 | intel_wait_for_vblank(dev, intel_crtc->pipe); | 5807 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
5568 | 5808 | ||
5569 | return crtc; | 5809 | return true; |
5570 | } | 5810 | } |
5571 | 5811 | ||
5572 | void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder, | 5812 | void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder, |
5573 | struct drm_connector *connector, int dpms_mode) | 5813 | struct drm_connector *connector, |
5814 | struct intel_load_detect_pipe *old) | ||
5574 | { | 5815 | { |
5575 | struct drm_encoder *encoder = &intel_encoder->base; | 5816 | struct drm_encoder *encoder = &intel_encoder->base; |
5576 | struct drm_device *dev = encoder->dev; | 5817 | struct drm_device *dev = encoder->dev; |
@@ -5578,19 +5819,24 @@ void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder, | |||
5578 | struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; | 5819 | struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; |
5579 | struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; | 5820 | struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; |
5580 | 5821 | ||
5581 | if (intel_encoder->load_detect_temp) { | 5822 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", |
5582 | encoder->crtc = NULL; | 5823 | connector->base.id, drm_get_connector_name(connector), |
5824 | encoder->base.id, drm_get_encoder_name(encoder)); | ||
5825 | |||
5826 | if (old->load_detect_temp) { | ||
5583 | connector->encoder = NULL; | 5827 | connector->encoder = NULL; |
5584 | intel_encoder->load_detect_temp = false; | ||
5585 | crtc->enabled = drm_helper_crtc_in_use(crtc); | ||
5586 | drm_helper_disable_unused_functions(dev); | 5828 | drm_helper_disable_unused_functions(dev); |
5829 | |||
5830 | if (old->release_fb) | ||
5831 | old->release_fb->funcs->destroy(old->release_fb); | ||
5832 | |||
5833 | return; | ||
5587 | } | 5834 | } |
5588 | 5835 | ||
5589 | /* Switch crtc and encoder back off if necessary */ | 5836 | /* Switch crtc and encoder back off if necessary */ |
5590 | if (crtc->enabled && dpms_mode != DRM_MODE_DPMS_ON) { | 5837 | if (old->dpms_mode != DRM_MODE_DPMS_ON) { |
5591 | if (encoder->crtc == crtc) | 5838 | encoder_funcs->dpms(encoder, old->dpms_mode); |
5592 | encoder_funcs->dpms(encoder, dpms_mode); | 5839 | crtc_funcs->dpms(crtc, old->dpms_mode); |
5593 | crtc_funcs->dpms(crtc, dpms_mode); | ||
5594 | } | 5840 | } |
5595 | } | 5841 | } |
5596 | 5842 | ||
@@ -5605,9 +5851,9 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc) | |||
5605 | intel_clock_t clock; | 5851 | intel_clock_t clock; |
5606 | 5852 | ||
5607 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) | 5853 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) |
5608 | fp = FP0(pipe); | 5854 | fp = I915_READ(FP0(pipe)); |
5609 | else | 5855 | else |
5610 | fp = FP1(pipe); | 5856 | fp = I915_READ(FP1(pipe)); |
5611 | 5857 | ||
5612 | clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; | 5858 | clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; |
5613 | if (IS_PINEVIEW(dev)) { | 5859 | if (IS_PINEVIEW(dev)) { |
@@ -6185,6 +6431,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, | |||
6185 | break; | 6431 | break; |
6186 | 6432 | ||
6187 | case 6: | 6433 | case 6: |
6434 | case 7: | ||
6188 | OUT_RING(MI_DISPLAY_FLIP | | 6435 | OUT_RING(MI_DISPLAY_FLIP | |
6189 | MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); | 6436 | MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); |
6190 | OUT_RING(fb->pitch | obj->tiling_mode); | 6437 | OUT_RING(fb->pitch | obj->tiling_mode); |
@@ -6504,6 +6751,9 @@ static void intel_setup_outputs(struct drm_device *dev) | |||
6504 | } | 6751 | } |
6505 | 6752 | ||
6506 | intel_panel_setup_backlight(dev); | 6753 | intel_panel_setup_backlight(dev); |
6754 | |||
6755 | /* disable all the possible outputs/crtcs before entering KMS mode */ | ||
6756 | drm_helper_disable_unused_functions(dev); | ||
6507 | } | 6757 | } |
6508 | 6758 | ||
6509 | static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb) | 6759 | static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb) |
@@ -6571,25 +6821,12 @@ intel_user_framebuffer_create(struct drm_device *dev, | |||
6571 | struct drm_mode_fb_cmd *mode_cmd) | 6821 | struct drm_mode_fb_cmd *mode_cmd) |
6572 | { | 6822 | { |
6573 | struct drm_i915_gem_object *obj; | 6823 | struct drm_i915_gem_object *obj; |
6574 | struct intel_framebuffer *intel_fb; | ||
6575 | int ret; | ||
6576 | 6824 | ||
6577 | obj = to_intel_bo(drm_gem_object_lookup(dev, filp, mode_cmd->handle)); | 6825 | obj = to_intel_bo(drm_gem_object_lookup(dev, filp, mode_cmd->handle)); |
6578 | if (&obj->base == NULL) | 6826 | if (&obj->base == NULL) |
6579 | return ERR_PTR(-ENOENT); | 6827 | return ERR_PTR(-ENOENT); |
6580 | 6828 | ||
6581 | intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); | 6829 | return intel_framebuffer_create(dev, mode_cmd, obj); |
6582 | if (!intel_fb) | ||
6583 | return ERR_PTR(-ENOMEM); | ||
6584 | |||
6585 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); | ||
6586 | if (ret) { | ||
6587 | drm_gem_object_unreference_unlocked(&obj->base); | ||
6588 | kfree(intel_fb); | ||
6589 | return ERR_PTR(ret); | ||
6590 | } | ||
6591 | |||
6592 | return &intel_fb->base; | ||
6593 | } | 6830 | } |
6594 | 6831 | ||
6595 | static const struct drm_mode_config_funcs intel_mode_funcs = { | 6832 | static const struct drm_mode_config_funcs intel_mode_funcs = { |
@@ -6603,13 +6840,14 @@ intel_alloc_context_page(struct drm_device *dev) | |||
6603 | struct drm_i915_gem_object *ctx; | 6840 | struct drm_i915_gem_object *ctx; |
6604 | int ret; | 6841 | int ret; |
6605 | 6842 | ||
6843 | WARN_ON(!mutex_is_locked(&dev->struct_mutex)); | ||
6844 | |||
6606 | ctx = i915_gem_alloc_object(dev, 4096); | 6845 | ctx = i915_gem_alloc_object(dev, 4096); |
6607 | if (!ctx) { | 6846 | if (!ctx) { |
6608 | DRM_DEBUG("failed to alloc power context, RC6 disabled\n"); | 6847 | DRM_DEBUG("failed to alloc power context, RC6 disabled\n"); |
6609 | return NULL; | 6848 | return NULL; |
6610 | } | 6849 | } |
6611 | 6850 | ||
6612 | mutex_lock(&dev->struct_mutex); | ||
6613 | ret = i915_gem_object_pin(ctx, 4096, true); | 6851 | ret = i915_gem_object_pin(ctx, 4096, true); |
6614 | if (ret) { | 6852 | if (ret) { |
6615 | DRM_ERROR("failed to pin power context: %d\n", ret); | 6853 | DRM_ERROR("failed to pin power context: %d\n", ret); |
@@ -6621,7 +6859,6 @@ intel_alloc_context_page(struct drm_device *dev) | |||
6621 | DRM_ERROR("failed to set-domain on power context: %d\n", ret); | 6859 | DRM_ERROR("failed to set-domain on power context: %d\n", ret); |
6622 | goto err_unpin; | 6860 | goto err_unpin; |
6623 | } | 6861 | } |
6624 | mutex_unlock(&dev->struct_mutex); | ||
6625 | 6862 | ||
6626 | return ctx; | 6863 | return ctx; |
6627 | 6864 | ||
@@ -6756,6 +6993,11 @@ void gen6_disable_rps(struct drm_device *dev) | |||
6756 | I915_WRITE(GEN6_RPNSWREQ, 1 << 31); | 6993 | I915_WRITE(GEN6_RPNSWREQ, 1 << 31); |
6757 | I915_WRITE(GEN6_PMINTRMSK, 0xffffffff); | 6994 | I915_WRITE(GEN6_PMINTRMSK, 0xffffffff); |
6758 | I915_WRITE(GEN6_PMIER, 0); | 6995 | I915_WRITE(GEN6_PMIER, 0); |
6996 | |||
6997 | spin_lock_irq(&dev_priv->rps_lock); | ||
6998 | dev_priv->pm_iir = 0; | ||
6999 | spin_unlock_irq(&dev_priv->rps_lock); | ||
7000 | |||
6759 | I915_WRITE(GEN6_PMIIR, I915_READ(GEN6_PMIIR)); | 7001 | I915_WRITE(GEN6_PMIIR, I915_READ(GEN6_PMIIR)); |
6760 | } | 7002 | } |
6761 | 7003 | ||
@@ -6849,7 +7091,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv) | |||
6849 | { | 7091 | { |
6850 | u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); | 7092 | u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
6851 | u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); | 7093 | u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS); |
6852 | u32 pcu_mbox; | 7094 | u32 pcu_mbox, rc6_mask = 0; |
6853 | int cur_freq, min_freq, max_freq; | 7095 | int cur_freq, min_freq, max_freq; |
6854 | int i; | 7096 | int i; |
6855 | 7097 | ||
@@ -6860,7 +7102,8 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv) | |||
6860 | * userspace... | 7102 | * userspace... |
6861 | */ | 7103 | */ |
6862 | I915_WRITE(GEN6_RC_STATE, 0); | 7104 | I915_WRITE(GEN6_RC_STATE, 0); |
6863 | __gen6_gt_force_wake_get(dev_priv); | 7105 | mutex_lock(&dev_priv->dev->struct_mutex); |
7106 | gen6_gt_force_wake_get(dev_priv); | ||
6864 | 7107 | ||
6865 | /* disable the counters and set deterministic thresholds */ | 7108 | /* disable the counters and set deterministic thresholds */ |
6866 | I915_WRITE(GEN6_RC_CONTROL, 0); | 7109 | I915_WRITE(GEN6_RC_CONTROL, 0); |
@@ -6880,9 +7123,12 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv) | |||
6880 | I915_WRITE(GEN6_RC6p_THRESHOLD, 100000); | 7123 | I915_WRITE(GEN6_RC6p_THRESHOLD, 100000); |
6881 | I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */ | 7124 | I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */ |
6882 | 7125 | ||
7126 | if (i915_enable_rc6) | ||
7127 | rc6_mask = GEN6_RC_CTL_RC6p_ENABLE | | ||
7128 | GEN6_RC_CTL_RC6_ENABLE; | ||
7129 | |||
6883 | I915_WRITE(GEN6_RC_CONTROL, | 7130 | I915_WRITE(GEN6_RC_CONTROL, |
6884 | GEN6_RC_CTL_RC6p_ENABLE | | 7131 | rc6_mask | |
6885 | GEN6_RC_CTL_RC6_ENABLE | | ||
6886 | GEN6_RC_CTL_EI_MODE(1) | | 7132 | GEN6_RC_CTL_EI_MODE(1) | |
6887 | GEN6_RC_CTL_HW_ENABLE); | 7133 | GEN6_RC_CTL_HW_ENABLE); |
6888 | 7134 | ||
@@ -6954,168 +7200,237 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv) | |||
6954 | GEN6_PM_RP_DOWN_THRESHOLD | | 7200 | GEN6_PM_RP_DOWN_THRESHOLD | |
6955 | GEN6_PM_RP_UP_EI_EXPIRED | | 7201 | GEN6_PM_RP_UP_EI_EXPIRED | |
6956 | GEN6_PM_RP_DOWN_EI_EXPIRED); | 7202 | GEN6_PM_RP_DOWN_EI_EXPIRED); |
7203 | spin_lock_irq(&dev_priv->rps_lock); | ||
7204 | WARN_ON(dev_priv->pm_iir != 0); | ||
6957 | I915_WRITE(GEN6_PMIMR, 0); | 7205 | I915_WRITE(GEN6_PMIMR, 0); |
7206 | spin_unlock_irq(&dev_priv->rps_lock); | ||
6958 | /* enable all PM interrupts */ | 7207 | /* enable all PM interrupts */ |
6959 | I915_WRITE(GEN6_PMINTRMSK, 0); | 7208 | I915_WRITE(GEN6_PMINTRMSK, 0); |
6960 | 7209 | ||
6961 | __gen6_gt_force_wake_put(dev_priv); | 7210 | gen6_gt_force_wake_put(dev_priv); |
7211 | mutex_unlock(&dev_priv->dev->struct_mutex); | ||
7212 | } | ||
7213 | |||
7214 | static void ironlake_init_clock_gating(struct drm_device *dev) | ||
7215 | { | ||
7216 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7217 | uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE; | ||
7218 | |||
7219 | /* Required for FBC */ | ||
7220 | dspclk_gate |= DPFCUNIT_CLOCK_GATE_DISABLE | | ||
7221 | DPFCRUNIT_CLOCK_GATE_DISABLE | | ||
7222 | DPFDUNIT_CLOCK_GATE_DISABLE; | ||
7223 | /* Required for CxSR */ | ||
7224 | dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE; | ||
7225 | |||
7226 | I915_WRITE(PCH_3DCGDIS0, | ||
7227 | MARIUNIT_CLOCK_GATE_DISABLE | | ||
7228 | SVSMUNIT_CLOCK_GATE_DISABLE); | ||
7229 | I915_WRITE(PCH_3DCGDIS1, | ||
7230 | VFMUNIT_CLOCK_GATE_DISABLE); | ||
7231 | |||
7232 | I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate); | ||
7233 | |||
7234 | /* | ||
7235 | * According to the spec the following bits should be set in | ||
7236 | * order to enable memory self-refresh | ||
7237 | * The bit 22/21 of 0x42004 | ||
7238 | * The bit 5 of 0x42020 | ||
7239 | * The bit 15 of 0x45000 | ||
7240 | */ | ||
7241 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7242 | (I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7243 | ILK_DPARB_GATE | ILK_VSDPFD_FULL)); | ||
7244 | I915_WRITE(ILK_DSPCLK_GATE, | ||
7245 | (I915_READ(ILK_DSPCLK_GATE) | | ||
7246 | ILK_DPARB_CLK_GATE)); | ||
7247 | I915_WRITE(DISP_ARB_CTL, | ||
7248 | (I915_READ(DISP_ARB_CTL) | | ||
7249 | DISP_FBC_WM_DIS)); | ||
7250 | I915_WRITE(WM3_LP_ILK, 0); | ||
7251 | I915_WRITE(WM2_LP_ILK, 0); | ||
7252 | I915_WRITE(WM1_LP_ILK, 0); | ||
7253 | |||
7254 | /* | ||
7255 | * Based on the document from hardware guys the following bits | ||
7256 | * should be set unconditionally in order to enable FBC. | ||
7257 | * The bit 22 of 0x42000 | ||
7258 | * The bit 22 of 0x42004 | ||
7259 | * The bit 7,8,9 of 0x42020. | ||
7260 | */ | ||
7261 | if (IS_IRONLAKE_M(dev)) { | ||
7262 | I915_WRITE(ILK_DISPLAY_CHICKEN1, | ||
7263 | I915_READ(ILK_DISPLAY_CHICKEN1) | | ||
7264 | ILK_FBCQ_DIS); | ||
7265 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7266 | I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7267 | ILK_DPARB_GATE); | ||
7268 | I915_WRITE(ILK_DSPCLK_GATE, | ||
7269 | I915_READ(ILK_DSPCLK_GATE) | | ||
7270 | ILK_DPFC_DIS1 | | ||
7271 | ILK_DPFC_DIS2 | | ||
7272 | ILK_CLK_FBC); | ||
7273 | } | ||
7274 | |||
7275 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7276 | I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7277 | ILK_ELPIN_409_SELECT); | ||
7278 | I915_WRITE(_3D_CHICKEN2, | ||
7279 | _3D_CHICKEN2_WM_READ_PIPELINED << 16 | | ||
7280 | _3D_CHICKEN2_WM_READ_PIPELINED); | ||
6962 | } | 7281 | } |
6963 | 7282 | ||
6964 | void intel_enable_clock_gating(struct drm_device *dev) | 7283 | static void gen6_init_clock_gating(struct drm_device *dev) |
6965 | { | 7284 | { |
6966 | struct drm_i915_private *dev_priv = dev->dev_private; | 7285 | struct drm_i915_private *dev_priv = dev->dev_private; |
6967 | int pipe; | 7286 | int pipe; |
7287 | uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE; | ||
7288 | |||
7289 | I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate); | ||
7290 | |||
7291 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7292 | I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7293 | ILK_ELPIN_409_SELECT); | ||
7294 | |||
7295 | I915_WRITE(WM3_LP_ILK, 0); | ||
7296 | I915_WRITE(WM2_LP_ILK, 0); | ||
7297 | I915_WRITE(WM1_LP_ILK, 0); | ||
6968 | 7298 | ||
6969 | /* | 7299 | /* |
6970 | * Disable clock gating reported to work incorrectly according to the | 7300 | * According to the spec the following bits should be |
6971 | * specs, but enable as much else as we can. | 7301 | * set in order to enable memory self-refresh and fbc: |
7302 | * The bit21 and bit22 of 0x42000 | ||
7303 | * The bit21 and bit22 of 0x42004 | ||
7304 | * The bit5 and bit7 of 0x42020 | ||
7305 | * The bit14 of 0x70180 | ||
7306 | * The bit14 of 0x71180 | ||
6972 | */ | 7307 | */ |
6973 | if (HAS_PCH_SPLIT(dev)) { | 7308 | I915_WRITE(ILK_DISPLAY_CHICKEN1, |
6974 | uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE; | 7309 | I915_READ(ILK_DISPLAY_CHICKEN1) | |
7310 | ILK_FBCQ_DIS | ILK_PABSTRETCH_DIS); | ||
7311 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7312 | I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7313 | ILK_DPARB_GATE | ILK_VSDPFD_FULL); | ||
7314 | I915_WRITE(ILK_DSPCLK_GATE, | ||
7315 | I915_READ(ILK_DSPCLK_GATE) | | ||
7316 | ILK_DPARB_CLK_GATE | | ||
7317 | ILK_DPFD_CLK_GATE); | ||
6975 | 7318 | ||
6976 | if (IS_GEN5(dev)) { | 7319 | for_each_pipe(pipe) |
6977 | /* Required for FBC */ | 7320 | I915_WRITE(DSPCNTR(pipe), |
6978 | dspclk_gate |= DPFCUNIT_CLOCK_GATE_DISABLE | | 7321 | I915_READ(DSPCNTR(pipe)) | |
6979 | DPFCRUNIT_CLOCK_GATE_DISABLE | | 7322 | DISPPLANE_TRICKLE_FEED_DISABLE); |
6980 | DPFDUNIT_CLOCK_GATE_DISABLE; | 7323 | } |
6981 | /* Required for CxSR */ | ||
6982 | dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE; | ||
6983 | |||
6984 | I915_WRITE(PCH_3DCGDIS0, | ||
6985 | MARIUNIT_CLOCK_GATE_DISABLE | | ||
6986 | SVSMUNIT_CLOCK_GATE_DISABLE); | ||
6987 | I915_WRITE(PCH_3DCGDIS1, | ||
6988 | VFMUNIT_CLOCK_GATE_DISABLE); | ||
6989 | } | ||
6990 | 7324 | ||
6991 | I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate); | 7325 | static void ivybridge_init_clock_gating(struct drm_device *dev) |
7326 | { | ||
7327 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7328 | int pipe; | ||
7329 | uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE; | ||
6992 | 7330 | ||
6993 | /* | 7331 | I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate); |
6994 | * On Ibex Peak and Cougar Point, we need to disable clock | ||
6995 | * gating for the panel power sequencer or it will fail to | ||
6996 | * start up when no ports are active. | ||
6997 | */ | ||
6998 | I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE); | ||
6999 | 7332 | ||
7000 | /* | 7333 | I915_WRITE(WM3_LP_ILK, 0); |
7001 | * According to the spec the following bits should be set in | 7334 | I915_WRITE(WM2_LP_ILK, 0); |
7002 | * order to enable memory self-refresh | 7335 | I915_WRITE(WM1_LP_ILK, 0); |
7003 | * The bit 22/21 of 0x42004 | ||
7004 | * The bit 5 of 0x42020 | ||
7005 | * The bit 15 of 0x45000 | ||
7006 | */ | ||
7007 | if (IS_GEN5(dev)) { | ||
7008 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7009 | (I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7010 | ILK_DPARB_GATE | ILK_VSDPFD_FULL)); | ||
7011 | I915_WRITE(ILK_DSPCLK_GATE, | ||
7012 | (I915_READ(ILK_DSPCLK_GATE) | | ||
7013 | ILK_DPARB_CLK_GATE)); | ||
7014 | I915_WRITE(DISP_ARB_CTL, | ||
7015 | (I915_READ(DISP_ARB_CTL) | | ||
7016 | DISP_FBC_WM_DIS)); | ||
7017 | I915_WRITE(WM3_LP_ILK, 0); | ||
7018 | I915_WRITE(WM2_LP_ILK, 0); | ||
7019 | I915_WRITE(WM1_LP_ILK, 0); | ||
7020 | } | ||
7021 | /* | ||
7022 | * Based on the document from hardware guys the following bits | ||
7023 | * should be set unconditionally in order to enable FBC. | ||
7024 | * The bit 22 of 0x42000 | ||
7025 | * The bit 22 of 0x42004 | ||
7026 | * The bit 7,8,9 of 0x42020. | ||
7027 | */ | ||
7028 | if (IS_IRONLAKE_M(dev)) { | ||
7029 | I915_WRITE(ILK_DISPLAY_CHICKEN1, | ||
7030 | I915_READ(ILK_DISPLAY_CHICKEN1) | | ||
7031 | ILK_FBCQ_DIS); | ||
7032 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7033 | I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7034 | ILK_DPARB_GATE); | ||
7035 | I915_WRITE(ILK_DSPCLK_GATE, | ||
7036 | I915_READ(ILK_DSPCLK_GATE) | | ||
7037 | ILK_DPFC_DIS1 | | ||
7038 | ILK_DPFC_DIS2 | | ||
7039 | ILK_CLK_FBC); | ||
7040 | } | ||
7041 | 7336 | ||
7042 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | 7337 | I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE); |
7043 | I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7044 | ILK_ELPIN_409_SELECT); | ||
7045 | 7338 | ||
7046 | if (IS_GEN5(dev)) { | 7339 | for_each_pipe(pipe) |
7047 | I915_WRITE(_3D_CHICKEN2, | 7340 | I915_WRITE(DSPCNTR(pipe), |
7048 | _3D_CHICKEN2_WM_READ_PIPELINED << 16 | | 7341 | I915_READ(DSPCNTR(pipe)) | |
7049 | _3D_CHICKEN2_WM_READ_PIPELINED); | 7342 | DISPPLANE_TRICKLE_FEED_DISABLE); |
7050 | } | 7343 | } |
7051 | 7344 | ||
7052 | if (IS_GEN6(dev)) { | 7345 | static void g4x_init_clock_gating(struct drm_device *dev) |
7053 | I915_WRITE(WM3_LP_ILK, 0); | 7346 | { |
7054 | I915_WRITE(WM2_LP_ILK, 0); | 7347 | struct drm_i915_private *dev_priv = dev->dev_private; |
7055 | I915_WRITE(WM1_LP_ILK, 0); | 7348 | uint32_t dspclk_gate; |
7056 | 7349 | ||
7057 | /* | 7350 | I915_WRITE(RENCLK_GATE_D1, 0); |
7058 | * According to the spec the following bits should be | 7351 | I915_WRITE(RENCLK_GATE_D2, VF_UNIT_CLOCK_GATE_DISABLE | |
7059 | * set in order to enable memory self-refresh and fbc: | 7352 | GS_UNIT_CLOCK_GATE_DISABLE | |
7060 | * The bit21 and bit22 of 0x42000 | 7353 | CL_UNIT_CLOCK_GATE_DISABLE); |
7061 | * The bit21 and bit22 of 0x42004 | 7354 | I915_WRITE(RAMCLK_GATE_D, 0); |
7062 | * The bit5 and bit7 of 0x42020 | 7355 | dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE | |
7063 | * The bit14 of 0x70180 | 7356 | OVRUNIT_CLOCK_GATE_DISABLE | |
7064 | * The bit14 of 0x71180 | 7357 | OVCUNIT_CLOCK_GATE_DISABLE; |
7065 | */ | 7358 | if (IS_GM45(dev)) |
7066 | I915_WRITE(ILK_DISPLAY_CHICKEN1, | 7359 | dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE; |
7067 | I915_READ(ILK_DISPLAY_CHICKEN1) | | 7360 | I915_WRITE(DSPCLK_GATE_D, dspclk_gate); |
7068 | ILK_FBCQ_DIS | ILK_PABSTRETCH_DIS); | 7361 | } |
7069 | I915_WRITE(ILK_DISPLAY_CHICKEN2, | ||
7070 | I915_READ(ILK_DISPLAY_CHICKEN2) | | ||
7071 | ILK_DPARB_GATE | ILK_VSDPFD_FULL); | ||
7072 | I915_WRITE(ILK_DSPCLK_GATE, | ||
7073 | I915_READ(ILK_DSPCLK_GATE) | | ||
7074 | ILK_DPARB_CLK_GATE | | ||
7075 | ILK_DPFD_CLK_GATE); | ||
7076 | |||
7077 | for_each_pipe(pipe) | ||
7078 | I915_WRITE(DSPCNTR(pipe), | ||
7079 | I915_READ(DSPCNTR(pipe)) | | ||
7080 | DISPPLANE_TRICKLE_FEED_DISABLE); | ||
7081 | } | ||
7082 | } else if (IS_G4X(dev)) { | ||
7083 | uint32_t dspclk_gate; | ||
7084 | I915_WRITE(RENCLK_GATE_D1, 0); | ||
7085 | I915_WRITE(RENCLK_GATE_D2, VF_UNIT_CLOCK_GATE_DISABLE | | ||
7086 | GS_UNIT_CLOCK_GATE_DISABLE | | ||
7087 | CL_UNIT_CLOCK_GATE_DISABLE); | ||
7088 | I915_WRITE(RAMCLK_GATE_D, 0); | ||
7089 | dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE | | ||
7090 | OVRUNIT_CLOCK_GATE_DISABLE | | ||
7091 | OVCUNIT_CLOCK_GATE_DISABLE; | ||
7092 | if (IS_GM45(dev)) | ||
7093 | dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE; | ||
7094 | I915_WRITE(DSPCLK_GATE_D, dspclk_gate); | ||
7095 | } else if (IS_CRESTLINE(dev)) { | ||
7096 | I915_WRITE(RENCLK_GATE_D1, I965_RCC_CLOCK_GATE_DISABLE); | ||
7097 | I915_WRITE(RENCLK_GATE_D2, 0); | ||
7098 | I915_WRITE(DSPCLK_GATE_D, 0); | ||
7099 | I915_WRITE(RAMCLK_GATE_D, 0); | ||
7100 | I915_WRITE16(DEUC, 0); | ||
7101 | } else if (IS_BROADWATER(dev)) { | ||
7102 | I915_WRITE(RENCLK_GATE_D1, I965_RCZ_CLOCK_GATE_DISABLE | | ||
7103 | I965_RCC_CLOCK_GATE_DISABLE | | ||
7104 | I965_RCPB_CLOCK_GATE_DISABLE | | ||
7105 | I965_ISC_CLOCK_GATE_DISABLE | | ||
7106 | I965_FBC_CLOCK_GATE_DISABLE); | ||
7107 | I915_WRITE(RENCLK_GATE_D2, 0); | ||
7108 | } else if (IS_GEN3(dev)) { | ||
7109 | u32 dstate = I915_READ(D_STATE); | ||
7110 | 7362 | ||
7111 | dstate |= DSTATE_PLL_D3_OFF | DSTATE_GFX_CLOCK_GATING | | 7363 | static void crestline_init_clock_gating(struct drm_device *dev) |
7112 | DSTATE_DOT_CLOCK_GATING; | 7364 | { |
7113 | I915_WRITE(D_STATE, dstate); | 7365 | struct drm_i915_private *dev_priv = dev->dev_private; |
7114 | } else if (IS_I85X(dev) || IS_I865G(dev)) { | 7366 | |
7115 | I915_WRITE(RENCLK_GATE_D1, SV_CLOCK_GATE_DISABLE); | 7367 | I915_WRITE(RENCLK_GATE_D1, I965_RCC_CLOCK_GATE_DISABLE); |
7116 | } else if (IS_I830(dev)) { | 7368 | I915_WRITE(RENCLK_GATE_D2, 0); |
7117 | I915_WRITE(DSPCLK_GATE_D, OVRUNIT_CLOCK_GATE_DISABLE); | 7369 | I915_WRITE(DSPCLK_GATE_D, 0); |
7118 | } | 7370 | I915_WRITE(RAMCLK_GATE_D, 0); |
7371 | I915_WRITE16(DEUC, 0); | ||
7372 | } | ||
7373 | |||
7374 | static void broadwater_init_clock_gating(struct drm_device *dev) | ||
7375 | { | ||
7376 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7377 | |||
7378 | I915_WRITE(RENCLK_GATE_D1, I965_RCZ_CLOCK_GATE_DISABLE | | ||
7379 | I965_RCC_CLOCK_GATE_DISABLE | | ||
7380 | I965_RCPB_CLOCK_GATE_DISABLE | | ||
7381 | I965_ISC_CLOCK_GATE_DISABLE | | ||
7382 | I965_FBC_CLOCK_GATE_DISABLE); | ||
7383 | I915_WRITE(RENCLK_GATE_D2, 0); | ||
7384 | } | ||
7385 | |||
7386 | static void gen3_init_clock_gating(struct drm_device *dev) | ||
7387 | { | ||
7388 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7389 | u32 dstate = I915_READ(D_STATE); | ||
7390 | |||
7391 | dstate |= DSTATE_PLL_D3_OFF | DSTATE_GFX_CLOCK_GATING | | ||
7392 | DSTATE_DOT_CLOCK_GATING; | ||
7393 | I915_WRITE(D_STATE, dstate); | ||
7394 | } | ||
7395 | |||
7396 | static void i85x_init_clock_gating(struct drm_device *dev) | ||
7397 | { | ||
7398 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7399 | |||
7400 | I915_WRITE(RENCLK_GATE_D1, SV_CLOCK_GATE_DISABLE); | ||
7401 | } | ||
7402 | |||
7403 | static void i830_init_clock_gating(struct drm_device *dev) | ||
7404 | { | ||
7405 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7406 | |||
7407 | I915_WRITE(DSPCLK_GATE_D, OVRUNIT_CLOCK_GATE_DISABLE); | ||
7408 | } | ||
7409 | |||
7410 | static void ibx_init_clock_gating(struct drm_device *dev) | ||
7411 | { | ||
7412 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7413 | |||
7414 | /* | ||
7415 | * On Ibex Peak and Cougar Point, we need to disable clock | ||
7416 | * gating for the panel power sequencer or it will fail to | ||
7417 | * start up when no ports are active. | ||
7418 | */ | ||
7419 | I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE); | ||
7420 | } | ||
7421 | |||
7422 | static void cpt_init_clock_gating(struct drm_device *dev) | ||
7423 | { | ||
7424 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7425 | |||
7426 | /* | ||
7427 | * On Ibex Peak and Cougar Point, we need to disable clock | ||
7428 | * gating for the panel power sequencer or it will fail to | ||
7429 | * start up when no ports are active. | ||
7430 | */ | ||
7431 | I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE); | ||
7432 | I915_WRITE(SOUTH_CHICKEN2, I915_READ(SOUTH_CHICKEN2) | | ||
7433 | DPLS_EDP_PPS_FIX_DIS); | ||
7119 | } | 7434 | } |
7120 | 7435 | ||
7121 | static void ironlake_teardown_rc6(struct drm_device *dev) | 7436 | static void ironlake_teardown_rc6(struct drm_device *dev) |
@@ -7185,9 +7500,12 @@ void ironlake_enable_rc6(struct drm_device *dev) | |||
7185 | if (!i915_enable_rc6) | 7500 | if (!i915_enable_rc6) |
7186 | return; | 7501 | return; |
7187 | 7502 | ||
7503 | mutex_lock(&dev->struct_mutex); | ||
7188 | ret = ironlake_setup_rc6(dev); | 7504 | ret = ironlake_setup_rc6(dev); |
7189 | if (ret) | 7505 | if (ret) { |
7506 | mutex_unlock(&dev->struct_mutex); | ||
7190 | return; | 7507 | return; |
7508 | } | ||
7191 | 7509 | ||
7192 | /* | 7510 | /* |
7193 | * GPU can automatically power down the render unit if given a page | 7511 | * GPU can automatically power down the render unit if given a page |
@@ -7196,6 +7514,7 @@ void ironlake_enable_rc6(struct drm_device *dev) | |||
7196 | ret = BEGIN_LP_RING(6); | 7514 | ret = BEGIN_LP_RING(6); |
7197 | if (ret) { | 7515 | if (ret) { |
7198 | ironlake_teardown_rc6(dev); | 7516 | ironlake_teardown_rc6(dev); |
7517 | mutex_unlock(&dev->struct_mutex); | ||
7199 | return; | 7518 | return; |
7200 | } | 7519 | } |
7201 | 7520 | ||
@@ -7211,10 +7530,33 @@ void ironlake_enable_rc6(struct drm_device *dev) | |||
7211 | OUT_RING(MI_FLUSH); | 7530 | OUT_RING(MI_FLUSH); |
7212 | ADVANCE_LP_RING(); | 7531 | ADVANCE_LP_RING(); |
7213 | 7532 | ||
7533 | /* | ||
7534 | * Wait for the command parser to advance past MI_SET_CONTEXT. The HW | ||
7535 | * does an implicit flush, combined with MI_FLUSH above, it should be | ||
7536 | * safe to assume that renderctx is valid | ||
7537 | */ | ||
7538 | ret = intel_wait_ring_idle(LP_RING(dev_priv)); | ||
7539 | if (ret) { | ||
7540 | DRM_ERROR("failed to enable ironlake power power savings\n"); | ||
7541 | ironlake_teardown_rc6(dev); | ||
7542 | mutex_unlock(&dev->struct_mutex); | ||
7543 | return; | ||
7544 | } | ||
7545 | |||
7214 | I915_WRITE(PWRCTXA, dev_priv->pwrctx->gtt_offset | PWRCTX_EN); | 7546 | I915_WRITE(PWRCTXA, dev_priv->pwrctx->gtt_offset | PWRCTX_EN); |
7215 | I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT); | 7547 | I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT); |
7548 | mutex_unlock(&dev->struct_mutex); | ||
7216 | } | 7549 | } |
7217 | 7550 | ||
7551 | void intel_init_clock_gating(struct drm_device *dev) | ||
7552 | { | ||
7553 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7554 | |||
7555 | dev_priv->display.init_clock_gating(dev); | ||
7556 | |||
7557 | if (dev_priv->display.init_pch_clock_gating) | ||
7558 | dev_priv->display.init_pch_clock_gating(dev); | ||
7559 | } | ||
7218 | 7560 | ||
7219 | /* Set up chip specific display functions */ | 7561 | /* Set up chip specific display functions */ |
7220 | static void intel_init_display(struct drm_device *dev) | 7562 | static void intel_init_display(struct drm_device *dev) |
@@ -7222,10 +7564,13 @@ static void intel_init_display(struct drm_device *dev) | |||
7222 | struct drm_i915_private *dev_priv = dev->dev_private; | 7564 | struct drm_i915_private *dev_priv = dev->dev_private; |
7223 | 7565 | ||
7224 | /* We always want a DPMS function */ | 7566 | /* We always want a DPMS function */ |
7225 | if (HAS_PCH_SPLIT(dev)) | 7567 | if (HAS_PCH_SPLIT(dev)) { |
7226 | dev_priv->display.dpms = ironlake_crtc_dpms; | 7568 | dev_priv->display.dpms = ironlake_crtc_dpms; |
7227 | else | 7569 | dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set; |
7570 | } else { | ||
7228 | dev_priv->display.dpms = i9xx_crtc_dpms; | 7571 | dev_priv->display.dpms = i9xx_crtc_dpms; |
7572 | dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set; | ||
7573 | } | ||
7229 | 7574 | ||
7230 | if (I915_HAS_FBC(dev)) { | 7575 | if (I915_HAS_FBC(dev)) { |
7231 | if (HAS_PCH_SPLIT(dev)) { | 7576 | if (HAS_PCH_SPLIT(dev)) { |
@@ -7269,6 +7614,11 @@ static void intel_init_display(struct drm_device *dev) | |||
7269 | 7614 | ||
7270 | /* For FIFO watermark updates */ | 7615 | /* For FIFO watermark updates */ |
7271 | if (HAS_PCH_SPLIT(dev)) { | 7616 | if (HAS_PCH_SPLIT(dev)) { |
7617 | if (HAS_PCH_IBX(dev)) | ||
7618 | dev_priv->display.init_pch_clock_gating = ibx_init_clock_gating; | ||
7619 | else if (HAS_PCH_CPT(dev)) | ||
7620 | dev_priv->display.init_pch_clock_gating = cpt_init_clock_gating; | ||
7621 | |||
7272 | if (IS_GEN5(dev)) { | 7622 | if (IS_GEN5(dev)) { |
7273 | if (I915_READ(MLTR_ILK) & ILK_SRLT_MASK) | 7623 | if (I915_READ(MLTR_ILK) & ILK_SRLT_MASK) |
7274 | dev_priv->display.update_wm = ironlake_update_wm; | 7624 | dev_priv->display.update_wm = ironlake_update_wm; |
@@ -7277,6 +7627,8 @@ static void intel_init_display(struct drm_device *dev) | |||
7277 | "Disable CxSR\n"); | 7627 | "Disable CxSR\n"); |
7278 | dev_priv->display.update_wm = NULL; | 7628 | dev_priv->display.update_wm = NULL; |
7279 | } | 7629 | } |
7630 | dev_priv->display.fdi_link_train = ironlake_fdi_link_train; | ||
7631 | dev_priv->display.init_clock_gating = ironlake_init_clock_gating; | ||
7280 | } else if (IS_GEN6(dev)) { | 7632 | } else if (IS_GEN6(dev)) { |
7281 | if (SNB_READ_WM0_LATENCY()) { | 7633 | if (SNB_READ_WM0_LATENCY()) { |
7282 | dev_priv->display.update_wm = sandybridge_update_wm; | 7634 | dev_priv->display.update_wm = sandybridge_update_wm; |
@@ -7285,6 +7637,20 @@ static void intel_init_display(struct drm_device *dev) | |||
7285 | "Disable CxSR\n"); | 7637 | "Disable CxSR\n"); |
7286 | dev_priv->display.update_wm = NULL; | 7638 | dev_priv->display.update_wm = NULL; |
7287 | } | 7639 | } |
7640 | dev_priv->display.fdi_link_train = gen6_fdi_link_train; | ||
7641 | dev_priv->display.init_clock_gating = gen6_init_clock_gating; | ||
7642 | } else if (IS_IVYBRIDGE(dev)) { | ||
7643 | /* FIXME: detect B0+ stepping and use auto training */ | ||
7644 | dev_priv->display.fdi_link_train = ivb_manual_fdi_link_train; | ||
7645 | if (SNB_READ_WM0_LATENCY()) { | ||
7646 | dev_priv->display.update_wm = sandybridge_update_wm; | ||
7647 | } else { | ||
7648 | DRM_DEBUG_KMS("Failed to read display plane latency. " | ||
7649 | "Disable CxSR\n"); | ||
7650 | dev_priv->display.update_wm = NULL; | ||
7651 | } | ||
7652 | dev_priv->display.init_clock_gating = ivybridge_init_clock_gating; | ||
7653 | |||
7288 | } else | 7654 | } else |
7289 | dev_priv->display.update_wm = NULL; | 7655 | dev_priv->display.update_wm = NULL; |
7290 | } else if (IS_PINEVIEW(dev)) { | 7656 | } else if (IS_PINEVIEW(dev)) { |
@@ -7302,18 +7668,30 @@ static void intel_init_display(struct drm_device *dev) | |||
7302 | dev_priv->display.update_wm = NULL; | 7668 | dev_priv->display.update_wm = NULL; |
7303 | } else | 7669 | } else |
7304 | dev_priv->display.update_wm = pineview_update_wm; | 7670 | dev_priv->display.update_wm = pineview_update_wm; |
7305 | } else if (IS_G4X(dev)) | 7671 | } else if (IS_G4X(dev)) { |
7306 | dev_priv->display.update_wm = g4x_update_wm; | 7672 | dev_priv->display.update_wm = g4x_update_wm; |
7307 | else if (IS_GEN4(dev)) | 7673 | dev_priv->display.init_clock_gating = g4x_init_clock_gating; |
7674 | } else if (IS_GEN4(dev)) { | ||
7308 | dev_priv->display.update_wm = i965_update_wm; | 7675 | dev_priv->display.update_wm = i965_update_wm; |
7309 | else if (IS_GEN3(dev)) { | 7676 | if (IS_CRESTLINE(dev)) |
7677 | dev_priv->display.init_clock_gating = crestline_init_clock_gating; | ||
7678 | else if (IS_BROADWATER(dev)) | ||
7679 | dev_priv->display.init_clock_gating = broadwater_init_clock_gating; | ||
7680 | } else if (IS_GEN3(dev)) { | ||
7310 | dev_priv->display.update_wm = i9xx_update_wm; | 7681 | dev_priv->display.update_wm = i9xx_update_wm; |
7311 | dev_priv->display.get_fifo_size = i9xx_get_fifo_size; | 7682 | dev_priv->display.get_fifo_size = i9xx_get_fifo_size; |
7683 | dev_priv->display.init_clock_gating = gen3_init_clock_gating; | ||
7684 | } else if (IS_I865G(dev)) { | ||
7685 | dev_priv->display.update_wm = i830_update_wm; | ||
7686 | dev_priv->display.init_clock_gating = i85x_init_clock_gating; | ||
7687 | dev_priv->display.get_fifo_size = i830_get_fifo_size; | ||
7312 | } else if (IS_I85X(dev)) { | 7688 | } else if (IS_I85X(dev)) { |
7313 | dev_priv->display.update_wm = i9xx_update_wm; | 7689 | dev_priv->display.update_wm = i9xx_update_wm; |
7314 | dev_priv->display.get_fifo_size = i85x_get_fifo_size; | 7690 | dev_priv->display.get_fifo_size = i85x_get_fifo_size; |
7691 | dev_priv->display.init_clock_gating = i85x_init_clock_gating; | ||
7315 | } else { | 7692 | } else { |
7316 | dev_priv->display.update_wm = i830_update_wm; | 7693 | dev_priv->display.update_wm = i830_update_wm; |
7694 | dev_priv->display.init_clock_gating = i830_init_clock_gating; | ||
7317 | if (IS_845G(dev)) | 7695 | if (IS_845G(dev)) |
7318 | dev_priv->display.get_fifo_size = i845_get_fifo_size; | 7696 | dev_priv->display.get_fifo_size = i845_get_fifo_size; |
7319 | else | 7697 | else |
@@ -7439,12 +7817,11 @@ void intel_modeset_init(struct drm_device *dev) | |||
7439 | intel_crtc_init(dev, i); | 7817 | intel_crtc_init(dev, i); |
7440 | } | 7818 | } |
7441 | 7819 | ||
7442 | intel_setup_outputs(dev); | ||
7443 | |||
7444 | intel_enable_clock_gating(dev); | ||
7445 | |||
7446 | /* Just disable it once at startup */ | 7820 | /* Just disable it once at startup */ |
7447 | i915_disable_vga(dev); | 7821 | i915_disable_vga(dev); |
7822 | intel_setup_outputs(dev); | ||
7823 | |||
7824 | intel_init_clock_gating(dev); | ||
7448 | 7825 | ||
7449 | if (IS_IRONLAKE_M(dev)) { | 7826 | if (IS_IRONLAKE_M(dev)) { |
7450 | ironlake_enable_drps(dev); | 7827 | ironlake_enable_drps(dev); |
@@ -7454,12 +7831,15 @@ void intel_modeset_init(struct drm_device *dev) | |||
7454 | if (IS_GEN6(dev)) | 7831 | if (IS_GEN6(dev)) |
7455 | gen6_enable_rps(dev_priv); | 7832 | gen6_enable_rps(dev_priv); |
7456 | 7833 | ||
7457 | if (IS_IRONLAKE_M(dev)) | ||
7458 | ironlake_enable_rc6(dev); | ||
7459 | |||
7460 | INIT_WORK(&dev_priv->idle_work, intel_idle_update); | 7834 | INIT_WORK(&dev_priv->idle_work, intel_idle_update); |
7461 | setup_timer(&dev_priv->idle_timer, intel_gpu_idle_timer, | 7835 | setup_timer(&dev_priv->idle_timer, intel_gpu_idle_timer, |
7462 | (unsigned long)dev); | 7836 | (unsigned long)dev); |
7837 | } | ||
7838 | |||
7839 | void intel_modeset_gem_init(struct drm_device *dev) | ||
7840 | { | ||
7841 | if (IS_IRONLAKE_M(dev)) | ||
7842 | ironlake_enable_rc6(dev); | ||
7463 | 7843 | ||
7464 | intel_setup_overlay(dev); | 7844 | intel_setup_overlay(dev); |
7465 | } | 7845 | } |
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index cb8578b7e443..a4d80314e7f8 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -1470,7 +1470,8 @@ intel_dp_link_down(struct intel_dp *intel_dp) | |||
1470 | 1470 | ||
1471 | if (!HAS_PCH_CPT(dev) && | 1471 | if (!HAS_PCH_CPT(dev) && |
1472 | I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) { | 1472 | I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) { |
1473 | struct intel_crtc *intel_crtc = to_intel_crtc(intel_dp->base.base.crtc); | 1473 | struct drm_crtc *crtc = intel_dp->base.base.crtc; |
1474 | |||
1474 | /* Hardware workaround: leaving our transcoder select | 1475 | /* Hardware workaround: leaving our transcoder select |
1475 | * set to transcoder B while it's off will prevent the | 1476 | * set to transcoder B while it's off will prevent the |
1476 | * corresponding HDMI output on transcoder A. | 1477 | * corresponding HDMI output on transcoder A. |
@@ -1485,7 +1486,19 @@ intel_dp_link_down(struct intel_dp *intel_dp) | |||
1485 | /* Changes to enable or select take place the vblank | 1486 | /* Changes to enable or select take place the vblank |
1486 | * after being written. | 1487 | * after being written. |
1487 | */ | 1488 | */ |
1488 | intel_wait_for_vblank(dev, intel_crtc->pipe); | 1489 | if (crtc == NULL) { |
1490 | /* We can arrive here never having been attached | ||
1491 | * to a CRTC, for instance, due to inheriting | ||
1492 | * random state from the BIOS. | ||
1493 | * | ||
1494 | * If the pipe is not running, play safe and | ||
1495 | * wait for the clocks to stabilise before | ||
1496 | * continuing. | ||
1497 | */ | ||
1498 | POSTING_READ(intel_dp->output_reg); | ||
1499 | msleep(50); | ||
1500 | } else | ||
1501 | intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe); | ||
1489 | } | 1502 | } |
1490 | 1503 | ||
1491 | I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); | 1504 | I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 1d20712d527f..831d7a4a0d18 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -140,7 +140,6 @@ struct intel_fbdev { | |||
140 | struct intel_encoder { | 140 | struct intel_encoder { |
141 | struct drm_encoder base; | 141 | struct drm_encoder base; |
142 | int type; | 142 | int type; |
143 | bool load_detect_temp; | ||
144 | bool needs_tv_clock; | 143 | bool needs_tv_clock; |
145 | void (*hot_plug)(struct intel_encoder *); | 144 | void (*hot_plug)(struct intel_encoder *); |
146 | int crtc_mask; | 145 | int crtc_mask; |
@@ -291,13 +290,19 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, | |||
291 | struct drm_file *file_priv); | 290 | struct drm_file *file_priv); |
292 | extern void intel_wait_for_vblank(struct drm_device *dev, int pipe); | 291 | extern void intel_wait_for_vblank(struct drm_device *dev, int pipe); |
293 | extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe); | 292 | extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe); |
294 | extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_encoder *intel_encoder, | 293 | |
295 | struct drm_connector *connector, | 294 | struct intel_load_detect_pipe { |
296 | struct drm_display_mode *mode, | 295 | struct drm_framebuffer *release_fb; |
297 | int *dpms_mode); | 296 | bool load_detect_temp; |
297 | int dpms_mode; | ||
298 | }; | ||
299 | extern bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder, | ||
300 | struct drm_connector *connector, | ||
301 | struct drm_display_mode *mode, | ||
302 | struct intel_load_detect_pipe *old); | ||
298 | extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder, | 303 | extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder, |
299 | struct drm_connector *connector, | 304 | struct drm_connector *connector, |
300 | int dpms_mode); | 305 | struct intel_load_detect_pipe *old); |
301 | 306 | ||
302 | extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB); | 307 | extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB); |
303 | extern int intel_sdvo_supports_hotplug(struct drm_connector *connector); | 308 | extern int intel_sdvo_supports_hotplug(struct drm_connector *connector); |
@@ -339,4 +344,6 @@ extern int intel_overlay_attrs(struct drm_device *dev, void *data, | |||
339 | 344 | ||
340 | extern void intel_fb_output_poll_changed(struct drm_device *dev); | 345 | extern void intel_fb_output_poll_changed(struct drm_device *dev); |
341 | extern void intel_fb_restore_mode(struct drm_device *dev); | 346 | extern void intel_fb_restore_mode(struct drm_device *dev); |
347 | |||
348 | extern void intel_init_clock_gating(struct drm_device *dev); | ||
342 | #endif /* __INTEL_DRV_H__ */ | 349 | #endif /* __INTEL_DRV_H__ */ |
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index a562bd2648c7..67cb076d271b 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c | |||
@@ -539,6 +539,9 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val, | |||
539 | struct drm_device *dev = dev_priv->dev; | 539 | struct drm_device *dev = dev_priv->dev; |
540 | struct drm_connector *connector = dev_priv->int_lvds_connector; | 540 | struct drm_connector *connector = dev_priv->int_lvds_connector; |
541 | 541 | ||
542 | if (dev->switch_power_state != DRM_SWITCH_POWER_ON) | ||
543 | return NOTIFY_OK; | ||
544 | |||
542 | /* | 545 | /* |
543 | * check and update the status of LVDS connector after receiving | 546 | * check and update the status of LVDS connector after receiving |
544 | * the LID nofication event. | 547 | * the LID nofication event. |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index e9e6f71418a4..3971b5e6ad60 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -236,7 +236,7 @@ init_pipe_control(struct intel_ring_buffer *ring) | |||
236 | ret = -ENOMEM; | 236 | ret = -ENOMEM; |
237 | goto err; | 237 | goto err; |
238 | } | 238 | } |
239 | obj->agp_type = AGP_USER_CACHED_MEMORY; | 239 | obj->cache_level = I915_CACHE_LLC; |
240 | 240 | ||
241 | ret = i915_gem_object_pin(obj, 4096, true); | 241 | ret = i915_gem_object_pin(obj, 4096, true); |
242 | if (ret) | 242 | if (ret) |
@@ -286,7 +286,7 @@ static int init_render_ring(struct intel_ring_buffer *ring) | |||
286 | 286 | ||
287 | if (INTEL_INFO(dev)->gen > 3) { | 287 | if (INTEL_INFO(dev)->gen > 3) { |
288 | int mode = VS_TIMER_DISPATCH << 16 | VS_TIMER_DISPATCH; | 288 | int mode = VS_TIMER_DISPATCH << 16 | VS_TIMER_DISPATCH; |
289 | if (IS_GEN6(dev)) | 289 | if (IS_GEN6(dev) || IS_GEN7(dev)) |
290 | mode |= MI_FLUSH_ENABLE << 16 | MI_FLUSH_ENABLE; | 290 | mode |= MI_FLUSH_ENABLE << 16 | MI_FLUSH_ENABLE; |
291 | I915_WRITE(MI_MODE, mode); | 291 | I915_WRITE(MI_MODE, mode); |
292 | } | 292 | } |
@@ -551,10 +551,31 @@ render_ring_put_irq(struct intel_ring_buffer *ring) | |||
551 | 551 | ||
552 | void intel_ring_setup_status_page(struct intel_ring_buffer *ring) | 552 | void intel_ring_setup_status_page(struct intel_ring_buffer *ring) |
553 | { | 553 | { |
554 | struct drm_device *dev = ring->dev; | ||
554 | drm_i915_private_t *dev_priv = ring->dev->dev_private; | 555 | drm_i915_private_t *dev_priv = ring->dev->dev_private; |
555 | u32 mmio = IS_GEN6(ring->dev) ? | 556 | u32 mmio = 0; |
556 | RING_HWS_PGA_GEN6(ring->mmio_base) : | 557 | |
557 | RING_HWS_PGA(ring->mmio_base); | 558 | /* The ring status page addresses are no longer next to the rest of |
559 | * the ring registers as of gen7. | ||
560 | */ | ||
561 | if (IS_GEN7(dev)) { | ||
562 | switch (ring->id) { | ||
563 | case RING_RENDER: | ||
564 | mmio = RENDER_HWS_PGA_GEN7; | ||
565 | break; | ||
566 | case RING_BLT: | ||
567 | mmio = BLT_HWS_PGA_GEN7; | ||
568 | break; | ||
569 | case RING_BSD: | ||
570 | mmio = BSD_HWS_PGA_GEN7; | ||
571 | break; | ||
572 | } | ||
573 | } else if (IS_GEN6(ring->dev)) { | ||
574 | mmio = RING_HWS_PGA_GEN6(ring->mmio_base); | ||
575 | } else { | ||
576 | mmio = RING_HWS_PGA(ring->mmio_base); | ||
577 | } | ||
578 | |||
558 | I915_WRITE(mmio, (u32)ring->status_page.gfx_addr); | 579 | I915_WRITE(mmio, (u32)ring->status_page.gfx_addr); |
559 | POSTING_READ(mmio); | 580 | POSTING_READ(mmio); |
560 | } | 581 | } |
@@ -759,7 +780,7 @@ static int init_status_page(struct intel_ring_buffer *ring) | |||
759 | ret = -ENOMEM; | 780 | ret = -ENOMEM; |
760 | goto err; | 781 | goto err; |
761 | } | 782 | } |
762 | obj->agp_type = AGP_USER_CACHED_MEMORY; | 783 | obj->cache_level = I915_CACHE_LLC; |
763 | 784 | ||
764 | ret = i915_gem_object_pin(obj, 4096, true); | 785 | ret = i915_gem_object_pin(obj, 4096, true); |
765 | if (ret != 0) { | 786 | if (ret != 0) { |
@@ -800,6 +821,7 @@ int intel_init_ring_buffer(struct drm_device *dev, | |||
800 | INIT_LIST_HEAD(&ring->request_list); | 821 | INIT_LIST_HEAD(&ring->request_list); |
801 | INIT_LIST_HEAD(&ring->gpu_write_list); | 822 | INIT_LIST_HEAD(&ring->gpu_write_list); |
802 | 823 | ||
824 | init_waitqueue_head(&ring->irq_queue); | ||
803 | spin_lock_init(&ring->irq_lock); | 825 | spin_lock_init(&ring->irq_lock); |
804 | ring->irq_mask = ~0; | 826 | ring->irq_mask = ~0; |
805 | 827 | ||
@@ -872,7 +894,7 @@ void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring) | |||
872 | 894 | ||
873 | /* Disable the ring buffer. The ring must be idle at this point */ | 895 | /* Disable the ring buffer. The ring must be idle at this point */ |
874 | dev_priv = ring->dev->dev_private; | 896 | dev_priv = ring->dev->dev_private; |
875 | ret = intel_wait_ring_buffer(ring, ring->size - 8); | 897 | ret = intel_wait_ring_idle(ring); |
876 | if (ret) | 898 | if (ret) |
877 | DRM_ERROR("failed to quiesce %s whilst cleaning up: %d\n", | 899 | DRM_ERROR("failed to quiesce %s whilst cleaning up: %d\n", |
878 | ring->name, ret); | 900 | ring->name, ret); |
@@ -1333,7 +1355,7 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev) | |||
1333 | drm_i915_private_t *dev_priv = dev->dev_private; | 1355 | drm_i915_private_t *dev_priv = dev->dev_private; |
1334 | struct intel_ring_buffer *ring = &dev_priv->ring[VCS]; | 1356 | struct intel_ring_buffer *ring = &dev_priv->ring[VCS]; |
1335 | 1357 | ||
1336 | if (IS_GEN6(dev)) | 1358 | if (IS_GEN6(dev) || IS_GEN7(dev)) |
1337 | *ring = gen6_bsd_ring; | 1359 | *ring = gen6_bsd_ring; |
1338 | else | 1360 | else |
1339 | *ring = bsd_ring; | 1361 | *ring = bsd_ring; |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index f23cc5f037a6..c0e0ee63fbf4 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h | |||
@@ -14,27 +14,24 @@ struct intel_hw_status_page { | |||
14 | struct drm_i915_gem_object *obj; | 14 | struct drm_i915_gem_object *obj; |
15 | }; | 15 | }; |
16 | 16 | ||
17 | #define I915_RING_READ(reg) i915_gt_read(dev_priv, reg) | 17 | #define I915_READ_TAIL(ring) I915_READ(RING_TAIL((ring)->mmio_base)) |
18 | #define I915_RING_WRITE(reg, val) i915_gt_write(dev_priv, reg, val) | 18 | #define I915_WRITE_TAIL(ring, val) I915_WRITE(RING_TAIL((ring)->mmio_base), val) |
19 | 19 | ||
20 | #define I915_READ_TAIL(ring) I915_RING_READ(RING_TAIL((ring)->mmio_base)) | 20 | #define I915_READ_START(ring) I915_READ(RING_START((ring)->mmio_base)) |
21 | #define I915_WRITE_TAIL(ring, val) I915_RING_WRITE(RING_TAIL((ring)->mmio_base), val) | 21 | #define I915_WRITE_START(ring, val) I915_WRITE(RING_START((ring)->mmio_base), val) |
22 | 22 | ||
23 | #define I915_READ_START(ring) I915_RING_READ(RING_START((ring)->mmio_base)) | 23 | #define I915_READ_HEAD(ring) I915_READ(RING_HEAD((ring)->mmio_base)) |
24 | #define I915_WRITE_START(ring, val) I915_RING_WRITE(RING_START((ring)->mmio_base), val) | 24 | #define I915_WRITE_HEAD(ring, val) I915_WRITE(RING_HEAD((ring)->mmio_base), val) |
25 | 25 | ||
26 | #define I915_READ_HEAD(ring) I915_RING_READ(RING_HEAD((ring)->mmio_base)) | 26 | #define I915_READ_CTL(ring) I915_READ(RING_CTL((ring)->mmio_base)) |
27 | #define I915_WRITE_HEAD(ring, val) I915_RING_WRITE(RING_HEAD((ring)->mmio_base), val) | 27 | #define I915_WRITE_CTL(ring, val) I915_WRITE(RING_CTL((ring)->mmio_base), val) |
28 | 28 | ||
29 | #define I915_READ_CTL(ring) I915_RING_READ(RING_CTL((ring)->mmio_base)) | 29 | #define I915_READ_IMR(ring) I915_READ(RING_IMR((ring)->mmio_base)) |
30 | #define I915_WRITE_CTL(ring, val) I915_RING_WRITE(RING_CTL((ring)->mmio_base), val) | 30 | #define I915_WRITE_IMR(ring, val) I915_WRITE(RING_IMR((ring)->mmio_base), val) |
31 | 31 | ||
32 | #define I915_READ_IMR(ring) I915_RING_READ(RING_IMR((ring)->mmio_base)) | 32 | #define I915_READ_NOPID(ring) I915_READ(RING_NOPID((ring)->mmio_base)) |
33 | #define I915_WRITE_IMR(ring, val) I915_RING_WRITE(RING_IMR((ring)->mmio_base), val) | 33 | #define I915_READ_SYNC_0(ring) I915_READ(RING_SYNC_0((ring)->mmio_base)) |
34 | 34 | #define I915_READ_SYNC_1(ring) I915_READ(RING_SYNC_1((ring)->mmio_base)) | |
35 | #define I915_READ_NOPID(ring) I915_RING_READ(RING_NOPID((ring)->mmio_base)) | ||
36 | #define I915_READ_SYNC_0(ring) I915_RING_READ(RING_SYNC_0((ring)->mmio_base)) | ||
37 | #define I915_READ_SYNC_1(ring) I915_RING_READ(RING_SYNC_1((ring)->mmio_base)) | ||
38 | 35 | ||
39 | struct intel_ring_buffer { | 36 | struct intel_ring_buffer { |
40 | const char *name; | 37 | const char *name; |
@@ -164,7 +161,13 @@ intel_read_status_page(struct intel_ring_buffer *ring, | |||
164 | #define I915_BREADCRUMB_INDEX 0x21 | 161 | #define I915_BREADCRUMB_INDEX 0x21 |
165 | 162 | ||
166 | void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring); | 163 | void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring); |
164 | |||
167 | int __must_check intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n); | 165 | int __must_check intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n); |
166 | static inline int intel_wait_ring_idle(struct intel_ring_buffer *ring) | ||
167 | { | ||
168 | return intel_wait_ring_buffer(ring, ring->space - 8); | ||
169 | } | ||
170 | |||
168 | int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n); | 171 | int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n); |
169 | 172 | ||
170 | static inline void intel_ring_emit(struct intel_ring_buffer *ring, | 173 | static inline void intel_ring_emit(struct intel_ring_buffer *ring, |
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c index 6b22c1dcc015..113e4e7264cd 100644 --- a/drivers/gpu/drm/i915/intel_tv.c +++ b/drivers/gpu/drm/i915/intel_tv.c | |||
@@ -1361,15 +1361,14 @@ intel_tv_detect(struct drm_connector *connector, bool force) | |||
1361 | if (intel_tv->base.base.crtc && intel_tv->base.base.crtc->enabled) { | 1361 | if (intel_tv->base.base.crtc && intel_tv->base.base.crtc->enabled) { |
1362 | type = intel_tv_detect_type(intel_tv, connector); | 1362 | type = intel_tv_detect_type(intel_tv, connector); |
1363 | } else if (force) { | 1363 | } else if (force) { |
1364 | struct drm_crtc *crtc; | 1364 | struct intel_load_detect_pipe tmp; |
1365 | int dpms_mode; | ||
1366 | 1365 | ||
1367 | crtc = intel_get_load_detect_pipe(&intel_tv->base, connector, | 1366 | if (intel_get_load_detect_pipe(&intel_tv->base, connector, |
1368 | &mode, &dpms_mode); | 1367 | &mode, &tmp)) { |
1369 | if (crtc) { | ||
1370 | type = intel_tv_detect_type(intel_tv, connector); | 1368 | type = intel_tv_detect_type(intel_tv, connector); |
1371 | intel_release_load_detect_pipe(&intel_tv->base, connector, | 1369 | intel_release_load_detect_pipe(&intel_tv->base, |
1372 | dpms_mode); | 1370 | connector, |
1371 | &tmp); | ||
1373 | } else | 1372 | } else |
1374 | return connector_status_unknown; | 1373 | return connector_status_unknown; |
1375 | } else | 1374 | } else |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index e9bc135d9189..c20eac3379e6 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -862,9 +862,15 @@ int evergreen_pcie_gart_enable(struct radeon_device *rdev) | |||
862 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | | 862 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
863 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | | 863 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | |
864 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); | 864 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); |
865 | WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); | 865 | if (rdev->flags & RADEON_IS_IGP) { |
866 | WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); | 866 | WREG32(FUS_MC_VM_MD_L1_TLB0_CNTL, tmp); |
867 | WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); | 867 | WREG32(FUS_MC_VM_MD_L1_TLB1_CNTL, tmp); |
868 | WREG32(FUS_MC_VM_MD_L1_TLB2_CNTL, tmp); | ||
869 | } else { | ||
870 | WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); | ||
871 | WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); | ||
872 | WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); | ||
873 | } | ||
868 | WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); | 874 | WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); |
869 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); | 875 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); |
870 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); | 876 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); |
@@ -2923,11 +2929,6 @@ static int evergreen_startup(struct radeon_device *rdev) | |||
2923 | rdev->asic->copy = NULL; | 2929 | rdev->asic->copy = NULL; |
2924 | dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r); | 2930 | dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r); |
2925 | } | 2931 | } |
2926 | /* XXX: ontario has problems blitting to gart at the moment */ | ||
2927 | if (rdev->family == CHIP_PALM) { | ||
2928 | rdev->asic->copy = NULL; | ||
2929 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); | ||
2930 | } | ||
2931 | 2932 | ||
2932 | /* allocate wb buffer */ | 2933 | /* allocate wb buffer */ |
2933 | r = radeon_wb_init(rdev); | 2934 | r = radeon_wb_init(rdev); |
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h index 9aaa3f0c9372..94533849927e 100644 --- a/drivers/gpu/drm/radeon/evergreend.h +++ b/drivers/gpu/drm/radeon/evergreend.h | |||
@@ -221,6 +221,11 @@ | |||
221 | #define MC_VM_MD_L1_TLB0_CNTL 0x2654 | 221 | #define MC_VM_MD_L1_TLB0_CNTL 0x2654 |
222 | #define MC_VM_MD_L1_TLB1_CNTL 0x2658 | 222 | #define MC_VM_MD_L1_TLB1_CNTL 0x2658 |
223 | #define MC_VM_MD_L1_TLB2_CNTL 0x265C | 223 | #define MC_VM_MD_L1_TLB2_CNTL 0x265C |
224 | |||
225 | #define FUS_MC_VM_MD_L1_TLB0_CNTL 0x265C | ||
226 | #define FUS_MC_VM_MD_L1_TLB1_CNTL 0x2660 | ||
227 | #define FUS_MC_VM_MD_L1_TLB2_CNTL 0x2664 | ||
228 | |||
224 | #define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C | 229 | #define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C |
225 | #define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038 | 230 | #define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038 |
226 | #define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034 | 231 | #define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034 |
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index f5d12fb103fa..f116516bfef7 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c | |||
@@ -1599,9 +1599,10 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct | |||
1599 | memcpy((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0], | 1599 | memcpy((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0], |
1600 | fake_edid_record->ucFakeEDIDLength); | 1600 | fake_edid_record->ucFakeEDIDLength); |
1601 | 1601 | ||
1602 | if (drm_edid_is_valid(edid)) | 1602 | if (drm_edid_is_valid(edid)) { |
1603 | rdev->mode_info.bios_hardcoded_edid = edid; | 1603 | rdev->mode_info.bios_hardcoded_edid = edid; |
1604 | else | 1604 | rdev->mode_info.bios_hardcoded_edid_size = edid_size; |
1605 | } else | ||
1605 | kfree(edid); | 1606 | kfree(edid); |
1606 | } | 1607 | } |
1607 | } | 1608 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 871df0376b1c..bd58af658581 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -234,6 +234,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
234 | return -EINVAL; | 234 | return -EINVAL; |
235 | } | 235 | } |
236 | break; | 236 | break; |
237 | case RADEON_INFO_FUSION_GART_WORKING: | ||
238 | value = 1; | ||
239 | break; | ||
237 | default: | 240 | default: |
238 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); | 241 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
239 | return -EINVAL; | 242 | return -EINVAL; |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 060ef6327876..50e40dbd8bb6 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -110,8 +110,7 @@ config SENSORS_ADM1021 | |||
110 | help | 110 | help |
111 | If you say yes here you get support for Analog Devices ADM1021 | 111 | If you say yes here you get support for Analog Devices ADM1021 |
112 | and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A, | 112 | and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A, |
113 | Genesys Logic GL523SM, National Semiconductor LM84, TI THMC10, | 113 | Genesys Logic GL523SM, National Semiconductor LM84 and TI THMC10. |
114 | and the XEON processor built-in sensor. | ||
115 | 114 | ||
116 | This driver can also be built as a module. If so, the module | 115 | This driver can also be built as a module. If so, the module |
117 | will be called adm1021. | 116 | will be called adm1021. |
@@ -618,10 +617,10 @@ config SENSORS_LM90 | |||
618 | depends on I2C | 617 | depends on I2C |
619 | help | 618 | help |
620 | If you say yes here you get support for National Semiconductor LM90, | 619 | If you say yes here you get support for National Semiconductor LM90, |
621 | LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, Maxim | 620 | LM86, LM89 and LM99, Analog Devices ADM1032, ADT7461, and ADT7461A, |
622 | MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, | 621 | Maxim MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, |
623 | MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, and Winbond/Nuvoton | 622 | MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, ON Semiconductor NCT1008, |
624 | W83L771W/G/AWG/ASG sensor chips. | 623 | and Winbond/Nuvoton W83L771W/G/AWG/ASG sensor chips. |
625 | 624 | ||
626 | This driver can also be built as a module. If so, the module | 625 | This driver can also be built as a module. If so, the module |
627 | will be called lm90. | 626 | will be called lm90. |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 250d099ca398..da72dc12068c 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -1094,6 +1094,7 @@ static struct attribute *lm85_attributes_minctl[] = { | |||
1094 | &sensor_dev_attr_pwm1_auto_pwm_minctl.dev_attr.attr, | 1094 | &sensor_dev_attr_pwm1_auto_pwm_minctl.dev_attr.attr, |
1095 | &sensor_dev_attr_pwm2_auto_pwm_minctl.dev_attr.attr, | 1095 | &sensor_dev_attr_pwm2_auto_pwm_minctl.dev_attr.attr, |
1096 | &sensor_dev_attr_pwm3_auto_pwm_minctl.dev_attr.attr, | 1096 | &sensor_dev_attr_pwm3_auto_pwm_minctl.dev_attr.attr, |
1097 | NULL | ||
1097 | }; | 1098 | }; |
1098 | 1099 | ||
1099 | static const struct attribute_group lm85_group_minctl = { | 1100 | static const struct attribute_group lm85_group_minctl = { |
@@ -1104,6 +1105,7 @@ static struct attribute *lm85_attributes_temp_off[] = { | |||
1104 | &sensor_dev_attr_temp1_auto_temp_off.dev_attr.attr, | 1105 | &sensor_dev_attr_temp1_auto_temp_off.dev_attr.attr, |
1105 | &sensor_dev_attr_temp2_auto_temp_off.dev_attr.attr, | 1106 | &sensor_dev_attr_temp2_auto_temp_off.dev_attr.attr, |
1106 | &sensor_dev_attr_temp3_auto_temp_off.dev_attr.attr, | 1107 | &sensor_dev_attr_temp3_auto_temp_off.dev_attr.attr, |
1108 | NULL | ||
1107 | }; | 1109 | }; |
1108 | 1110 | ||
1109 | static const struct attribute_group lm85_group_temp_off = { | 1111 | static const struct attribute_group lm85_group_temp_off = { |
@@ -1329,11 +1331,11 @@ static int lm85_probe(struct i2c_client *client, | |||
1329 | if (data->type != emc6d103s) { | 1331 | if (data->type != emc6d103s) { |
1330 | err = sysfs_create_group(&client->dev.kobj, &lm85_group_minctl); | 1332 | err = sysfs_create_group(&client->dev.kobj, &lm85_group_minctl); |
1331 | if (err) | 1333 | if (err) |
1332 | goto err_kfree; | 1334 | goto err_remove_files; |
1333 | err = sysfs_create_group(&client->dev.kobj, | 1335 | err = sysfs_create_group(&client->dev.kobj, |
1334 | &lm85_group_temp_off); | 1336 | &lm85_group_temp_off); |
1335 | if (err) | 1337 | if (err) |
1336 | goto err_kfree; | 1338 | goto err_remove_files; |
1337 | } | 1339 | } |
1338 | 1340 | ||
1339 | /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used | 1341 | /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index c43b4e9f96a9..2f94f9504804 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -49,10 +49,10 @@ | |||
49 | * chips, but support three temperature sensors instead of two. MAX6695 | 49 | * chips, but support three temperature sensors instead of two. MAX6695 |
50 | * and MAX6696 only differ in the pinout so they can be treated identically. | 50 | * and MAX6696 only differ in the pinout so they can be treated identically. |
51 | * | 51 | * |
52 | * This driver also supports the ADT7461 chip from Analog Devices. | 52 | * This driver also supports ADT7461 and ADT7461A from Analog Devices as well as |
53 | * It's supported in both compatibility and extended mode. It is mostly | 53 | * NCT1008 from ON Semiconductor. The chips are supported in both compatibility |
54 | * compatible with LM90 except for a data format difference for the | 54 | * and extended mode. They are mostly compatible with LM90 except for a data |
55 | * temperature value registers. | 55 | * format difference for the temperature value registers. |
56 | * | 56 | * |
57 | * Since the LM90 was the first chipset supported by this driver, most | 57 | * Since the LM90 was the first chipset supported by this driver, most |
58 | * comments will refer to this chipset, but are actually general and | 58 | * comments will refer to this chipset, but are actually general and |
@@ -88,9 +88,10 @@ | |||
88 | * Addresses to scan | 88 | * Addresses to scan |
89 | * Address is fully defined internally and cannot be changed except for | 89 | * Address is fully defined internally and cannot be changed except for |
90 | * MAX6659, MAX6680 and MAX6681. | 90 | * MAX6659, MAX6680 and MAX6681. |
91 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6649, MAX6657, | 91 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, ADT7461A, MAX6649, |
92 | * MAX6658 and W83L771 have address 0x4c. | 92 | * MAX6657, MAX6658, NCT1008 and W83L771 have address 0x4c. |
93 | * ADM1032-2, ADT7461-2, LM89-1, LM99-1 and MAX6646 have address 0x4d. | 93 | * ADM1032-2, ADT7461-2, ADT7461A-2, LM89-1, LM99-1, MAX6646, and NCT1008D |
94 | * have address 0x4d. | ||
94 | * MAX6647 has address 0x4e. | 95 | * MAX6647 has address 0x4e. |
95 | * MAX6659 can have address 0x4c, 0x4d or 0x4e. | 96 | * MAX6659 can have address 0x4c, 0x4d or 0x4e. |
96 | * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, | 97 | * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, |
@@ -174,6 +175,7 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, | |||
174 | static const struct i2c_device_id lm90_id[] = { | 175 | static const struct i2c_device_id lm90_id[] = { |
175 | { "adm1032", adm1032 }, | 176 | { "adm1032", adm1032 }, |
176 | { "adt7461", adt7461 }, | 177 | { "adt7461", adt7461 }, |
178 | { "adt7461a", adt7461 }, | ||
177 | { "lm90", lm90 }, | 179 | { "lm90", lm90 }, |
178 | { "lm86", lm86 }, | 180 | { "lm86", lm86 }, |
179 | { "lm89", lm86 }, | 181 | { "lm89", lm86 }, |
@@ -188,6 +190,7 @@ static const struct i2c_device_id lm90_id[] = { | |||
188 | { "max6681", max6680 }, | 190 | { "max6681", max6680 }, |
189 | { "max6695", max6696 }, | 191 | { "max6695", max6696 }, |
190 | { "max6696", max6696 }, | 192 | { "max6696", max6696 }, |
193 | { "nct1008", adt7461 }, | ||
191 | { "w83l771", w83l771 }, | 194 | { "w83l771", w83l771 }, |
192 | { } | 195 | { } |
193 | }; | 196 | }; |
@@ -1153,6 +1156,11 @@ static int lm90_detect(struct i2c_client *new_client, | |||
1153 | && (reg_config1 & 0x1B) == 0x00 | 1156 | && (reg_config1 & 0x1B) == 0x00 |
1154 | && reg_convrate <= 0x0A) { | 1157 | && reg_convrate <= 0x0A) { |
1155 | name = "adt7461"; | 1158 | name = "adt7461"; |
1159 | } else | ||
1160 | if (chip_id == 0x57 /* ADT7461A, NCT1008 */ | ||
1161 | && (reg_config1 & 0x1B) == 0x00 | ||
1162 | && reg_convrate <= 0x0A) { | ||
1163 | name = "adt7461a"; | ||
1156 | } | 1164 | } |
1157 | } else | 1165 | } else |
1158 | if (man_id == 0x4D) { /* Maxim */ | 1166 | if (man_id == 0x4D) { /* Maxim */ |
diff --git a/drivers/hwmon/twl4030-madc-hwmon.c b/drivers/hwmon/twl4030-madc-hwmon.c index de5819199e2e..57240740b161 100644 --- a/drivers/hwmon/twl4030-madc-hwmon.c +++ b/drivers/hwmon/twl4030-madc-hwmon.c | |||
@@ -98,7 +98,6 @@ static const struct attribute_group twl4030_madc_group = { | |||
98 | static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev) | 98 | static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev) |
99 | { | 99 | { |
100 | int ret; | 100 | int ret; |
101 | int status; | ||
102 | struct device *hwmon; | 101 | struct device *hwmon; |
103 | 102 | ||
104 | ret = sysfs_create_group(&pdev->dev.kobj, &twl4030_madc_group); | 103 | ret = sysfs_create_group(&pdev->dev.kobj, &twl4030_madc_group); |
@@ -107,7 +106,7 @@ static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev) | |||
107 | hwmon = hwmon_device_register(&pdev->dev); | 106 | hwmon = hwmon_device_register(&pdev->dev); |
108 | if (IS_ERR(hwmon)) { | 107 | if (IS_ERR(hwmon)) { |
109 | dev_err(&pdev->dev, "hwmon_device_register failed.\n"); | 108 | dev_err(&pdev->dev, "hwmon_device_register failed.\n"); |
110 | status = PTR_ERR(hwmon); | 109 | ret = PTR_ERR(hwmon); |
111 | goto err_reg; | 110 | goto err_reg; |
112 | } | 111 | } |
113 | 112 | ||
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 72c0415f6f94..455e909bc768 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -134,10 +134,15 @@ | |||
134 | SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \ | 134 | SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \ |
135 | SMBHSTSTS_INTR) | 135 | SMBHSTSTS_INTR) |
136 | 136 | ||
137 | /* Older devices have their ID defined in <linux/pci_ids.h> */ | ||
138 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22 | ||
139 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS 0x1d22 | ||
137 | /* Patsburg also has three 'Integrated Device Function' SMBus controllers */ | 140 | /* Patsburg also has three 'Integrated Device Function' SMBus controllers */ |
138 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70 | 141 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70 |
139 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71 | 142 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71 |
140 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72 | 143 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72 |
144 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330 | ||
145 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 | ||
141 | 146 | ||
142 | struct i801_priv { | 147 | struct i801_priv { |
143 | struct i2c_adapter adapter; | 148 | struct i2c_adapter adapter; |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 0eb1515541e7..2dbba163b102 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ------------------------------------------------------------------------ * | 1 | /* ------------------------------------------------------------------------ * |
2 | * i2c-parport.c I2C bus over parallel port * | 2 | * i2c-parport.c I2C bus over parallel port * |
3 | * ------------------------------------------------------------------------ * | 3 | * ------------------------------------------------------------------------ * |
4 | Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> | 4 | Copyright (C) 2003-2011 Jean Delvare <khali@linux-fr.org> |
5 | 5 | ||
6 | Based on older i2c-philips-par.c driver | 6 | Based on older i2c-philips-par.c driver |
7 | Copyright (C) 1995-2000 Simon G. Vogl | 7 | Copyright (C) 1995-2000 Simon G. Vogl |
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/i2c-algo-bit.h> | 33 | #include <linux/i2c-algo-bit.h> |
34 | #include <linux/i2c-smbus.h> | 34 | #include <linux/i2c-smbus.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/list.h> | ||
37 | #include <linux/mutex.h> | ||
36 | #include "i2c-parport.h" | 38 | #include "i2c-parport.h" |
37 | 39 | ||
38 | /* ----- Device list ------------------------------------------------------ */ | 40 | /* ----- Device list ------------------------------------------------------ */ |
@@ -43,10 +45,11 @@ struct i2c_par { | |||
43 | struct i2c_algo_bit_data algo_data; | 45 | struct i2c_algo_bit_data algo_data; |
44 | struct i2c_smbus_alert_setup alert_data; | 46 | struct i2c_smbus_alert_setup alert_data; |
45 | struct i2c_client *ara; | 47 | struct i2c_client *ara; |
46 | struct i2c_par *next; | 48 | struct list_head node; |
47 | }; | 49 | }; |
48 | 50 | ||
49 | static struct i2c_par *adapter_list; | 51 | static LIST_HEAD(adapter_list); |
52 | static DEFINE_MUTEX(adapter_list_lock); | ||
50 | 53 | ||
51 | /* ----- Low-level parallel port access ----------------------------------- */ | 54 | /* ----- Low-level parallel port access ----------------------------------- */ |
52 | 55 | ||
@@ -228,8 +231,9 @@ static void i2c_parport_attach (struct parport *port) | |||
228 | } | 231 | } |
229 | 232 | ||
230 | /* Add the new adapter to the list */ | 233 | /* Add the new adapter to the list */ |
231 | adapter->next = adapter_list; | 234 | mutex_lock(&adapter_list_lock); |
232 | adapter_list = adapter; | 235 | list_add_tail(&adapter->node, &adapter_list); |
236 | mutex_unlock(&adapter_list_lock); | ||
233 | return; | 237 | return; |
234 | 238 | ||
235 | ERROR1: | 239 | ERROR1: |
@@ -241,11 +245,11 @@ ERROR0: | |||
241 | 245 | ||
242 | static void i2c_parport_detach (struct parport *port) | 246 | static void i2c_parport_detach (struct parport *port) |
243 | { | 247 | { |
244 | struct i2c_par *adapter, *prev; | 248 | struct i2c_par *adapter, *_n; |
245 | 249 | ||
246 | /* Walk the list */ | 250 | /* Walk the list */ |
247 | for (prev = NULL, adapter = adapter_list; adapter; | 251 | mutex_lock(&adapter_list_lock); |
248 | prev = adapter, adapter = adapter->next) { | 252 | list_for_each_entry_safe(adapter, _n, &adapter_list, node) { |
249 | if (adapter->pdev->port == port) { | 253 | if (adapter->pdev->port == port) { |
250 | if (adapter->ara) { | 254 | if (adapter->ara) { |
251 | parport_disable_irq(port); | 255 | parport_disable_irq(port); |
@@ -259,14 +263,11 @@ static void i2c_parport_detach (struct parport *port) | |||
259 | 263 | ||
260 | parport_release(adapter->pdev); | 264 | parport_release(adapter->pdev); |
261 | parport_unregister_device(adapter->pdev); | 265 | parport_unregister_device(adapter->pdev); |
262 | if (prev) | 266 | list_del(&adapter->node); |
263 | prev->next = adapter->next; | ||
264 | else | ||
265 | adapter_list = adapter->next; | ||
266 | kfree(adapter); | 267 | kfree(adapter); |
267 | return; | ||
268 | } | 268 | } |
269 | } | 269 | } |
270 | mutex_unlock(&adapter_list_lock); | ||
270 | } | 271 | } |
271 | 272 | ||
272 | static struct parport_driver i2c_parport_driver = { | 273 | static struct parport_driver i2c_parport_driver = { |
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c index 7de4b7ebffc5..d8ca0a0b970d 100644 --- a/drivers/infiniband/hw/qib/qib_iba6120.c +++ b/drivers/infiniband/hw/qib/qib_iba6120.c | |||
@@ -1799,7 +1799,7 @@ static int qib_6120_setup_reset(struct qib_devdata *dd) | |||
1799 | /* | 1799 | /* |
1800 | * Keep chip from being accessed until we are ready. Use | 1800 | * Keep chip from being accessed until we are ready. Use |
1801 | * writeq() directly, to allow the write even though QIB_PRESENT | 1801 | * writeq() directly, to allow the write even though QIB_PRESENT |
1802 | * isn't' set. | 1802 | * isn't set. |
1803 | */ | 1803 | */ |
1804 | dd->flags &= ~(QIB_INITTED | QIB_PRESENT); | 1804 | dd->flags &= ~(QIB_INITTED | QIB_PRESENT); |
1805 | dd->int_counter = 0; /* so we check interrupts work again */ | 1805 | dd->int_counter = 0; /* so we check interrupts work again */ |
diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c index 74fe0360bec7..c765a2eb04cf 100644 --- a/drivers/infiniband/hw/qib/qib_iba7220.c +++ b/drivers/infiniband/hw/qib/qib_iba7220.c | |||
@@ -2111,7 +2111,7 @@ static int qib_setup_7220_reset(struct qib_devdata *dd) | |||
2111 | /* | 2111 | /* |
2112 | * Keep chip from being accessed until we are ready. Use | 2112 | * Keep chip from being accessed until we are ready. Use |
2113 | * writeq() directly, to allow the write even though QIB_PRESENT | 2113 | * writeq() directly, to allow the write even though QIB_PRESENT |
2114 | * isn't' set. | 2114 | * isn't set. |
2115 | */ | 2115 | */ |
2116 | dd->flags &= ~(QIB_INITTED | QIB_PRESENT); | 2116 | dd->flags &= ~(QIB_INITTED | QIB_PRESENT); |
2117 | dd->int_counter = 0; /* so we check interrupts work again */ | 2117 | dd->int_counter = 0; /* so we check interrupts work again */ |
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index 55de3cf3441c..6bab3eaea70f 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c | |||
@@ -3299,7 +3299,7 @@ static int qib_do_7322_reset(struct qib_devdata *dd) | |||
3299 | /* | 3299 | /* |
3300 | * Keep chip from being accessed until we are ready. Use | 3300 | * Keep chip from being accessed until we are ready. Use |
3301 | * writeq() directly, to allow the write even though QIB_PRESENT | 3301 | * writeq() directly, to allow the write even though QIB_PRESENT |
3302 | * isn't' set. | 3302 | * isn't set. |
3303 | */ | 3303 | */ |
3304 | dd->flags &= ~(QIB_INITTED | QIB_PRESENT | QIB_BADINTR); | 3304 | dd->flags &= ~(QIB_INITTED | QIB_PRESENT | QIB_BADINTR); |
3305 | dd->flags |= QIB_DOING_RESET; | 3305 | dd->flags |= QIB_DOING_RESET; |
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c index 6ae054f8e0aa..9175d49d2546 100644 --- a/drivers/input/touchscreen/wm831x-ts.c +++ b/drivers/input/touchscreen/wm831x-ts.c | |||
@@ -68,8 +68,23 @@ struct wm831x_ts { | |||
68 | unsigned int pd_irq; | 68 | unsigned int pd_irq; |
69 | bool pressure; | 69 | bool pressure; |
70 | bool pen_down; | 70 | bool pen_down; |
71 | struct work_struct pd_data_work; | ||
71 | }; | 72 | }; |
72 | 73 | ||
74 | static void wm831x_pd_data_work(struct work_struct *work) | ||
75 | { | ||
76 | struct wm831x_ts *wm831x_ts = | ||
77 | container_of(work, struct wm831x_ts, pd_data_work); | ||
78 | |||
79 | if (wm831x_ts->pen_down) { | ||
80 | enable_irq(wm831x_ts->data_irq); | ||
81 | dev_dbg(wm831x_ts->wm831x->dev, "IRQ PD->DATA done\n"); | ||
82 | } else { | ||
83 | enable_irq(wm831x_ts->pd_irq); | ||
84 | dev_dbg(wm831x_ts->wm831x->dev, "IRQ DATA->PD done\n"); | ||
85 | } | ||
86 | } | ||
87 | |||
73 | static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) | 88 | static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) |
74 | { | 89 | { |
75 | struct wm831x_ts *wm831x_ts = irq_data; | 90 | struct wm831x_ts *wm831x_ts = irq_data; |
@@ -110,6 +125,9 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) | |||
110 | } | 125 | } |
111 | 126 | ||
112 | if (!wm831x_ts->pen_down) { | 127 | if (!wm831x_ts->pen_down) { |
128 | /* Switch from data to pen down */ | ||
129 | dev_dbg(wm831x->dev, "IRQ DATA->PD\n"); | ||
130 | |||
113 | disable_irq_nosync(wm831x_ts->data_irq); | 131 | disable_irq_nosync(wm831x_ts->data_irq); |
114 | 132 | ||
115 | /* Don't need data any more */ | 133 | /* Don't need data any more */ |
@@ -128,6 +146,10 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) | |||
128 | ABS_PRESSURE, 0); | 146 | ABS_PRESSURE, 0); |
129 | 147 | ||
130 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0); | 148 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0); |
149 | |||
150 | schedule_work(&wm831x_ts->pd_data_work); | ||
151 | } else { | ||
152 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1); | ||
131 | } | 153 | } |
132 | 154 | ||
133 | input_sync(wm831x_ts->input_dev); | 155 | input_sync(wm831x_ts->input_dev); |
@@ -141,6 +163,11 @@ static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data) | |||
141 | struct wm831x *wm831x = wm831x_ts->wm831x; | 163 | struct wm831x *wm831x = wm831x_ts->wm831x; |
142 | int ena = 0; | 164 | int ena = 0; |
143 | 165 | ||
166 | if (wm831x_ts->pen_down) | ||
167 | return IRQ_HANDLED; | ||
168 | |||
169 | disable_irq_nosync(wm831x_ts->pd_irq); | ||
170 | |||
144 | /* Start collecting data */ | 171 | /* Start collecting data */ |
145 | if (wm831x_ts->pressure) | 172 | if (wm831x_ts->pressure) |
146 | ena |= WM831X_TCH_Z_ENA; | 173 | ena |= WM831X_TCH_Z_ENA; |
@@ -149,14 +176,14 @@ static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data) | |||
149 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, | 176 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, |
150 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena); | 177 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena); |
151 | 178 | ||
152 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1); | ||
153 | input_sync(wm831x_ts->input_dev); | ||
154 | |||
155 | wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, | 179 | wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, |
156 | WM831X_TCHPD_EINT, WM831X_TCHPD_EINT); | 180 | WM831X_TCHPD_EINT, WM831X_TCHPD_EINT); |
157 | 181 | ||
158 | wm831x_ts->pen_down = true; | 182 | wm831x_ts->pen_down = true; |
159 | enable_irq(wm831x_ts->data_irq); | 183 | |
184 | /* Switch from pen down to data */ | ||
185 | dev_dbg(wm831x->dev, "IRQ PD->DATA\n"); | ||
186 | schedule_work(&wm831x_ts->pd_data_work); | ||
160 | 187 | ||
161 | return IRQ_HANDLED; | 188 | return IRQ_HANDLED; |
162 | } | 189 | } |
@@ -182,13 +209,28 @@ static void wm831x_ts_input_close(struct input_dev *idev) | |||
182 | struct wm831x_ts *wm831x_ts = input_get_drvdata(idev); | 209 | struct wm831x_ts *wm831x_ts = input_get_drvdata(idev); |
183 | struct wm831x *wm831x = wm831x_ts->wm831x; | 210 | struct wm831x *wm831x = wm831x_ts->wm831x; |
184 | 211 | ||
212 | /* Shut the controller down, disabling all other functionality too */ | ||
185 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | 213 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, |
186 | WM831X_TCH_ENA | WM831X_TCH_CVT_ENA | | 214 | WM831X_TCH_ENA | WM831X_TCH_X_ENA | |
187 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | | 215 | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, 0); |
188 | WM831X_TCH_Z_ENA, 0); | ||
189 | 216 | ||
190 | if (wm831x_ts->pen_down) | 217 | /* Make sure any pending IRQs are done, the above will prevent |
218 | * new ones firing. | ||
219 | */ | ||
220 | synchronize_irq(wm831x_ts->data_irq); | ||
221 | synchronize_irq(wm831x_ts->pd_irq); | ||
222 | |||
223 | /* Make sure the IRQ completion work is quiesced */ | ||
224 | flush_work_sync(&wm831x_ts->pd_data_work); | ||
225 | |||
226 | /* If we ended up with the pen down then make sure we revert back | ||
227 | * to pen detection state for the next time we start up. | ||
228 | */ | ||
229 | if (wm831x_ts->pen_down) { | ||
191 | disable_irq(wm831x_ts->data_irq); | 230 | disable_irq(wm831x_ts->data_irq); |
231 | enable_irq(wm831x_ts->pd_irq); | ||
232 | wm831x_ts->pen_down = false; | ||
233 | } | ||
192 | } | 234 | } |
193 | 235 | ||
194 | static __devinit int wm831x_ts_probe(struct platform_device *pdev) | 236 | static __devinit int wm831x_ts_probe(struct platform_device *pdev) |
@@ -198,7 +240,7 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
198 | struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent); | 240 | struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent); |
199 | struct wm831x_touch_pdata *pdata = NULL; | 241 | struct wm831x_touch_pdata *pdata = NULL; |
200 | struct input_dev *input_dev; | 242 | struct input_dev *input_dev; |
201 | int error; | 243 | int error, irqf; |
202 | 244 | ||
203 | if (core_pdata) | 245 | if (core_pdata) |
204 | pdata = core_pdata->touch; | 246 | pdata = core_pdata->touch; |
@@ -212,6 +254,7 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
212 | 254 | ||
213 | wm831x_ts->wm831x = wm831x; | 255 | wm831x_ts->wm831x = wm831x; |
214 | wm831x_ts->input_dev = input_dev; | 256 | wm831x_ts->input_dev = input_dev; |
257 | INIT_WORK(&wm831x_ts->pd_data_work, wm831x_pd_data_work); | ||
215 | 258 | ||
216 | /* | 259 | /* |
217 | * If we have a direct IRQ use it, otherwise use the interrupt | 260 | * If we have a direct IRQ use it, otherwise use the interrupt |
@@ -270,9 +313,14 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
270 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | 313 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, |
271 | WM831X_TCH_RATE_MASK, 6); | 314 | WM831X_TCH_RATE_MASK, 6); |
272 | 315 | ||
316 | if (pdata && pdata->data_irqf) | ||
317 | irqf = pdata->data_irqf; | ||
318 | else | ||
319 | irqf = IRQF_TRIGGER_HIGH; | ||
320 | |||
273 | error = request_threaded_irq(wm831x_ts->data_irq, | 321 | error = request_threaded_irq(wm831x_ts->data_irq, |
274 | NULL, wm831x_ts_data_irq, | 322 | NULL, wm831x_ts_data_irq, |
275 | IRQF_ONESHOT, | 323 | irqf | IRQF_ONESHOT, |
276 | "Touchscreen data", wm831x_ts); | 324 | "Touchscreen data", wm831x_ts); |
277 | if (error) { | 325 | if (error) { |
278 | dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", | 326 | dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", |
@@ -281,9 +329,14 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev) | |||
281 | } | 329 | } |
282 | disable_irq(wm831x_ts->data_irq); | 330 | disable_irq(wm831x_ts->data_irq); |
283 | 331 | ||
332 | if (pdata && pdata->pd_irqf) | ||
333 | irqf = pdata->pd_irqf; | ||
334 | else | ||
335 | irqf = IRQF_TRIGGER_HIGH; | ||
336 | |||
284 | error = request_threaded_irq(wm831x_ts->pd_irq, | 337 | error = request_threaded_irq(wm831x_ts->pd_irq, |
285 | NULL, wm831x_ts_pen_down_irq, | 338 | NULL, wm831x_ts_pen_down_irq, |
286 | IRQF_ONESHOT, | 339 | irqf | IRQF_ONESHOT, |
287 | "Touchscreen pen down", wm831x_ts); | 340 | "Touchscreen pen down", wm831x_ts); |
288 | if (error) { | 341 | if (error) { |
289 | dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n", | 342 | dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n", |
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c index 5466d47db899..aae40e52af5b 100644 --- a/drivers/media/common/tuners/tda18271-common.c +++ b/drivers/media/common/tuners/tda18271-common.c | |||
@@ -533,16 +533,7 @@ int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq) | |||
533 | if (tda_fail(ret)) | 533 | if (tda_fail(ret)) |
534 | goto fail; | 534 | goto fail; |
535 | 535 | ||
536 | regs[R_MPD] = (0x77 & pd); | 536 | regs[R_MPD] = (0x7f & pd); |
537 | |||
538 | switch (priv->mode) { | ||
539 | case TDA18271_ANALOG: | ||
540 | regs[R_MPD] &= ~0x08; | ||
541 | break; | ||
542 | case TDA18271_DIGITAL: | ||
543 | regs[R_MPD] |= 0x08; | ||
544 | break; | ||
545 | } | ||
546 | 537 | ||
547 | div = ((d * (freq / 1000)) << 7) / 125; | 538 | div = ((d * (freq / 1000)) << 7) / 125; |
548 | 539 | ||
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c index 9ad4454a148d..d884f5eee73c 100644 --- a/drivers/media/common/tuners/tda18271-fe.c +++ b/drivers/media/common/tuners/tda18271-fe.c | |||
@@ -579,8 +579,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
579 | #define RF3 2 | 579 | #define RF3 2 |
580 | u32 rf_default[3]; | 580 | u32 rf_default[3]; |
581 | u32 rf_freq[3]; | 581 | u32 rf_freq[3]; |
582 | u8 prog_cal[3]; | 582 | s32 prog_cal[3]; |
583 | u8 prog_tab[3]; | 583 | s32 prog_tab[3]; |
584 | 584 | ||
585 | i = tda18271_lookup_rf_band(fe, &freq, NULL); | 585 | i = tda18271_lookup_rf_band(fe, &freq, NULL); |
586 | 586 | ||
@@ -602,32 +602,33 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
602 | return bcal; | 602 | return bcal; |
603 | 603 | ||
604 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); | 604 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); |
605 | prog_tab[rf] = regs[R_EB14]; | 605 | prog_tab[rf] = (s32)regs[R_EB14]; |
606 | 606 | ||
607 | if (1 == bcal) | 607 | if (1 == bcal) |
608 | prog_cal[rf] = tda18271_calibrate_rf(fe, rf_freq[rf]); | 608 | prog_cal[rf] = |
609 | (s32)tda18271_calibrate_rf(fe, rf_freq[rf]); | ||
609 | else | 610 | else |
610 | prog_cal[rf] = prog_tab[rf]; | 611 | prog_cal[rf] = prog_tab[rf]; |
611 | 612 | ||
612 | switch (rf) { | 613 | switch (rf) { |
613 | case RF1: | 614 | case RF1: |
614 | map[i].rf_a1 = 0; | 615 | map[i].rf_a1 = 0; |
615 | map[i].rf_b1 = (s32)(prog_cal[RF1] - prog_tab[RF1]); | 616 | map[i].rf_b1 = (prog_cal[RF1] - prog_tab[RF1]); |
616 | map[i].rf1 = rf_freq[RF1] / 1000; | 617 | map[i].rf1 = rf_freq[RF1] / 1000; |
617 | break; | 618 | break; |
618 | case RF2: | 619 | case RF2: |
619 | dividend = (s32)(prog_cal[RF2] - prog_tab[RF2]) - | 620 | dividend = (prog_cal[RF2] - prog_tab[RF2] - |
620 | (s32)(prog_cal[RF1] + prog_tab[RF1]); | 621 | prog_cal[RF1] + prog_tab[RF1]); |
621 | divisor = (s32)(rf_freq[RF2] - rf_freq[RF1]) / 1000; | 622 | divisor = (s32)(rf_freq[RF2] - rf_freq[RF1]) / 1000; |
622 | map[i].rf_a1 = (dividend / divisor); | 623 | map[i].rf_a1 = (dividend / divisor); |
623 | map[i].rf2 = rf_freq[RF2] / 1000; | 624 | map[i].rf2 = rf_freq[RF2] / 1000; |
624 | break; | 625 | break; |
625 | case RF3: | 626 | case RF3: |
626 | dividend = (s32)(prog_cal[RF3] - prog_tab[RF3]) - | 627 | dividend = (prog_cal[RF3] - prog_tab[RF3] - |
627 | (s32)(prog_cal[RF2] + prog_tab[RF2]); | 628 | prog_cal[RF2] + prog_tab[RF2]); |
628 | divisor = (s32)(rf_freq[RF3] - rf_freq[RF2]) / 1000; | 629 | divisor = (s32)(rf_freq[RF3] - rf_freq[RF2]) / 1000; |
629 | map[i].rf_a2 = (dividend / divisor); | 630 | map[i].rf_a2 = (dividend / divisor); |
630 | map[i].rf_b2 = (s32)(prog_cal[RF2] - prog_tab[RF2]); | 631 | map[i].rf_b2 = (prog_cal[RF2] - prog_tab[RF2]); |
631 | map[i].rf3 = rf_freq[RF3] / 1000; | 632 | map[i].rf3 = rf_freq[RF3] / 1000; |
632 | break; | 633 | break; |
633 | default: | 634 | default: |
diff --git a/drivers/media/common/tuners/tda18271-maps.c b/drivers/media/common/tuners/tda18271-maps.c index e7f84c705da8..3d5b6ab7e332 100644 --- a/drivers/media/common/tuners/tda18271-maps.c +++ b/drivers/media/common/tuners/tda18271-maps.c | |||
@@ -229,8 +229,7 @@ static struct tda18271_map tda18271c2_km[] = { | |||
229 | static struct tda18271_map tda18271_rf_band[] = { | 229 | static struct tda18271_map tda18271_rf_band[] = { |
230 | { .rfmax = 47900, .val = 0x00 }, | 230 | { .rfmax = 47900, .val = 0x00 }, |
231 | { .rfmax = 61100, .val = 0x01 }, | 231 | { .rfmax = 61100, .val = 0x01 }, |
232 | /* { .rfmax = 152600, .val = 0x02 }, */ | 232 | { .rfmax = 152600, .val = 0x02 }, |
233 | { .rfmax = 121200, .val = 0x02 }, | ||
234 | { .rfmax = 164700, .val = 0x03 }, | 233 | { .rfmax = 164700, .val = 0x03 }, |
235 | { .rfmax = 203500, .val = 0x04 }, | 234 | { .rfmax = 203500, .val = 0x04 }, |
236 | { .rfmax = 457800, .val = 0x05 }, | 235 | { .rfmax = 457800, .val = 0x05 }, |
@@ -448,7 +447,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = { | |||
448 | { .rfmax = 150000, .val = 0xb0 }, | 447 | { .rfmax = 150000, .val = 0xb0 }, |
449 | { .rfmax = 151000, .val = 0xb1 }, | 448 | { .rfmax = 151000, .val = 0xb1 }, |
450 | { .rfmax = 152000, .val = 0xb7 }, | 449 | { .rfmax = 152000, .val = 0xb7 }, |
451 | { .rfmax = 153000, .val = 0xbd }, | 450 | { .rfmax = 152600, .val = 0xbd }, |
452 | { .rfmax = 154000, .val = 0x20 }, | 451 | { .rfmax = 154000, .val = 0x20 }, |
453 | { .rfmax = 155000, .val = 0x22 }, | 452 | { .rfmax = 155000, .val = 0x22 }, |
454 | { .rfmax = 156000, .val = 0x24 }, | 453 | { .rfmax = 156000, .val = 0x24 }, |
@@ -459,7 +458,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = { | |||
459 | { .rfmax = 161000, .val = 0x2d }, | 458 | { .rfmax = 161000, .val = 0x2d }, |
460 | { .rfmax = 163000, .val = 0x2e }, | 459 | { .rfmax = 163000, .val = 0x2e }, |
461 | { .rfmax = 164000, .val = 0x2f }, | 460 | { .rfmax = 164000, .val = 0x2f }, |
462 | { .rfmax = 165000, .val = 0x30 }, | 461 | { .rfmax = 164700, .val = 0x30 }, |
463 | { .rfmax = 166000, .val = 0x11 }, | 462 | { .rfmax = 166000, .val = 0x11 }, |
464 | { .rfmax = 167000, .val = 0x12 }, | 463 | { .rfmax = 167000, .val = 0x12 }, |
465 | { .rfmax = 168000, .val = 0x13 }, | 464 | { .rfmax = 168000, .val = 0x13 }, |
@@ -510,7 +509,8 @@ static struct tda18271_map tda18271c2_rf_cal[] = { | |||
510 | { .rfmax = 236000, .val = 0x1b }, | 509 | { .rfmax = 236000, .val = 0x1b }, |
511 | { .rfmax = 237000, .val = 0x1c }, | 510 | { .rfmax = 237000, .val = 0x1c }, |
512 | { .rfmax = 240000, .val = 0x1d }, | 511 | { .rfmax = 240000, .val = 0x1d }, |
513 | { .rfmax = 242000, .val = 0x1f }, | 512 | { .rfmax = 242000, .val = 0x1e }, |
513 | { .rfmax = 244000, .val = 0x1f }, | ||
514 | { .rfmax = 247000, .val = 0x20 }, | 514 | { .rfmax = 247000, .val = 0x20 }, |
515 | { .rfmax = 249000, .val = 0x21 }, | 515 | { .rfmax = 249000, .val = 0x21 }, |
516 | { .rfmax = 252000, .val = 0x22 }, | 516 | { .rfmax = 252000, .val = 0x22 }, |
@@ -624,7 +624,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = { | |||
624 | { .rfmax = 453000, .val = 0x93 }, | 624 | { .rfmax = 453000, .val = 0x93 }, |
625 | { .rfmax = 454000, .val = 0x94 }, | 625 | { .rfmax = 454000, .val = 0x94 }, |
626 | { .rfmax = 456000, .val = 0x96 }, | 626 | { .rfmax = 456000, .val = 0x96 }, |
627 | { .rfmax = 457000, .val = 0x98 }, | 627 | { .rfmax = 457800, .val = 0x98 }, |
628 | { .rfmax = 461000, .val = 0x11 }, | 628 | { .rfmax = 461000, .val = 0x11 }, |
629 | { .rfmax = 468000, .val = 0x12 }, | 629 | { .rfmax = 468000, .val = 0x12 }, |
630 | { .rfmax = 472000, .val = 0x13 }, | 630 | { .rfmax = 472000, .val = 0x13 }, |
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c index 955254090a0e..03f96d6ca894 100644 --- a/drivers/media/dvb/b2c2/flexcop-pci.c +++ b/drivers/media/dvb/b2c2/flexcop-pci.c | |||
@@ -38,7 +38,7 @@ MODULE_PARM_DESC(debug, | |||
38 | DEBSTATUS); | 38 | DEBSTATUS); |
39 | 39 | ||
40 | #define DRIVER_VERSION "0.1" | 40 | #define DRIVER_VERSION "0.1" |
41 | #define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV PCI Driver" | 41 | #define DRIVER_NAME "flexcop-pci" |
42 | #define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>" | 42 | #define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>" |
43 | 43 | ||
44 | struct flexcop_pci { | 44 | struct flexcop_pci { |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index fe4f894183ff..ccbd39a38c46 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -362,7 +362,7 @@ config DVB_USB_LME2510 | |||
362 | config DVB_USB_TECHNISAT_USB2 | 362 | config DVB_USB_TECHNISAT_USB2 |
363 | tristate "Technisat DVB-S/S2 USB2.0 support" | 363 | tristate "Technisat DVB-S/S2 USB2.0 support" |
364 | depends on DVB_USB | 364 | depends on DVB_USB |
365 | select DVB_STB0899 if !DVB_FE_CUSTOMISE | 365 | select DVB_STV090x if !DVB_FE_CUSTOMISE |
366 | select DVB_STB6100 if !DVB_FE_CUSTOMISE | 366 | select DVB_STV6110x if !DVB_FE_CUSTOMISE |
367 | help | 367 | help |
368 | Say Y here to support the Technisat USB2 DVB-S/S2 device | 368 | Say Y here to support the Technisat USB2 DVB-S/S2 device |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index 97af266d7f1d..65214af5cd74 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
@@ -2162,7 +2162,7 @@ struct dibx000_agc_config dib7090_agc_config[2] = { | |||
2162 | .agc1_pt3 = 98, | 2162 | .agc1_pt3 = 98, |
2163 | .agc1_slope1 = 0, | 2163 | .agc1_slope1 = 0, |
2164 | .agc1_slope2 = 167, | 2164 | .agc1_slope2 = 167, |
2165 | .agc1_pt1 = 98, | 2165 | .agc2_pt1 = 98, |
2166 | .agc2_pt2 = 255, | 2166 | .agc2_pt2 = 255, |
2167 | .agc2_slope1 = 104, | 2167 | .agc2_slope1 = 104, |
2168 | .agc2_slope2 = 0, | 2168 | .agc2_slope2 = 0, |
@@ -2440,11 +2440,11 @@ static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap) | |||
2440 | dib0700_set_i2c_speed(adap->dev, 340); | 2440 | dib0700_set_i2c_speed(adap->dev, 340); |
2441 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]); | 2441 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]); |
2442 | 2442 | ||
2443 | dib7090_slave_reset(adap->fe); | ||
2444 | |||
2445 | if (adap->fe == NULL) | 2443 | if (adap->fe == NULL) |
2446 | return -ENODEV; | 2444 | return -ENODEV; |
2447 | 2445 | ||
2446 | dib7090_slave_reset(adap->fe); | ||
2447 | |||
2448 | return 0; | 2448 | return 0; |
2449 | } | 2449 | } |
2450 | 2450 | ||
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 23640ed44d85..056138f63c7d 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c | |||
@@ -378,7 +378,6 @@ EXPORT_SYMBOL_GPL(media_entity_create_link); | |||
378 | 378 | ||
379 | static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) | 379 | static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) |
380 | { | 380 | { |
381 | const u32 mask = MEDIA_LNK_FL_ENABLED; | ||
382 | int ret; | 381 | int ret; |
383 | 382 | ||
384 | /* Notify both entities. */ | 383 | /* Notify both entities. */ |
@@ -395,7 +394,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) | |||
395 | return ret; | 394 | return ret; |
396 | } | 395 | } |
397 | 396 | ||
398 | link->flags = (link->flags & ~mask) | (flags & mask); | 397 | link->flags = flags; |
399 | link->reverse->flags = link->flags; | 398 | link->reverse->flags = link->flags; |
400 | 399 | ||
401 | return 0; | 400 | return 0; |
@@ -417,6 +416,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) | |||
417 | */ | 416 | */ |
418 | int __media_entity_setup_link(struct media_link *link, u32 flags) | 417 | int __media_entity_setup_link(struct media_link *link, u32 flags) |
419 | { | 418 | { |
419 | const u32 mask = MEDIA_LNK_FL_ENABLED; | ||
420 | struct media_device *mdev; | 420 | struct media_device *mdev; |
421 | struct media_entity *source, *sink; | 421 | struct media_entity *source, *sink; |
422 | int ret = -EBUSY; | 422 | int ret = -EBUSY; |
@@ -424,6 +424,10 @@ int __media_entity_setup_link(struct media_link *link, u32 flags) | |||
424 | if (link == NULL) | 424 | if (link == NULL) |
425 | return -EINVAL; | 425 | return -EINVAL; |
426 | 426 | ||
427 | /* The non-modifiable link flags must not be modified. */ | ||
428 | if ((link->flags & ~mask) != (flags & ~mask)) | ||
429 | return -EINVAL; | ||
430 | |||
427 | if (link->flags & MEDIA_LNK_FL_IMMUTABLE) | 431 | if (link->flags & MEDIA_LNK_FL_IMMUTABLE) |
428 | return link->flags == flags ? 0 : -EINVAL; | 432 | return link->flags == flags ? 0 : -EINVAL; |
429 | 433 | ||
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c index dc3f04c52d5e..87bad7678d92 100644 --- a/drivers/media/radio/radio-sf16fmr2.c +++ b/drivers/media/radio/radio-sf16fmr2.c | |||
@@ -170,7 +170,7 @@ static int fmr2_setfreq(struct fmr2 *dev) | |||
170 | return 0; | 170 | return 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | /* !!! not tested, in my card this does't work !!! */ | 173 | /* !!! not tested, in my card this doesn't work !!! */ |
174 | static int fmr2_setvolume(struct fmr2 *dev) | 174 | static int fmr2_setvolume(struct fmr2 *dev) |
175 | { | 175 | { |
176 | int vol[16] = { 0x021, 0x084, 0x090, 0x104, | 176 | int vol[16] = { 0x021, 0x084, 0x090, 0x104, |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 4498b944dec8..00f51dd121f3 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -875,7 +875,7 @@ config MX3_VIDEO | |||
875 | config VIDEO_MX3 | 875 | config VIDEO_MX3 |
876 | tristate "i.MX3x Camera Sensor Interface driver" | 876 | tristate "i.MX3x Camera Sensor Interface driver" |
877 | depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA | 877 | depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA |
878 | select VIDEOBUF_DMA_CONTIG | 878 | select VIDEOBUF2_DMA_CONTIG |
879 | select MX3_VIDEO | 879 | select MX3_VIDEO |
880 | ---help--- | 880 | ---help--- |
881 | This is a v4l2 driver for the i.MX3x Camera Sensor Interface | 881 | This is a v4l2 driver for the i.MX3x Camera Sensor Interface |
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index c6e2ca3b1149..6fbc356113c1 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c | |||
@@ -350,9 +350,17 @@ void cx18_streams_cleanup(struct cx18 *cx, int unregister) | |||
350 | 350 | ||
351 | /* No struct video_device, but can have buffers allocated */ | 351 | /* No struct video_device, but can have buffers allocated */ |
352 | if (type == CX18_ENC_STREAM_TYPE_IDX) { | 352 | if (type == CX18_ENC_STREAM_TYPE_IDX) { |
353 | /* If the module params didn't inhibit IDX ... */ | ||
353 | if (cx->stream_buffers[type] != 0) { | 354 | if (cx->stream_buffers[type] != 0) { |
354 | cx->stream_buffers[type] = 0; | 355 | cx->stream_buffers[type] = 0; |
355 | cx18_stream_free(&cx->streams[type]); | 356 | /* |
357 | * Before calling cx18_stream_free(), | ||
358 | * check if the IDX stream was actually set up. | ||
359 | * Needed, since the cx18_probe() error path | ||
360 | * exits through here as well as normal clean up | ||
361 | */ | ||
362 | if (cx->streams[type].buffers != 0) | ||
363 | cx18_stream_free(&cx->streams[type]); | ||
356 | } | 364 | } |
357 | continue; | 365 | continue; |
358 | } | 366 | } |
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig index 3b6e7f28568e..caab1bfb79e2 100644 --- a/drivers/media/video/cx23885/Kconfig +++ b/drivers/media/video/cx23885/Kconfig | |||
@@ -22,6 +22,7 @@ config VIDEO_CX23885 | |||
22 | select DVB_CX24116 if !DVB_FE_CUSTOMISE | 22 | select DVB_CX24116 if !DVB_FE_CUSTOMISE |
23 | select DVB_STV0900 if !DVB_FE_CUSTOMISE | 23 | select DVB_STV0900 if !DVB_FE_CUSTOMISE |
24 | select DVB_DS3000 if !DVB_FE_CUSTOMISE | 24 | select DVB_DS3000 if !DVB_FE_CUSTOMISE |
25 | select DVB_STV0367 if !DVB_FE_CUSTOMISE | ||
25 | select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMISE | 26 | select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMISE |
26 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE | 27 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE |
27 | select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE | 28 | select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE |
diff --git a/drivers/media/video/imx074.c b/drivers/media/video/imx074.c index 1a1169115716..0382ea752e6f 100644 --- a/drivers/media/video/imx074.c +++ b/drivers/media/video/imx074.c | |||
@@ -298,7 +298,7 @@ static unsigned long imx074_query_bus_param(struct soc_camera_device *icd) | |||
298 | static int imx074_set_bus_param(struct soc_camera_device *icd, | 298 | static int imx074_set_bus_param(struct soc_camera_device *icd, |
299 | unsigned long flags) | 299 | unsigned long flags) |
300 | { | 300 | { |
301 | return -1; | 301 | return -EINVAL; |
302 | } | 302 | } |
303 | 303 | ||
304 | static struct soc_camera_ops imx074_ops = { | 304 | static struct soc_camera_ops imx074_ops = { |
diff --git a/drivers/media/video/omap3isp/isp.c b/drivers/media/video/omap3isp/isp.c index 503bd7922bd6..472a69359e60 100644 --- a/drivers/media/video/omap3isp/isp.c +++ b/drivers/media/video/omap3isp/isp.c | |||
@@ -215,20 +215,21 @@ static u32 isp_set_xclk(struct isp_device *isp, u32 xclk, u8 xclksel) | |||
215 | } | 215 | } |
216 | 216 | ||
217 | switch (xclksel) { | 217 | switch (xclksel) { |
218 | case 0: | 218 | case ISP_XCLK_A: |
219 | isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, | 219 | isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, |
220 | ISPTCTRL_CTRL_DIVA_MASK, | 220 | ISPTCTRL_CTRL_DIVA_MASK, |
221 | divisor << ISPTCTRL_CTRL_DIVA_SHIFT); | 221 | divisor << ISPTCTRL_CTRL_DIVA_SHIFT); |
222 | dev_dbg(isp->dev, "isp_set_xclk(): cam_xclka set to %d Hz\n", | 222 | dev_dbg(isp->dev, "isp_set_xclk(): cam_xclka set to %d Hz\n", |
223 | currentxclk); | 223 | currentxclk); |
224 | break; | 224 | break; |
225 | case 1: | 225 | case ISP_XCLK_B: |
226 | isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, | 226 | isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, |
227 | ISPTCTRL_CTRL_DIVB_MASK, | 227 | ISPTCTRL_CTRL_DIVB_MASK, |
228 | divisor << ISPTCTRL_CTRL_DIVB_SHIFT); | 228 | divisor << ISPTCTRL_CTRL_DIVB_SHIFT); |
229 | dev_dbg(isp->dev, "isp_set_xclk(): cam_xclkb set to %d Hz\n", | 229 | dev_dbg(isp->dev, "isp_set_xclk(): cam_xclkb set to %d Hz\n", |
230 | currentxclk); | 230 | currentxclk); |
231 | break; | 231 | break; |
232 | case ISP_XCLK_NONE: | ||
232 | default: | 233 | default: |
233 | omap3isp_put(isp); | 234 | omap3isp_put(isp); |
234 | dev_dbg(isp->dev, "ISP_ERR: isp_set_xclk(): Invalid requested " | 235 | dev_dbg(isp->dev, "ISP_ERR: isp_set_xclk(): Invalid requested " |
@@ -237,13 +238,13 @@ static u32 isp_set_xclk(struct isp_device *isp, u32 xclk, u8 xclksel) | |||
237 | } | 238 | } |
238 | 239 | ||
239 | /* Do we go from stable whatever to clock? */ | 240 | /* Do we go from stable whatever to clock? */ |
240 | if (divisor >= 2 && isp->xclk_divisor[xclksel] < 2) | 241 | if (divisor >= 2 && isp->xclk_divisor[xclksel - 1] < 2) |
241 | omap3isp_get(isp); | 242 | omap3isp_get(isp); |
242 | /* Stopping the clock. */ | 243 | /* Stopping the clock. */ |
243 | else if (divisor < 2 && isp->xclk_divisor[xclksel] >= 2) | 244 | else if (divisor < 2 && isp->xclk_divisor[xclksel - 1] >= 2) |
244 | omap3isp_put(isp); | 245 | omap3isp_put(isp); |
245 | 246 | ||
246 | isp->xclk_divisor[xclksel] = divisor; | 247 | isp->xclk_divisor[xclksel - 1] = divisor; |
247 | 248 | ||
248 | omap3isp_put(isp); | 249 | omap3isp_put(isp); |
249 | 250 | ||
@@ -285,7 +286,8 @@ static void isp_power_settings(struct isp_device *isp, int idle) | |||
285 | */ | 286 | */ |
286 | void omap3isp_configure_bridge(struct isp_device *isp, | 287 | void omap3isp_configure_bridge(struct isp_device *isp, |
287 | enum ccdc_input_entity input, | 288 | enum ccdc_input_entity input, |
288 | const struct isp_parallel_platform_data *pdata) | 289 | const struct isp_parallel_platform_data *pdata, |
290 | unsigned int shift) | ||
289 | { | 291 | { |
290 | u32 ispctrl_val; | 292 | u32 ispctrl_val; |
291 | 293 | ||
@@ -298,9 +300,9 @@ void omap3isp_configure_bridge(struct isp_device *isp, | |||
298 | switch (input) { | 300 | switch (input) { |
299 | case CCDC_INPUT_PARALLEL: | 301 | case CCDC_INPUT_PARALLEL: |
300 | ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL; | 302 | ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL; |
301 | ispctrl_val |= pdata->data_lane_shift << ISPCTRL_SHIFT_SHIFT; | ||
302 | ispctrl_val |= pdata->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT; | 303 | ispctrl_val |= pdata->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT; |
303 | ispctrl_val |= pdata->bridge << ISPCTRL_PAR_BRIDGE_SHIFT; | 304 | ispctrl_val |= pdata->bridge << ISPCTRL_PAR_BRIDGE_SHIFT; |
305 | shift += pdata->data_lane_shift * 2; | ||
304 | break; | 306 | break; |
305 | 307 | ||
306 | case CCDC_INPUT_CSI2A: | 308 | case CCDC_INPUT_CSI2A: |
@@ -319,6 +321,8 @@ void omap3isp_configure_bridge(struct isp_device *isp, | |||
319 | return; | 321 | return; |
320 | } | 322 | } |
321 | 323 | ||
324 | ispctrl_val |= ((shift/2) << ISPCTRL_SHIFT_SHIFT) & ISPCTRL_SHIFT_MASK; | ||
325 | |||
322 | ispctrl_val &= ~ISPCTRL_SYNC_DETECT_MASK; | 326 | ispctrl_val &= ~ISPCTRL_SYNC_DETECT_MASK; |
323 | ispctrl_val |= ISPCTRL_SYNC_DETECT_VSRISE; | 327 | ispctrl_val |= ISPCTRL_SYNC_DETECT_VSRISE; |
324 | 328 | ||
@@ -658,6 +662,8 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) | |||
658 | 662 | ||
659 | /* Apply power change to connected non-nodes. */ | 663 | /* Apply power change to connected non-nodes. */ |
660 | ret = isp_pipeline_pm_power(entity, change); | 664 | ret = isp_pipeline_pm_power(entity, change); |
665 | if (ret < 0) | ||
666 | entity->use_count -= change; | ||
661 | 667 | ||
662 | mutex_unlock(&entity->parent->graph_mutex); | 668 | mutex_unlock(&entity->parent->graph_mutex); |
663 | 669 | ||
@@ -872,6 +878,9 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) | |||
872 | } | 878 | } |
873 | } | 879 | } |
874 | 880 | ||
881 | if (failure < 0) | ||
882 | isp->needs_reset = true; | ||
883 | |||
875 | return failure; | 884 | return failure; |
876 | } | 885 | } |
877 | 886 | ||
@@ -884,7 +893,8 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) | |||
884 | * single-shot or continuous mode. | 893 | * single-shot or continuous mode. |
885 | * | 894 | * |
886 | * Return 0 if successful, or the return value of the failed video::s_stream | 895 | * Return 0 if successful, or the return value of the failed video::s_stream |
887 | * operation otherwise. | 896 | * operation otherwise. The pipeline state is not updated when the operation |
897 | * fails, except when stopping the pipeline. | ||
888 | */ | 898 | */ |
889 | int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe, | 899 | int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe, |
890 | enum isp_pipeline_stream_state state) | 900 | enum isp_pipeline_stream_state state) |
@@ -895,7 +905,9 @@ int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe, | |||
895 | ret = isp_pipeline_disable(pipe); | 905 | ret = isp_pipeline_disable(pipe); |
896 | else | 906 | else |
897 | ret = isp_pipeline_enable(pipe, state); | 907 | ret = isp_pipeline_enable(pipe, state); |
898 | pipe->stream_state = state; | 908 | |
909 | if (ret == 0 || state == ISP_PIPELINE_STREAM_STOPPED) | ||
910 | pipe->stream_state = state; | ||
899 | 911 | ||
900 | return ret; | 912 | return ret; |
901 | } | 913 | } |
@@ -1481,6 +1493,10 @@ void omap3isp_put(struct isp_device *isp) | |||
1481 | if (--isp->ref_count == 0) { | 1493 | if (--isp->ref_count == 0) { |
1482 | isp_disable_interrupts(isp); | 1494 | isp_disable_interrupts(isp); |
1483 | isp_save_ctx(isp); | 1495 | isp_save_ctx(isp); |
1496 | if (isp->needs_reset) { | ||
1497 | isp_reset(isp); | ||
1498 | isp->needs_reset = false; | ||
1499 | } | ||
1484 | isp_disable_clocks(isp); | 1500 | isp_disable_clocks(isp); |
1485 | } | 1501 | } |
1486 | mutex_unlock(&isp->isp_mutex); | 1502 | mutex_unlock(&isp->isp_mutex); |
diff --git a/drivers/media/video/omap3isp/isp.h b/drivers/media/video/omap3isp/isp.h index cf5214e95a92..2620c405f5e4 100644 --- a/drivers/media/video/omap3isp/isp.h +++ b/drivers/media/video/omap3isp/isp.h | |||
@@ -132,7 +132,6 @@ struct isp_reg { | |||
132 | 132 | ||
133 | /** | 133 | /** |
134 | * struct isp_parallel_platform_data - Parallel interface platform data | 134 | * struct isp_parallel_platform_data - Parallel interface platform data |
135 | * @width: Parallel bus width in bits (8, 10, 11 or 12) | ||
136 | * @data_lane_shift: Data lane shifter | 135 | * @data_lane_shift: Data lane shifter |
137 | * 0 - CAMEXT[13:0] -> CAM[13:0] | 136 | * 0 - CAMEXT[13:0] -> CAM[13:0] |
138 | * 1 - CAMEXT[13:2] -> CAM[11:0] | 137 | * 1 - CAMEXT[13:2] -> CAM[11:0] |
@@ -146,7 +145,6 @@ struct isp_reg { | |||
146 | * ISPCTRL_PAR_BRIDGE_BENDIAN - Big endian | 145 | * ISPCTRL_PAR_BRIDGE_BENDIAN - Big endian |
147 | */ | 146 | */ |
148 | struct isp_parallel_platform_data { | 147 | struct isp_parallel_platform_data { |
149 | unsigned int width; | ||
150 | unsigned int data_lane_shift:2; | 148 | unsigned int data_lane_shift:2; |
151 | unsigned int clk_pol:1; | 149 | unsigned int clk_pol:1; |
152 | unsigned int bridge:4; | 150 | unsigned int bridge:4; |
@@ -262,6 +260,7 @@ struct isp_device { | |||
262 | /* ISP Obj */ | 260 | /* ISP Obj */ |
263 | spinlock_t stat_lock; /* common lock for statistic drivers */ | 261 | spinlock_t stat_lock; /* common lock for statistic drivers */ |
264 | struct mutex isp_mutex; /* For handling ref_count field */ | 262 | struct mutex isp_mutex; /* For handling ref_count field */ |
263 | bool needs_reset; | ||
265 | int has_context; | 264 | int has_context; |
266 | int ref_count; | 265 | int ref_count; |
267 | unsigned int autoidle; | 266 | unsigned int autoidle; |
@@ -311,11 +310,12 @@ int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe, | |||
311 | enum isp_pipeline_stream_state state); | 310 | enum isp_pipeline_stream_state state); |
312 | void omap3isp_configure_bridge(struct isp_device *isp, | 311 | void omap3isp_configure_bridge(struct isp_device *isp, |
313 | enum ccdc_input_entity input, | 312 | enum ccdc_input_entity input, |
314 | const struct isp_parallel_platform_data *pdata); | 313 | const struct isp_parallel_platform_data *pdata, |
314 | unsigned int shift); | ||
315 | 315 | ||
316 | #define ISP_XCLK_NONE -1 | 316 | #define ISP_XCLK_NONE 0 |
317 | #define ISP_XCLK_A 0 | 317 | #define ISP_XCLK_A 1 |
318 | #define ISP_XCLK_B 1 | 318 | #define ISP_XCLK_B 2 |
319 | 319 | ||
320 | struct isp_device *omap3isp_get(struct isp_device *isp); | 320 | struct isp_device *omap3isp_get(struct isp_device *isp); |
321 | void omap3isp_put(struct isp_device *isp); | 321 | void omap3isp_put(struct isp_device *isp); |
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c index 5ff9d14ce710..39d501bda636 100644 --- a/drivers/media/video/omap3isp/ispccdc.c +++ b/drivers/media/video/omap3isp/ispccdc.c | |||
@@ -43,6 +43,12 @@ __ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, | |||
43 | 43 | ||
44 | static const unsigned int ccdc_fmts[] = { | 44 | static const unsigned int ccdc_fmts[] = { |
45 | V4L2_MBUS_FMT_Y8_1X8, | 45 | V4L2_MBUS_FMT_Y8_1X8, |
46 | V4L2_MBUS_FMT_Y10_1X10, | ||
47 | V4L2_MBUS_FMT_Y12_1X12, | ||
48 | V4L2_MBUS_FMT_SGRBG8_1X8, | ||
49 | V4L2_MBUS_FMT_SRGGB8_1X8, | ||
50 | V4L2_MBUS_FMT_SBGGR8_1X8, | ||
51 | V4L2_MBUS_FMT_SGBRG8_1X8, | ||
46 | V4L2_MBUS_FMT_SGRBG10_1X10, | 52 | V4L2_MBUS_FMT_SGRBG10_1X10, |
47 | V4L2_MBUS_FMT_SRGGB10_1X10, | 53 | V4L2_MBUS_FMT_SRGGB10_1X10, |
48 | V4L2_MBUS_FMT_SBGGR10_1X10, | 54 | V4L2_MBUS_FMT_SBGGR10_1X10, |
@@ -1110,21 +1116,38 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) | |||
1110 | struct isp_parallel_platform_data *pdata = NULL; | 1116 | struct isp_parallel_platform_data *pdata = NULL; |
1111 | struct v4l2_subdev *sensor; | 1117 | struct v4l2_subdev *sensor; |
1112 | struct v4l2_mbus_framefmt *format; | 1118 | struct v4l2_mbus_framefmt *format; |
1119 | const struct isp_format_info *fmt_info; | ||
1120 | struct v4l2_subdev_format fmt_src; | ||
1121 | unsigned int depth_out; | ||
1122 | unsigned int depth_in = 0; | ||
1113 | struct media_pad *pad; | 1123 | struct media_pad *pad; |
1114 | unsigned long flags; | 1124 | unsigned long flags; |
1125 | unsigned int shift; | ||
1115 | u32 syn_mode; | 1126 | u32 syn_mode; |
1116 | u32 ccdc_pattern; | 1127 | u32 ccdc_pattern; |
1117 | 1128 | ||
1118 | if (ccdc->input == CCDC_INPUT_PARALLEL) { | 1129 | pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); |
1119 | pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); | 1130 | sensor = media_entity_to_v4l2_subdev(pad->entity); |
1120 | sensor = media_entity_to_v4l2_subdev(pad->entity); | 1131 | if (ccdc->input == CCDC_INPUT_PARALLEL) |
1121 | pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv) | 1132 | pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv) |
1122 | ->bus.parallel; | 1133 | ->bus.parallel; |
1134 | |||
1135 | /* Compute shift value for lane shifter to configure the bridge. */ | ||
1136 | fmt_src.pad = pad->index; | ||
1137 | fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; | ||
1138 | if (!v4l2_subdev_call(sensor, pad, get_fmt, NULL, &fmt_src)) { | ||
1139 | fmt_info = omap3isp_video_format_info(fmt_src.format.code); | ||
1140 | depth_in = fmt_info->bpp; | ||
1123 | } | 1141 | } |
1124 | 1142 | ||
1125 | omap3isp_configure_bridge(isp, ccdc->input, pdata); | 1143 | fmt_info = omap3isp_video_format_info |
1144 | (isp->isp_ccdc.formats[CCDC_PAD_SINK].code); | ||
1145 | depth_out = fmt_info->bpp; | ||
1146 | |||
1147 | shift = depth_in - depth_out; | ||
1148 | omap3isp_configure_bridge(isp, ccdc->input, pdata, shift); | ||
1126 | 1149 | ||
1127 | ccdc->syncif.datsz = pdata ? pdata->width : 10; | 1150 | ccdc->syncif.datsz = depth_out; |
1128 | ccdc_config_sync_if(ccdc, &ccdc->syncif); | 1151 | ccdc_config_sync_if(ccdc, &ccdc->syncif); |
1129 | 1152 | ||
1130 | /* CCDC_PAD_SINK */ | 1153 | /* CCDC_PAD_SINK */ |
@@ -1338,7 +1361,7 @@ static int ccdc_sbl_wait_idle(struct isp_ccdc_device *ccdc, | |||
1338 | * @ccdc: Pointer to ISP CCDC device. | 1361 | * @ccdc: Pointer to ISP CCDC device. |
1339 | * @event: Pointing which event trigger handler | 1362 | * @event: Pointing which event trigger handler |
1340 | * | 1363 | * |
1341 | * Return 1 when the event and stopping request combination is satisfyied, | 1364 | * Return 1 when the event and stopping request combination is satisfied, |
1342 | * zero otherwise. | 1365 | * zero otherwise. |
1343 | */ | 1366 | */ |
1344 | static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event) | 1367 | static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event) |
@@ -1618,7 +1641,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer) | |||
1618 | 1641 | ||
1619 | ccdc_set_outaddr(ccdc, buffer->isp_addr); | 1642 | ccdc_set_outaddr(ccdc, buffer->isp_addr); |
1620 | 1643 | ||
1621 | /* We now have a buffer queued on the output, restart the pipeline in | 1644 | /* We now have a buffer queued on the output, restart the pipeline |
1622 | * on the next CCDC interrupt if running in continuous mode (or when | 1645 | * on the next CCDC interrupt if running in continuous mode (or when |
1623 | * starting the stream). | 1646 | * starting the stream). |
1624 | */ | 1647 | */ |
diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c index 2b16988a501d..aba537af87e4 100644 --- a/drivers/media/video/omap3isp/isppreview.c +++ b/drivers/media/video/omap3isp/isppreview.c | |||
@@ -755,7 +755,7 @@ static struct preview_update update_attrs[] = { | |||
755 | * @configs - pointer to update config structure. | 755 | * @configs - pointer to update config structure. |
756 | * @config - return pointer to appropriate structure field. | 756 | * @config - return pointer to appropriate structure field. |
757 | * @bit - for which feature to return pointers. | 757 | * @bit - for which feature to return pointers. |
758 | * Return size of coresponding prev_params member | 758 | * Return size of corresponding prev_params member |
759 | */ | 759 | */ |
760 | static u32 | 760 | static u32 |
761 | __preview_get_ptrs(struct prev_params *params, void **param, | 761 | __preview_get_ptrs(struct prev_params *params, void **param, |
diff --git a/drivers/media/video/omap3isp/ispqueue.c b/drivers/media/video/omap3isp/ispqueue.c index 8fddc5806b0d..9c317148205f 100644 --- a/drivers/media/video/omap3isp/ispqueue.c +++ b/drivers/media/video/omap3isp/ispqueue.c | |||
@@ -339,7 +339,7 @@ static int isp_video_buffer_prepare_user(struct isp_video_buffer *buf) | |||
339 | up_read(¤t->mm->mmap_sem); | 339 | up_read(¤t->mm->mmap_sem); |
340 | 340 | ||
341 | if (ret != buf->npages) { | 341 | if (ret != buf->npages) { |
342 | buf->npages = ret; | 342 | buf->npages = ret < 0 ? 0 : ret; |
343 | isp_video_buffer_cleanup(buf); | 343 | isp_video_buffer_cleanup(buf); |
344 | return -EFAULT; | 344 | return -EFAULT; |
345 | } | 345 | } |
@@ -408,8 +408,8 @@ done: | |||
408 | * isp_video_buffer_prepare_vm_flags - Get VMA flags for a userspace address | 408 | * isp_video_buffer_prepare_vm_flags - Get VMA flags for a userspace address |
409 | * | 409 | * |
410 | * This function locates the VMAs for the buffer's userspace address and checks | 410 | * This function locates the VMAs for the buffer's userspace address and checks |
411 | * that their flags match. The onlflag that we need to care for at the moment is | 411 | * that their flags match. The only flag that we need to care for at the moment |
412 | * VM_PFNMAP. | 412 | * is VM_PFNMAP. |
413 | * | 413 | * |
414 | * The buffer vm_flags field is set to the first VMA flags. | 414 | * The buffer vm_flags field is set to the first VMA flags. |
415 | * | 415 | * |
diff --git a/drivers/media/video/omap3isp/ispresizer.c b/drivers/media/video/omap3isp/ispresizer.c index 653f88ba56db..0bb0f8cd36f5 100644 --- a/drivers/media/video/omap3isp/ispresizer.c +++ b/drivers/media/video/omap3isp/ispresizer.c | |||
@@ -714,19 +714,50 @@ static void resizer_print_status(struct isp_res_device *res) | |||
714 | * iw and ih are the input width and height after cropping. Those equations need | 714 | * iw and ih are the input width and height after cropping. Those equations need |
715 | * to be satisfied exactly for the resizer to work correctly. | 715 | * to be satisfied exactly for the resizer to work correctly. |
716 | * | 716 | * |
717 | * Reverting the equations, we can compute the resizing ratios with | 717 | * The equations can't be easily reverted, as the >> 8 operation is not linear. |
718 | * In addition, not all input sizes can be achieved for a given output size. To | ||
719 | * get the highest input size lower than or equal to the requested input size, | ||
720 | * we need to compute the highest resizing ratio that satisfies the following | ||
721 | * inequality (taking the 4-tap mode width equation as an example) | ||
722 | * | ||
723 | * iw >= (32 * sph + (ow - 1) * hrsz + 16) >> 8 - 7 | ||
724 | * | ||
725 | * (where iw is the requested input width) which can be rewritten as | ||
726 | * | ||
727 | * iw - 7 >= (32 * sph + (ow - 1) * hrsz + 16) >> 8 | ||
728 | * (iw - 7) << 8 >= 32 * sph + (ow - 1) * hrsz + 16 - b | ||
729 | * ((iw - 7) << 8) + b >= 32 * sph + (ow - 1) * hrsz + 16 | ||
730 | * | ||
731 | * where b is the value of the 8 least significant bits of the right hand side | ||
732 | * expression of the last inequality. The highest resizing ratio value will be | ||
733 | * achieved when b is equal to its maximum value of 255. That resizing ratio | ||
734 | * value will still satisfy the original inequality, as b will disappear when | ||
735 | * the expression will be shifted right by 8. | ||
736 | * | ||
737 | * The reverted the equations thus become | ||
718 | * | 738 | * |
719 | * - 8-phase, 4-tap mode | 739 | * - 8-phase, 4-tap mode |
720 | * hrsz = ((iw - 7) * 256 - 16 - 32 * sph) / (ow - 1) | 740 | * hrsz = ((iw - 7) * 256 + 255 - 16 - 32 * sph) / (ow - 1) |
721 | * vrsz = ((ih - 4) * 256 - 16 - 32 * spv) / (oh - 1) | 741 | * vrsz = ((ih - 4) * 256 + 255 - 16 - 32 * spv) / (oh - 1) |
722 | * - 4-phase, 7-tap mode | 742 | * - 4-phase, 7-tap mode |
723 | * hrsz = ((iw - 7) * 256 - 32 - 64 * sph) / (ow - 1) | 743 | * hrsz = ((iw - 7) * 256 + 255 - 32 - 64 * sph) / (ow - 1) |
724 | * vrsz = ((ih - 7) * 256 - 32 - 64 * spv) / (oh - 1) | 744 | * vrsz = ((ih - 7) * 256 + 255 - 32 - 64 * spv) / (oh - 1) |
725 | * | 745 | * |
726 | * The ratios are integer values, and must be rounded down to ensure that the | 746 | * The ratios are integer values, and are rounded down to ensure that the |
727 | * cropped input size is not bigger than the uncropped input size. As the ratio | 747 | * cropped input size is not bigger than the uncropped input size. |
728 | * in 7-tap mode is always smaller than the ratio in 4-tap mode, we can use the | 748 | * |
729 | * 7-tap mode equations to compute a ratio approximation. | 749 | * As the number of phases/taps, used to select the correct equations to compute |
750 | * the ratio, depends on the ratio, we start with the 4-tap mode equations to | ||
751 | * compute an approximation of the ratio, and switch to the 7-tap mode equations | ||
752 | * if the approximation is higher than the ratio threshold. | ||
753 | * | ||
754 | * As the 7-tap mode equations will return a ratio smaller than or equal to the | ||
755 | * 4-tap mode equations, the resulting ratio could become lower than or equal to | ||
756 | * the ratio threshold. This 'equations loop' isn't an issue as long as the | ||
757 | * correct equations are used to compute the final input size. Starting with the | ||
758 | * 4-tap mode equations ensure that, in case of values resulting in a 'ratio | ||
759 | * loop', the smallest of the ratio values will be used, never exceeding the | ||
760 | * requested input size. | ||
730 | * | 761 | * |
731 | * We first clamp the output size according to the hardware capabilitie to avoid | 762 | * We first clamp the output size according to the hardware capabilitie to avoid |
732 | * auto-cropping the input more than required to satisfy the TRM equations. The | 763 | * auto-cropping the input more than required to satisfy the TRM equations. The |
@@ -775,6 +806,8 @@ static void resizer_calc_ratios(struct isp_res_device *res, | |||
775 | unsigned int max_width; | 806 | unsigned int max_width; |
776 | unsigned int max_height; | 807 | unsigned int max_height; |
777 | unsigned int width_alignment; | 808 | unsigned int width_alignment; |
809 | unsigned int width; | ||
810 | unsigned int height; | ||
778 | 811 | ||
779 | /* | 812 | /* |
780 | * Clamp the output height based on the hardware capabilities and | 813 | * Clamp the output height based on the hardware capabilities and |
@@ -786,19 +819,22 @@ static void resizer_calc_ratios(struct isp_res_device *res, | |||
786 | max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT); | 819 | max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT); |
787 | output->height = clamp(output->height, min_height, max_height); | 820 | output->height = clamp(output->height, min_height, max_height); |
788 | 821 | ||
789 | ratio->vert = ((input->height - 7) * 256 - 32 - 64 * spv) | 822 | ratio->vert = ((input->height - 4) * 256 + 255 - 16 - 32 * spv) |
790 | / (output->height - 1); | 823 | / (output->height - 1); |
824 | if (ratio->vert > MID_RESIZE_VALUE) | ||
825 | ratio->vert = ((input->height - 7) * 256 + 255 - 32 - 64 * spv) | ||
826 | / (output->height - 1); | ||
791 | ratio->vert = clamp_t(unsigned int, ratio->vert, | 827 | ratio->vert = clamp_t(unsigned int, ratio->vert, |
792 | MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); | 828 | MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); |
793 | 829 | ||
794 | if (ratio->vert <= MID_RESIZE_VALUE) { | 830 | if (ratio->vert <= MID_RESIZE_VALUE) { |
795 | upscaled_height = (output->height - 1) * ratio->vert | 831 | upscaled_height = (output->height - 1) * ratio->vert |
796 | + 32 * spv + 16; | 832 | + 32 * spv + 16; |
797 | input->height = (upscaled_height >> 8) + 4; | 833 | height = (upscaled_height >> 8) + 4; |
798 | } else { | 834 | } else { |
799 | upscaled_height = (output->height - 1) * ratio->vert | 835 | upscaled_height = (output->height - 1) * ratio->vert |
800 | + 64 * spv + 32; | 836 | + 64 * spv + 32; |
801 | input->height = (upscaled_height >> 8) + 7; | 837 | height = (upscaled_height >> 8) + 7; |
802 | } | 838 | } |
803 | 839 | ||
804 | /* | 840 | /* |
@@ -854,20 +890,29 @@ static void resizer_calc_ratios(struct isp_res_device *res, | |||
854 | max_width & ~(width_alignment - 1)); | 890 | max_width & ~(width_alignment - 1)); |
855 | output->width = ALIGN(output->width, width_alignment); | 891 | output->width = ALIGN(output->width, width_alignment); |
856 | 892 | ||
857 | ratio->horz = ((input->width - 7) * 256 - 32 - 64 * sph) | 893 | ratio->horz = ((input->width - 7) * 256 + 255 - 16 - 32 * sph) |
858 | / (output->width - 1); | 894 | / (output->width - 1); |
895 | if (ratio->horz > MID_RESIZE_VALUE) | ||
896 | ratio->horz = ((input->width - 7) * 256 + 255 - 32 - 64 * sph) | ||
897 | / (output->width - 1); | ||
859 | ratio->horz = clamp_t(unsigned int, ratio->horz, | 898 | ratio->horz = clamp_t(unsigned int, ratio->horz, |
860 | MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); | 899 | MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); |
861 | 900 | ||
862 | if (ratio->horz <= MID_RESIZE_VALUE) { | 901 | if (ratio->horz <= MID_RESIZE_VALUE) { |
863 | upscaled_width = (output->width - 1) * ratio->horz | 902 | upscaled_width = (output->width - 1) * ratio->horz |
864 | + 32 * sph + 16; | 903 | + 32 * sph + 16; |
865 | input->width = (upscaled_width >> 8) + 7; | 904 | width = (upscaled_width >> 8) + 7; |
866 | } else { | 905 | } else { |
867 | upscaled_width = (output->width - 1) * ratio->horz | 906 | upscaled_width = (output->width - 1) * ratio->horz |
868 | + 64 * sph + 32; | 907 | + 64 * sph + 32; |
869 | input->width = (upscaled_width >> 8) + 7; | 908 | width = (upscaled_width >> 8) + 7; |
870 | } | 909 | } |
910 | |||
911 | /* Center the new crop rectangle. */ | ||
912 | input->left += (input->width - width) / 2; | ||
913 | input->top += (input->height - height) / 2; | ||
914 | input->width = width; | ||
915 | input->height = height; | ||
871 | } | 916 | } |
872 | 917 | ||
873 | /* | 918 | /* |
diff --git a/drivers/media/video/omap3isp/ispstat.h b/drivers/media/video/omap3isp/ispstat.h index 820950c9ef46..d86da94fa50d 100644 --- a/drivers/media/video/omap3isp/ispstat.h +++ b/drivers/media/video/omap3isp/ispstat.h | |||
@@ -131,9 +131,9 @@ struct ispstat { | |||
131 | struct ispstat_generic_config { | 131 | struct ispstat_generic_config { |
132 | /* | 132 | /* |
133 | * Fields must be in the same order as in: | 133 | * Fields must be in the same order as in: |
134 | * - isph3a_aewb_config | 134 | * - omap3isp_h3a_aewb_config |
135 | * - isph3a_af_config | 135 | * - omap3isp_h3a_af_config |
136 | * - isphist_config | 136 | * - omap3isp_hist_config |
137 | */ | 137 | */ |
138 | u32 buf_size; | 138 | u32 buf_size; |
139 | u16 config_counter; | 139 | u16 config_counter; |
diff --git a/drivers/media/video/omap3isp/ispvideo.c b/drivers/media/video/omap3isp/ispvideo.c index 208a7ec739d7..9cd8f1aa567b 100644 --- a/drivers/media/video/omap3isp/ispvideo.c +++ b/drivers/media/video/omap3isp/ispvideo.c | |||
@@ -47,29 +47,59 @@ | |||
47 | 47 | ||
48 | static struct isp_format_info formats[] = { | 48 | static struct isp_format_info formats[] = { |
49 | { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8, | 49 | { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8, |
50 | V4L2_MBUS_FMT_Y8_1X8, V4L2_PIX_FMT_GREY, 8, }, | 50 | V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8, |
51 | V4L2_PIX_FMT_GREY, 8, }, | ||
52 | { V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y10_1X10, | ||
53 | V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y8_1X8, | ||
54 | V4L2_PIX_FMT_Y10, 10, }, | ||
55 | { V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y10_1X10, | ||
56 | V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y8_1X8, | ||
57 | V4L2_PIX_FMT_Y12, 12, }, | ||
58 | { V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8, | ||
59 | V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8, | ||
60 | V4L2_PIX_FMT_SBGGR8, 8, }, | ||
61 | { V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8, | ||
62 | V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8, | ||
63 | V4L2_PIX_FMT_SGBRG8, 8, }, | ||
64 | { V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8, | ||
65 | V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8, | ||
66 | V4L2_PIX_FMT_SGRBG8, 8, }, | ||
67 | { V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8, | ||
68 | V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8, | ||
69 | V4L2_PIX_FMT_SRGGB8, 8, }, | ||
51 | { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, | 70 | { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, |
52 | V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10DPCM8, 8, }, | 71 | V4L2_MBUS_FMT_SGRBG10_1X10, 0, |
72 | V4L2_PIX_FMT_SGRBG10DPCM8, 8, }, | ||
53 | { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10, | 73 | { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10, |
54 | V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10, 10, }, | 74 | V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR8_1X8, |
75 | V4L2_PIX_FMT_SBGGR10, 10, }, | ||
55 | { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10, | 76 | { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10, |
56 | V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10, 10, }, | 77 | V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG8_1X8, |
78 | V4L2_PIX_FMT_SGBRG10, 10, }, | ||
57 | { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10, | 79 | { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10, |
58 | V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10, 10, }, | 80 | V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG8_1X8, |
81 | V4L2_PIX_FMT_SGRBG10, 10, }, | ||
59 | { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10, | 82 | { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10, |
60 | V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10, 10, }, | 83 | V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB8_1X8, |
84 | V4L2_PIX_FMT_SRGGB10, 10, }, | ||
61 | { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10, | 85 | { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10, |
62 | V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12, 12, }, | 86 | V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR8_1X8, |
87 | V4L2_PIX_FMT_SBGGR12, 12, }, | ||
63 | { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10, | 88 | { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10, |
64 | V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12, 12, }, | 89 | V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG8_1X8, |
90 | V4L2_PIX_FMT_SGBRG12, 12, }, | ||
65 | { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10, | 91 | { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10, |
66 | V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12, 12, }, | 92 | V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG8_1X8, |
93 | V4L2_PIX_FMT_SGRBG12, 12, }, | ||
67 | { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10, | 94 | { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10, |
68 | V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12, 12, }, | 95 | V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB8_1X8, |
96 | V4L2_PIX_FMT_SRGGB12, 12, }, | ||
69 | { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16, | 97 | { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16, |
70 | V4L2_MBUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 16, }, | 98 | V4L2_MBUS_FMT_UYVY8_1X16, 0, |
99 | V4L2_PIX_FMT_UYVY, 16, }, | ||
71 | { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16, | 100 | { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16, |
72 | V4L2_MBUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 16, }, | 101 | V4L2_MBUS_FMT_YUYV8_1X16, 0, |
102 | V4L2_PIX_FMT_YUYV, 16, }, | ||
73 | }; | 103 | }; |
74 | 104 | ||
75 | const struct isp_format_info * | 105 | const struct isp_format_info * |
@@ -86,6 +116,37 @@ omap3isp_video_format_info(enum v4l2_mbus_pixelcode code) | |||
86 | } | 116 | } |
87 | 117 | ||
88 | /* | 118 | /* |
119 | * Decide whether desired output pixel code can be obtained with | ||
120 | * the lane shifter by shifting the input pixel code. | ||
121 | * @in: input pixelcode to shifter | ||
122 | * @out: output pixelcode from shifter | ||
123 | * @additional_shift: # of bits the sensor's LSB is offset from CAMEXT[0] | ||
124 | * | ||
125 | * return true if the combination is possible | ||
126 | * return false otherwise | ||
127 | */ | ||
128 | static bool isp_video_is_shiftable(enum v4l2_mbus_pixelcode in, | ||
129 | enum v4l2_mbus_pixelcode out, | ||
130 | unsigned int additional_shift) | ||
131 | { | ||
132 | const struct isp_format_info *in_info, *out_info; | ||
133 | |||
134 | if (in == out) | ||
135 | return true; | ||
136 | |||
137 | in_info = omap3isp_video_format_info(in); | ||
138 | out_info = omap3isp_video_format_info(out); | ||
139 | |||
140 | if ((in_info->flavor == 0) || (out_info->flavor == 0)) | ||
141 | return false; | ||
142 | |||
143 | if (in_info->flavor != out_info->flavor) | ||
144 | return false; | ||
145 | |||
146 | return in_info->bpp - out_info->bpp + additional_shift <= 6; | ||
147 | } | ||
148 | |||
149 | /* | ||
89 | * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format | 150 | * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format |
90 | * @video: ISP video instance | 151 | * @video: ISP video instance |
91 | * @mbus: v4l2_mbus_framefmt format (input) | 152 | * @mbus: v4l2_mbus_framefmt format (input) |
@@ -235,6 +296,7 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe) | |||
235 | return -EPIPE; | 296 | return -EPIPE; |
236 | 297 | ||
237 | while (1) { | 298 | while (1) { |
299 | unsigned int shifter_link; | ||
238 | /* Retrieve the sink format */ | 300 | /* Retrieve the sink format */ |
239 | pad = &subdev->entity.pads[0]; | 301 | pad = &subdev->entity.pads[0]; |
240 | if (!(pad->flags & MEDIA_PAD_FL_SINK)) | 302 | if (!(pad->flags & MEDIA_PAD_FL_SINK)) |
@@ -263,6 +325,10 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe) | |||
263 | return -ENOSPC; | 325 | return -ENOSPC; |
264 | } | 326 | } |
265 | 327 | ||
328 | /* If sink pad is on CCDC, the link has the lane shifter | ||
329 | * in the middle of it. */ | ||
330 | shifter_link = subdev == &isp->isp_ccdc.subdev; | ||
331 | |||
266 | /* Retrieve the source format */ | 332 | /* Retrieve the source format */ |
267 | pad = media_entity_remote_source(pad); | 333 | pad = media_entity_remote_source(pad); |
268 | if (pad == NULL || | 334 | if (pad == NULL || |
@@ -278,10 +344,24 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe) | |||
278 | return -EPIPE; | 344 | return -EPIPE; |
279 | 345 | ||
280 | /* Check if the two ends match */ | 346 | /* Check if the two ends match */ |
281 | if (fmt_source.format.code != fmt_sink.format.code || | 347 | if (fmt_source.format.width != fmt_sink.format.width || |
282 | fmt_source.format.width != fmt_sink.format.width || | ||
283 | fmt_source.format.height != fmt_sink.format.height) | 348 | fmt_source.format.height != fmt_sink.format.height) |
284 | return -EPIPE; | 349 | return -EPIPE; |
350 | |||
351 | if (shifter_link) { | ||
352 | unsigned int parallel_shift = 0; | ||
353 | if (isp->isp_ccdc.input == CCDC_INPUT_PARALLEL) { | ||
354 | struct isp_parallel_platform_data *pdata = | ||
355 | &((struct isp_v4l2_subdevs_group *) | ||
356 | subdev->host_priv)->bus.parallel; | ||
357 | parallel_shift = pdata->data_lane_shift * 2; | ||
358 | } | ||
359 | if (!isp_video_is_shiftable(fmt_source.format.code, | ||
360 | fmt_sink.format.code, | ||
361 | parallel_shift)) | ||
362 | return -EPIPE; | ||
363 | } else if (fmt_source.format.code != fmt_sink.format.code) | ||
364 | return -EPIPE; | ||
285 | } | 365 | } |
286 | 366 | ||
287 | return 0; | 367 | return 0; |
diff --git a/drivers/media/video/omap3isp/ispvideo.h b/drivers/media/video/omap3isp/ispvideo.h index 524a1acd0906..911bea64e78a 100644 --- a/drivers/media/video/omap3isp/ispvideo.h +++ b/drivers/media/video/omap3isp/ispvideo.h | |||
@@ -49,6 +49,8 @@ struct v4l2_pix_format; | |||
49 | * bits. Identical to @code if the format is 10 bits wide or less. | 49 | * bits. Identical to @code if the format is 10 bits wide or less. |
50 | * @uncompressed: V4L2 media bus format code for the corresponding uncompressed | 50 | * @uncompressed: V4L2 media bus format code for the corresponding uncompressed |
51 | * format. Identical to @code if the format is not DPCM compressed. | 51 | * format. Identical to @code if the format is not DPCM compressed. |
52 | * @flavor: V4L2 media bus format code for the same pixel layout but | ||
53 | * shifted to be 8 bits per pixel. =0 if format is not shiftable. | ||
52 | * @pixelformat: V4L2 pixel format FCC identifier | 54 | * @pixelformat: V4L2 pixel format FCC identifier |
53 | * @bpp: Bits per pixel | 55 | * @bpp: Bits per pixel |
54 | */ | 56 | */ |
@@ -56,6 +58,7 @@ struct isp_format_info { | |||
56 | enum v4l2_mbus_pixelcode code; | 58 | enum v4l2_mbus_pixelcode code; |
57 | enum v4l2_mbus_pixelcode truncated; | 59 | enum v4l2_mbus_pixelcode truncated; |
58 | enum v4l2_mbus_pixelcode uncompressed; | 60 | enum v4l2_mbus_pixelcode uncompressed; |
61 | enum v4l2_mbus_pixelcode flavor; | ||
59 | u32 pixelformat; | 62 | u32 pixelformat; |
60 | unsigned int bpp; | 63 | unsigned int bpp; |
61 | }; | 64 | }; |
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index 95f8b4e11e46..d142b40ea64e 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c | |||
@@ -527,7 +527,7 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, | |||
527 | if (ret) | 527 | if (ret) |
528 | return ret; | 528 | return ret; |
529 | 529 | ||
530 | if (vb2_is_streaming(&fimc->vid_cap.vbq) || fimc_capture_active(fimc)) | 530 | if (vb2_is_busy(&fimc->vid_cap.vbq) || fimc_capture_active(fimc)) |
531 | return -EBUSY; | 531 | return -EBUSY; |
532 | 532 | ||
533 | frame = &ctx->d_frame; | 533 | frame = &ctx->d_frame; |
@@ -539,8 +539,10 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, | |||
539 | return -EINVAL; | 539 | return -EINVAL; |
540 | } | 540 | } |
541 | 541 | ||
542 | for (i = 0; i < frame->fmt->colplanes; i++) | 542 | for (i = 0; i < frame->fmt->colplanes; i++) { |
543 | frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height; | 543 | frame->payload[i] = |
544 | (pix->width * pix->height * frame->fmt->depth[i]) >> 3; | ||
545 | } | ||
544 | 546 | ||
545 | /* Output DMA frame pixel size and offsets. */ | 547 | /* Output DMA frame pixel size and offsets. */ |
546 | frame->f_width = pix->plane_fmt[0].bytesperline * 8 | 548 | frame->f_width = pix->plane_fmt[0].bytesperline * 8 |
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 6c919b38a3d8..dc91a8511af6 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c | |||
@@ -361,10 +361,20 @@ static void fimc_capture_irq_handler(struct fimc_dev *fimc) | |||
361 | { | 361 | { |
362 | struct fimc_vid_cap *cap = &fimc->vid_cap; | 362 | struct fimc_vid_cap *cap = &fimc->vid_cap; |
363 | struct fimc_vid_buffer *v_buf; | 363 | struct fimc_vid_buffer *v_buf; |
364 | struct timeval *tv; | ||
365 | struct timespec ts; | ||
364 | 366 | ||
365 | if (!list_empty(&cap->active_buf_q) && | 367 | if (!list_empty(&cap->active_buf_q) && |
366 | test_bit(ST_CAPT_RUN, &fimc->state)) { | 368 | test_bit(ST_CAPT_RUN, &fimc->state)) { |
369 | ktime_get_real_ts(&ts); | ||
370 | |||
367 | v_buf = active_queue_pop(cap); | 371 | v_buf = active_queue_pop(cap); |
372 | |||
373 | tv = &v_buf->vb.v4l2_buf.timestamp; | ||
374 | tv->tv_sec = ts.tv_sec; | ||
375 | tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; | ||
376 | v_buf->vb.v4l2_buf.sequence = cap->frame_count++; | ||
377 | |||
368 | vb2_buffer_done(&v_buf->vb, VB2_BUF_STATE_DONE); | 378 | vb2_buffer_done(&v_buf->vb, VB2_BUF_STATE_DONE); |
369 | } | 379 | } |
370 | 380 | ||
@@ -758,7 +768,7 @@ static void fimc_unlock(struct vb2_queue *vq) | |||
758 | mutex_unlock(&ctx->fimc_dev->lock); | 768 | mutex_unlock(&ctx->fimc_dev->lock); |
759 | } | 769 | } |
760 | 770 | ||
761 | struct vb2_ops fimc_qops = { | 771 | static struct vb2_ops fimc_qops = { |
762 | .queue_setup = fimc_queue_setup, | 772 | .queue_setup = fimc_queue_setup, |
763 | .buf_prepare = fimc_buf_prepare, | 773 | .buf_prepare = fimc_buf_prepare, |
764 | .buf_queue = fimc_buf_queue, | 774 | .buf_queue = fimc_buf_queue, |
@@ -927,23 +937,23 @@ int fimc_vidioc_try_fmt_mplane(struct file *file, void *priv, | |||
927 | pix->num_planes = fmt->memplanes; | 937 | pix->num_planes = fmt->memplanes; |
928 | pix->colorspace = V4L2_COLORSPACE_JPEG; | 938 | pix->colorspace = V4L2_COLORSPACE_JPEG; |
929 | 939 | ||
930 | for (i = 0; i < pix->num_planes; ++i) { | ||
931 | int bpl = pix->plane_fmt[i].bytesperline; | ||
932 | 940 | ||
933 | dbg("[%d] bpl: %d, depth: %d, w: %d, h: %d", | 941 | for (i = 0; i < pix->num_planes; ++i) { |
934 | i, bpl, fmt->depth[i], pix->width, pix->height); | 942 | u32 bpl = pix->plane_fmt[i].bytesperline; |
943 | u32 *sizeimage = &pix->plane_fmt[i].sizeimage; | ||
935 | 944 | ||
936 | if (!bpl || (bpl * 8 / fmt->depth[i]) > pix->width) | 945 | if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width)) |
937 | bpl = (pix->width * fmt->depth[0]) >> 3; | 946 | bpl = pix->width; /* Planar */ |
938 | 947 | ||
939 | if (!pix->plane_fmt[i].sizeimage) | 948 | if (fmt->colplanes == 1 && /* Packed */ |
940 | pix->plane_fmt[i].sizeimage = pix->height * bpl; | 949 | (bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width)) |
950 | bpl = (pix->width * fmt->depth[0]) / 8; | ||
941 | 951 | ||
942 | pix->plane_fmt[i].bytesperline = bpl; | 952 | if (i == 0) /* Same bytesperline for each plane. */ |
953 | mod_x = bpl; | ||
943 | 954 | ||
944 | dbg("[%d]: bpl: %d, sizeimage: %d", | 955 | pix->plane_fmt[i].bytesperline = mod_x; |
945 | i, pix->plane_fmt[i].bytesperline, | 956 | *sizeimage = (pix->width * pix->height * fmt->depth[i]) / 8; |
946 | pix->plane_fmt[i].sizeimage); | ||
947 | } | 957 | } |
948 | 958 | ||
949 | return 0; | 959 | return 0; |
@@ -965,7 +975,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv, | |||
965 | 975 | ||
966 | vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); | 976 | vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); |
967 | 977 | ||
968 | if (vb2_is_streaming(vq)) { | 978 | if (vb2_is_busy(vq)) { |
969 | v4l2_err(&fimc->m2m.v4l2_dev, "queue (%d) busy\n", f->type); | 979 | v4l2_err(&fimc->m2m.v4l2_dev, "queue (%d) busy\n", f->type); |
970 | return -EBUSY; | 980 | return -EBUSY; |
971 | } | 981 | } |
@@ -985,8 +995,10 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv, | |||
985 | if (!frame->fmt) | 995 | if (!frame->fmt) |
986 | return -EINVAL; | 996 | return -EINVAL; |
987 | 997 | ||
988 | for (i = 0; i < frame->fmt->colplanes; i++) | 998 | for (i = 0; i < frame->fmt->colplanes; i++) { |
989 | frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height; | 999 | frame->payload[i] = |
1000 | (pix->width * pix->height * frame->fmt->depth[i]) / 8; | ||
1001 | } | ||
990 | 1002 | ||
991 | frame->f_width = pix->plane_fmt[0].bytesperline * 8 / | 1003 | frame->f_width = pix->plane_fmt[0].bytesperline * 8 / |
992 | frame->fmt->depth[0]; | 1004 | frame->fmt->depth[0]; |
@@ -1750,7 +1762,7 @@ static int __devexit fimc_remove(struct platform_device *pdev) | |||
1750 | } | 1762 | } |
1751 | 1763 | ||
1752 | /* Image pixel limits, similar across several FIMC HW revisions. */ | 1764 | /* Image pixel limits, similar across several FIMC HW revisions. */ |
1753 | static struct fimc_pix_limit s5p_pix_limit[3] = { | 1765 | static struct fimc_pix_limit s5p_pix_limit[4] = { |
1754 | [0] = { | 1766 | [0] = { |
1755 | .scaler_en_w = 3264, | 1767 | .scaler_en_w = 3264, |
1756 | .scaler_dis_w = 8192, | 1768 | .scaler_dis_w = 8192, |
@@ -1775,6 +1787,14 @@ static struct fimc_pix_limit s5p_pix_limit[3] = { | |||
1775 | .out_rot_en_w = 1280, | 1787 | .out_rot_en_w = 1280, |
1776 | .out_rot_dis_w = 1920, | 1788 | .out_rot_dis_w = 1920, |
1777 | }, | 1789 | }, |
1790 | [3] = { | ||
1791 | .scaler_en_w = 1920, | ||
1792 | .scaler_dis_w = 8192, | ||
1793 | .in_rot_en_h = 1366, | ||
1794 | .in_rot_dis_w = 8192, | ||
1795 | .out_rot_en_w = 1366, | ||
1796 | .out_rot_dis_w = 1920, | ||
1797 | }, | ||
1778 | }; | 1798 | }; |
1779 | 1799 | ||
1780 | static struct samsung_fimc_variant fimc0_variant_s5p = { | 1800 | static struct samsung_fimc_variant fimc0_variant_s5p = { |
@@ -1827,7 +1847,7 @@ static struct samsung_fimc_variant fimc2_variant_s5pv210 = { | |||
1827 | .pix_limit = &s5p_pix_limit[2], | 1847 | .pix_limit = &s5p_pix_limit[2], |
1828 | }; | 1848 | }; |
1829 | 1849 | ||
1830 | static struct samsung_fimc_variant fimc0_variant_s5pv310 = { | 1850 | static struct samsung_fimc_variant fimc0_variant_exynos4 = { |
1831 | .pix_hoff = 1, | 1851 | .pix_hoff = 1, |
1832 | .has_inp_rot = 1, | 1852 | .has_inp_rot = 1, |
1833 | .has_out_rot = 1, | 1853 | .has_out_rot = 1, |
@@ -1840,7 +1860,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv310 = { | |||
1840 | .pix_limit = &s5p_pix_limit[1], | 1860 | .pix_limit = &s5p_pix_limit[1], |
1841 | }; | 1861 | }; |
1842 | 1862 | ||
1843 | static struct samsung_fimc_variant fimc2_variant_s5pv310 = { | 1863 | static struct samsung_fimc_variant fimc2_variant_exynos4 = { |
1844 | .pix_hoff = 1, | 1864 | .pix_hoff = 1, |
1845 | .has_cistatus2 = 1, | 1865 | .has_cistatus2 = 1, |
1846 | .has_mainscaler_ext = 1, | 1866 | .has_mainscaler_ext = 1, |
@@ -1848,7 +1868,7 @@ static struct samsung_fimc_variant fimc2_variant_s5pv310 = { | |||
1848 | .min_out_pixsize = 16, | 1868 | .min_out_pixsize = 16, |
1849 | .hor_offs_align = 1, | 1869 | .hor_offs_align = 1, |
1850 | .out_buf_count = 32, | 1870 | .out_buf_count = 32, |
1851 | .pix_limit = &s5p_pix_limit[2], | 1871 | .pix_limit = &s5p_pix_limit[3], |
1852 | }; | 1872 | }; |
1853 | 1873 | ||
1854 | /* S5PC100 */ | 1874 | /* S5PC100 */ |
@@ -1874,12 +1894,12 @@ static struct samsung_fimc_driverdata fimc_drvdata_s5pv210 = { | |||
1874 | }; | 1894 | }; |
1875 | 1895 | ||
1876 | /* S5PV310, S5PC210 */ | 1896 | /* S5PV310, S5PC210 */ |
1877 | static struct samsung_fimc_driverdata fimc_drvdata_s5pv310 = { | 1897 | static struct samsung_fimc_driverdata fimc_drvdata_exynos4 = { |
1878 | .variant = { | 1898 | .variant = { |
1879 | [0] = &fimc0_variant_s5pv310, | 1899 | [0] = &fimc0_variant_exynos4, |
1880 | [1] = &fimc0_variant_s5pv310, | 1900 | [1] = &fimc0_variant_exynos4, |
1881 | [2] = &fimc0_variant_s5pv310, | 1901 | [2] = &fimc0_variant_exynos4, |
1882 | [3] = &fimc2_variant_s5pv310, | 1902 | [3] = &fimc2_variant_exynos4, |
1883 | }, | 1903 | }, |
1884 | .num_entities = 4, | 1904 | .num_entities = 4, |
1885 | .lclk_frequency = 166000000UL, | 1905 | .lclk_frequency = 166000000UL, |
@@ -1893,8 +1913,8 @@ static struct platform_device_id fimc_driver_ids[] = { | |||
1893 | .name = "s5pv210-fimc", | 1913 | .name = "s5pv210-fimc", |
1894 | .driver_data = (unsigned long)&fimc_drvdata_s5pv210, | 1914 | .driver_data = (unsigned long)&fimc_drvdata_s5pv210, |
1895 | }, { | 1915 | }, { |
1896 | .name = "s5pv310-fimc", | 1916 | .name = "exynos4-fimc", |
1897 | .driver_data = (unsigned long)&fimc_drvdata_s5pv310, | 1917 | .driver_data = (unsigned long)&fimc_drvdata_exynos4, |
1898 | }, | 1918 | }, |
1899 | {}, | 1919 | {}, |
1900 | }; | 1920 | }; |
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 3fe54bf41142..134e86bf6d97 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
@@ -922,7 +922,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int | |||
922 | /* Try 2560x1920, 1280x960, 640x480, 320x240 */ | 922 | /* Try 2560x1920, 1280x960, 640x480, 320x240 */ |
923 | mf.width = 2560 >> shift; | 923 | mf.width = 2560 >> shift; |
924 | mf.height = 1920 >> shift; | 924 | mf.height = 1920 >> shift; |
925 | ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, | 925 | ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, |
926 | s_mbus_fmt, &mf); | 926 | s_mbus_fmt, &mf); |
927 | if (ret < 0) | 927 | if (ret < 0) |
928 | return ret; | 928 | return ret; |
@@ -1224,7 +1224,7 @@ static int client_s_fmt(struct soc_camera_device *icd, | |||
1224 | struct v4l2_cropcap cap; | 1224 | struct v4l2_cropcap cap; |
1225 | int ret; | 1225 | int ret; |
1226 | 1226 | ||
1227 | ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, | 1227 | ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, |
1228 | s_mbus_fmt, mf); | 1228 | s_mbus_fmt, mf); |
1229 | if (ret < 0) | 1229 | if (ret < 0) |
1230 | return ret; | 1230 | return ret; |
@@ -1254,7 +1254,7 @@ static int client_s_fmt(struct soc_camera_device *icd, | |||
1254 | tmp_h = min(2 * tmp_h, max_height); | 1254 | tmp_h = min(2 * tmp_h, max_height); |
1255 | mf->width = tmp_w; | 1255 | mf->width = tmp_w; |
1256 | mf->height = tmp_h; | 1256 | mf->height = tmp_h; |
1257 | ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, | 1257 | ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, |
1258 | s_mbus_fmt, mf); | 1258 | s_mbus_fmt, mf); |
1259 | dev_geo(dev, "Camera scaled to %ux%u\n", | 1259 | dev_geo(dev, "Camera scaled to %ux%u\n", |
1260 | mf->width, mf->height); | 1260 | mf->width, mf->height); |
@@ -1658,7 +1658,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd, | |||
1658 | mf.code = xlate->code; | 1658 | mf.code = xlate->code; |
1659 | mf.colorspace = pix->colorspace; | 1659 | mf.colorspace = pix->colorspace; |
1660 | 1660 | ||
1661 | ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, try_mbus_fmt, &mf); | 1661 | ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, try_mbus_fmt, &mf); |
1662 | if (ret < 0) | 1662 | if (ret < 0) |
1663 | return ret; | 1663 | return ret; |
1664 | 1664 | ||
@@ -1682,7 +1682,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd, | |||
1682 | */ | 1682 | */ |
1683 | mf.width = 2560; | 1683 | mf.width = 2560; |
1684 | mf.height = 1920; | 1684 | mf.height = 1920; |
1685 | ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, | 1685 | ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, |
1686 | try_mbus_fmt, &mf); | 1686 | try_mbus_fmt, &mf); |
1687 | if (ret < 0) { | 1687 | if (ret < 0) { |
1688 | /* Shouldn't actually happen... */ | 1688 | /* Shouldn't actually happen... */ |
diff --git a/drivers/media/video/sh_mobile_csi2.c b/drivers/media/video/sh_mobile_csi2.c index dd1b81b1442b..98b87481fa94 100644 --- a/drivers/media/video/sh_mobile_csi2.c +++ b/drivers/media/video/sh_mobile_csi2.c | |||
@@ -38,6 +38,8 @@ struct sh_csi2 { | |||
38 | void __iomem *base; | 38 | void __iomem *base; |
39 | struct platform_device *pdev; | 39 | struct platform_device *pdev; |
40 | struct sh_csi2_client_config *client; | 40 | struct sh_csi2_client_config *client; |
41 | unsigned long (*query_bus_param)(struct soc_camera_device *); | ||
42 | int (*set_bus_param)(struct soc_camera_device *, unsigned long); | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | static int sh_csi2_try_fmt(struct v4l2_subdev *sd, | 45 | static int sh_csi2_try_fmt(struct v4l2_subdev *sd, |
@@ -208,6 +210,7 @@ static int sh_csi2_notify(struct notifier_block *nb, | |||
208 | case BUS_NOTIFY_BOUND_DRIVER: | 210 | case BUS_NOTIFY_BOUND_DRIVER: |
209 | snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s%s", | 211 | snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s%s", |
210 | dev_name(v4l2_dev->dev), ".mipi-csi"); | 212 | dev_name(v4l2_dev->dev), ".mipi-csi"); |
213 | priv->subdev.grp_id = (long)icd; | ||
211 | ret = v4l2_device_register_subdev(v4l2_dev, &priv->subdev); | 214 | ret = v4l2_device_register_subdev(v4l2_dev, &priv->subdev); |
212 | dev_dbg(dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret); | 215 | dev_dbg(dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret); |
213 | if (ret < 0) | 216 | if (ret < 0) |
@@ -215,6 +218,8 @@ static int sh_csi2_notify(struct notifier_block *nb, | |||
215 | 218 | ||
216 | priv->client = pdata->clients + i; | 219 | priv->client = pdata->clients + i; |
217 | 220 | ||
221 | priv->set_bus_param = icd->ops->set_bus_param; | ||
222 | priv->query_bus_param = icd->ops->query_bus_param; | ||
218 | icd->ops->set_bus_param = sh_csi2_set_bus_param; | 223 | icd->ops->set_bus_param = sh_csi2_set_bus_param; |
219 | icd->ops->query_bus_param = sh_csi2_query_bus_param; | 224 | icd->ops->query_bus_param = sh_csi2_query_bus_param; |
220 | 225 | ||
@@ -226,8 +231,10 @@ static int sh_csi2_notify(struct notifier_block *nb, | |||
226 | priv->client = NULL; | 231 | priv->client = NULL; |
227 | 232 | ||
228 | /* Driver is about to be unbound */ | 233 | /* Driver is about to be unbound */ |
229 | icd->ops->set_bus_param = NULL; | 234 | icd->ops->set_bus_param = priv->set_bus_param; |
230 | icd->ops->query_bus_param = NULL; | 235 | icd->ops->query_bus_param = priv->query_bus_param; |
236 | priv->set_bus_param = NULL; | ||
237 | priv->query_bus_param = NULL; | ||
231 | 238 | ||
232 | v4l2_device_unregister_subdev(&priv->subdev); | 239 | v4l2_device_unregister_subdev(&priv->subdev); |
233 | 240 | ||
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 46284489e4eb..3973f9a94753 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -996,10 +996,11 @@ static void soc_camera_free_i2c(struct soc_camera_device *icd) | |||
996 | { | 996 | { |
997 | struct i2c_client *client = | 997 | struct i2c_client *client = |
998 | to_i2c_client(to_soc_camera_control(icd)); | 998 | to_i2c_client(to_soc_camera_control(icd)); |
999 | struct i2c_adapter *adap = client->adapter; | ||
999 | dev_set_drvdata(&icd->dev, NULL); | 1000 | dev_set_drvdata(&icd->dev, NULL); |
1000 | v4l2_device_unregister_subdev(i2c_get_clientdata(client)); | 1001 | v4l2_device_unregister_subdev(i2c_get_clientdata(client)); |
1001 | i2c_unregister_device(client); | 1002 | i2c_unregister_device(client); |
1002 | i2c_put_adapter(client->adapter); | 1003 | i2c_put_adapter(adap); |
1003 | } | 1004 | } |
1004 | #else | 1005 | #else |
1005 | #define soc_camera_init_i2c(icd, icl) (-ENODEV) | 1006 | #define soc_camera_init_i2c(icd, icl) (-ENODEV) |
@@ -1071,6 +1072,9 @@ static int soc_camera_probe(struct device *dev) | |||
1071 | } | 1072 | } |
1072 | } | 1073 | } |
1073 | 1074 | ||
1075 | sd = soc_camera_to_subdev(icd); | ||
1076 | sd->grp_id = (long)icd; | ||
1077 | |||
1074 | /* At this point client .probe() should have run already */ | 1078 | /* At this point client .probe() should have run already */ |
1075 | ret = soc_camera_init_user_formats(icd); | 1079 | ret = soc_camera_init_user_formats(icd); |
1076 | if (ret < 0) | 1080 | if (ret < 0) |
@@ -1092,7 +1096,6 @@ static int soc_camera_probe(struct device *dev) | |||
1092 | goto evidstart; | 1096 | goto evidstart; |
1093 | 1097 | ||
1094 | /* Try to improve our guess of a reasonable window format */ | 1098 | /* Try to improve our guess of a reasonable window format */ |
1095 | sd = soc_camera_to_subdev(icd); | ||
1096 | if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) { | 1099 | if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) { |
1097 | icd->user_width = mf.width; | 1100 | icd->user_width = mf.width; |
1098 | icd->user_height = mf.height; | 1101 | icd->user_height = mf.height; |
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 498e6742579e..6dc7196296b3 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -389,7 +389,8 @@ static int v4l2_open(struct inode *inode, struct file *filp) | |||
389 | video_get(vdev); | 389 | video_get(vdev); |
390 | mutex_unlock(&videodev_lock); | 390 | mutex_unlock(&videodev_lock); |
391 | #if defined(CONFIG_MEDIA_CONTROLLER) | 391 | #if defined(CONFIG_MEDIA_CONTROLLER) |
392 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) { | 392 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && |
393 | vdev->vfl_type != VFL_TYPE_SUBDEV) { | ||
393 | entity = media_entity_get(&vdev->entity); | 394 | entity = media_entity_get(&vdev->entity); |
394 | if (!entity) { | 395 | if (!entity) { |
395 | ret = -EBUSY; | 396 | ret = -EBUSY; |
@@ -415,7 +416,8 @@ err: | |||
415 | /* decrease the refcount in case of an error */ | 416 | /* decrease the refcount in case of an error */ |
416 | if (ret) { | 417 | if (ret) { |
417 | #if defined(CONFIG_MEDIA_CONTROLLER) | 418 | #if defined(CONFIG_MEDIA_CONTROLLER) |
418 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) | 419 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && |
420 | vdev->vfl_type != VFL_TYPE_SUBDEV) | ||
419 | media_entity_put(entity); | 421 | media_entity_put(entity); |
420 | #endif | 422 | #endif |
421 | video_put(vdev); | 423 | video_put(vdev); |
@@ -437,7 +439,8 @@ static int v4l2_release(struct inode *inode, struct file *filp) | |||
437 | mutex_unlock(vdev->lock); | 439 | mutex_unlock(vdev->lock); |
438 | } | 440 | } |
439 | #if defined(CONFIG_MEDIA_CONTROLLER) | 441 | #if defined(CONFIG_MEDIA_CONTROLLER) |
440 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) | 442 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && |
443 | vdev->vfl_type != VFL_TYPE_SUBDEV) | ||
441 | media_entity_put(&vdev->entity); | 444 | media_entity_put(&vdev->entity); |
442 | #endif | 445 | #endif |
443 | /* decrease the refcount unconditionally since the release() | 446 | /* decrease the refcount unconditionally since the release() |
@@ -686,7 +689,8 @@ int __video_register_device(struct video_device *vdev, int type, int nr, | |||
686 | 689 | ||
687 | #if defined(CONFIG_MEDIA_CONTROLLER) | 690 | #if defined(CONFIG_MEDIA_CONTROLLER) |
688 | /* Part 5: Register the entity. */ | 691 | /* Part 5: Register the entity. */ |
689 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) { | 692 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && |
693 | vdev->vfl_type != VFL_TYPE_SUBDEV) { | ||
690 | vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; | 694 | vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; |
691 | vdev->entity.name = vdev->name; | 695 | vdev->entity.name = vdev->name; |
692 | vdev->entity.v4l.major = VIDEO_MAJOR; | 696 | vdev->entity.v4l.major = VIDEO_MAJOR; |
@@ -733,7 +737,8 @@ void video_unregister_device(struct video_device *vdev) | |||
733 | return; | 737 | return; |
734 | 738 | ||
735 | #if defined(CONFIG_MEDIA_CONTROLLER) | 739 | #if defined(CONFIG_MEDIA_CONTROLLER) |
736 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) | 740 | if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && |
741 | vdev->vfl_type != VFL_TYPE_SUBDEV) | ||
737 | media_device_unregister_entity(&vdev->entity); | 742 | media_device_unregister_entity(&vdev->entity); |
738 | #endif | 743 | #endif |
739 | 744 | ||
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 6698c77e0f64..6ba1461d51ef 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c | |||
@@ -37,6 +37,9 @@ module_param(debug, int, 0644); | |||
37 | #define call_qop(q, op, args...) \ | 37 | #define call_qop(q, op, args...) \ |
38 | (((q)->ops->op) ? ((q)->ops->op(args)) : 0) | 38 | (((q)->ops->op) ? ((q)->ops->op(args)) : 0) |
39 | 39 | ||
40 | #define V4L2_BUFFER_STATE_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \ | ||
41 | V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR) | ||
42 | |||
40 | /** | 43 | /** |
41 | * __vb2_buf_mem_alloc() - allocate video memory for the given buffer | 44 | * __vb2_buf_mem_alloc() - allocate video memory for the given buffer |
42 | */ | 45 | */ |
@@ -51,7 +54,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb, | |||
51 | for (plane = 0; plane < vb->num_planes; ++plane) { | 54 | for (plane = 0; plane < vb->num_planes; ++plane) { |
52 | mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane], | 55 | mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane], |
53 | plane_sizes[plane]); | 56 | plane_sizes[plane]); |
54 | if (!mem_priv) | 57 | if (IS_ERR_OR_NULL(mem_priv)) |
55 | goto free; | 58 | goto free; |
56 | 59 | ||
57 | /* Associate allocator private data with this plane */ | 60 | /* Associate allocator private data with this plane */ |
@@ -284,7 +287,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) | |||
284 | struct vb2_queue *q = vb->vb2_queue; | 287 | struct vb2_queue *q = vb->vb2_queue; |
285 | int ret = 0; | 288 | int ret = 0; |
286 | 289 | ||
287 | /* Copy back data such as timestamp, input, etc. */ | 290 | /* Copy back data such as timestamp, flags, input, etc. */ |
288 | memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); | 291 | memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); |
289 | b->input = vb->v4l2_buf.input; | 292 | b->input = vb->v4l2_buf.input; |
290 | b->reserved = vb->v4l2_buf.reserved; | 293 | b->reserved = vb->v4l2_buf.reserved; |
@@ -313,7 +316,10 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) | |||
313 | b->m.userptr = vb->v4l2_planes[0].m.userptr; | 316 | b->m.userptr = vb->v4l2_planes[0].m.userptr; |
314 | } | 317 | } |
315 | 318 | ||
316 | b->flags = 0; | 319 | /* |
320 | * Clear any buffer state related flags. | ||
321 | */ | ||
322 | b->flags &= ~V4L2_BUFFER_STATE_FLAGS; | ||
317 | 323 | ||
318 | switch (vb->state) { | 324 | switch (vb->state) { |
319 | case VB2_BUF_STATE_QUEUED: | 325 | case VB2_BUF_STATE_QUEUED: |
@@ -519,6 +525,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | |||
519 | num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); | 525 | num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); |
520 | memset(plane_sizes, 0, sizeof(plane_sizes)); | 526 | memset(plane_sizes, 0, sizeof(plane_sizes)); |
521 | memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); | 527 | memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); |
528 | q->memory = req->memory; | ||
522 | 529 | ||
523 | /* | 530 | /* |
524 | * Ask the driver how many buffers and planes per buffer it requires. | 531 | * Ask the driver how many buffers and planes per buffer it requires. |
@@ -560,8 +567,6 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | |||
560 | ret = num_buffers; | 567 | ret = num_buffers; |
561 | } | 568 | } |
562 | 569 | ||
563 | q->memory = req->memory; | ||
564 | |||
565 | /* | 570 | /* |
566 | * Return the number of successfully allocated buffers | 571 | * Return the number of successfully allocated buffers |
567 | * to the userspace. | 572 | * to the userspace. |
@@ -715,6 +720,8 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b, | |||
715 | 720 | ||
716 | vb->v4l2_buf.field = b->field; | 721 | vb->v4l2_buf.field = b->field; |
717 | vb->v4l2_buf.timestamp = b->timestamp; | 722 | vb->v4l2_buf.timestamp = b->timestamp; |
723 | vb->v4l2_buf.input = b->input; | ||
724 | vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS; | ||
718 | 725 | ||
719 | return 0; | 726 | return 0; |
720 | } | 727 | } |
diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index 58205d596138..a790a5f8c06f 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c | |||
@@ -46,7 +46,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx, unsigned long size) | |||
46 | GFP_KERNEL); | 46 | GFP_KERNEL); |
47 | if (!buf->vaddr) { | 47 | if (!buf->vaddr) { |
48 | dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n", | 48 | dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n", |
49 | buf->size); | 49 | size); |
50 | kfree(buf); | 50 | kfree(buf); |
51 | return ERR_PTR(-ENOMEM); | 51 | return ERR_PTR(-ENOMEM); |
52 | } | 52 | } |
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 63667a8f140c..d6d62fd07ee9 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c | |||
@@ -284,6 +284,7 @@ int mmc_add_card(struct mmc_card *card) | |||
284 | type = "SD-combo"; | 284 | type = "SD-combo"; |
285 | if (mmc_card_blockaddr(card)) | 285 | if (mmc_card_blockaddr(card)) |
286 | type = "SDHC-combo"; | 286 | type = "SDHC-combo"; |
287 | break; | ||
287 | default: | 288 | default: |
288 | type = "?"; | 289 | type = "?"; |
289 | break; | 290 | break; |
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 461e6a17fb90..2b200c1cfbba 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c | |||
@@ -94,7 +94,7 @@ static void mmc_host_clk_gate_delayed(struct mmc_host *host) | |||
94 | spin_unlock_irqrestore(&host->clk_lock, flags); | 94 | spin_unlock_irqrestore(&host->clk_lock, flags); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | mutex_lock(&host->clk_gate_mutex); | 97 | mmc_claim_host(host); |
98 | spin_lock_irqsave(&host->clk_lock, flags); | 98 | spin_lock_irqsave(&host->clk_lock, flags); |
99 | if (!host->clk_requests) { | 99 | if (!host->clk_requests) { |
100 | spin_unlock_irqrestore(&host->clk_lock, flags); | 100 | spin_unlock_irqrestore(&host->clk_lock, flags); |
@@ -104,7 +104,7 @@ static void mmc_host_clk_gate_delayed(struct mmc_host *host) | |||
104 | pr_debug("%s: gated MCI clock\n", mmc_hostname(host)); | 104 | pr_debug("%s: gated MCI clock\n", mmc_hostname(host)); |
105 | } | 105 | } |
106 | spin_unlock_irqrestore(&host->clk_lock, flags); | 106 | spin_unlock_irqrestore(&host->clk_lock, flags); |
107 | mutex_unlock(&host->clk_gate_mutex); | 107 | mmc_release_host(host); |
108 | } | 108 | } |
109 | 109 | ||
110 | /* | 110 | /* |
@@ -130,7 +130,7 @@ void mmc_host_clk_ungate(struct mmc_host *host) | |||
130 | { | 130 | { |
131 | unsigned long flags; | 131 | unsigned long flags; |
132 | 132 | ||
133 | mutex_lock(&host->clk_gate_mutex); | 133 | mmc_claim_host(host); |
134 | spin_lock_irqsave(&host->clk_lock, flags); | 134 | spin_lock_irqsave(&host->clk_lock, flags); |
135 | if (host->clk_gated) { | 135 | if (host->clk_gated) { |
136 | spin_unlock_irqrestore(&host->clk_lock, flags); | 136 | spin_unlock_irqrestore(&host->clk_lock, flags); |
@@ -140,7 +140,7 @@ void mmc_host_clk_ungate(struct mmc_host *host) | |||
140 | } | 140 | } |
141 | host->clk_requests++; | 141 | host->clk_requests++; |
142 | spin_unlock_irqrestore(&host->clk_lock, flags); | 142 | spin_unlock_irqrestore(&host->clk_lock, flags); |
143 | mutex_unlock(&host->clk_gate_mutex); | 143 | mmc_release_host(host); |
144 | } | 144 | } |
145 | 145 | ||
146 | /** | 146 | /** |
@@ -215,7 +215,6 @@ static inline void mmc_host_clk_init(struct mmc_host *host) | |||
215 | host->clk_gated = false; | 215 | host->clk_gated = false; |
216 | INIT_WORK(&host->clk_gate_work, mmc_host_clk_gate_work); | 216 | INIT_WORK(&host->clk_gate_work, mmc_host_clk_gate_work); |
217 | spin_lock_init(&host->clk_lock); | 217 | spin_lock_init(&host->clk_lock); |
218 | mutex_init(&host->clk_gate_mutex); | ||
219 | } | 218 | } |
220 | 219 | ||
221 | /** | 220 | /** |
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 2e032f0e8cf4..a6c329040140 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
@@ -832,7 +832,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id) | |||
832 | return IRQ_HANDLED; | 832 | return IRQ_HANDLED; |
833 | } | 833 | } |
834 | 834 | ||
835 | if (end_command) | 835 | if (end_command && host->cmd) |
836 | mmc_omap_cmd_done(host, host->cmd); | 836 | mmc_omap_cmd_done(host, host->cmd); |
837 | if (host->data != NULL) { | 837 | if (host->data != NULL) { |
838 | if (transfer_error) | 838 | if (transfer_error) |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index a136be706347..f8b5f37007b2 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -957,6 +957,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
957 | host->ioaddr = pci_ioremap_bar(pdev, bar); | 957 | host->ioaddr = pci_ioremap_bar(pdev, bar); |
958 | if (!host->ioaddr) { | 958 | if (!host->ioaddr) { |
959 | dev_err(&pdev->dev, "failed to remap registers\n"); | 959 | dev_err(&pdev->dev, "failed to remap registers\n"); |
960 | ret = -ENOMEM; | ||
960 | goto release; | 961 | goto release; |
961 | } | 962 | } |
962 | 963 | ||
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9e15f41f87be..5d20661bc357 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -1334,6 +1334,13 @@ static void sdhci_tasklet_finish(unsigned long param) | |||
1334 | 1334 | ||
1335 | host = (struct sdhci_host*)param; | 1335 | host = (struct sdhci_host*)param; |
1336 | 1336 | ||
1337 | /* | ||
1338 | * If this tasklet gets rescheduled while running, it will | ||
1339 | * be run again afterwards but without any active request. | ||
1340 | */ | ||
1341 | if (!host->mrq) | ||
1342 | return; | ||
1343 | |||
1337 | spin_lock_irqsave(&host->lock, flags); | 1344 | spin_lock_irqsave(&host->lock, flags); |
1338 | 1345 | ||
1339 | del_timer(&host->timer); | 1346 | del_timer(&host->timer); |
@@ -1345,7 +1352,7 @@ static void sdhci_tasklet_finish(unsigned long param) | |||
1345 | * upon error conditions. | 1352 | * upon error conditions. |
1346 | */ | 1353 | */ |
1347 | if (!(host->flags & SDHCI_DEVICE_DEAD) && | 1354 | if (!(host->flags & SDHCI_DEVICE_DEAD) && |
1348 | (mrq->cmd->error || | 1355 | ((mrq->cmd && mrq->cmd->error) || |
1349 | (mrq->data && (mrq->data->error || | 1356 | (mrq->data && (mrq->data->error || |
1350 | (mrq->data->stop && mrq->data->stop->error))) || | 1357 | (mrq->data->stop && mrq->data->stop->error))) || |
1351 | (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { | 1358 | (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { |
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index 62d37de6de76..710339a85c84 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -728,15 +728,15 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
728 | tmio_mmc_set_clock(host, ios->clock); | 728 | tmio_mmc_set_clock(host, ios->clock); |
729 | 729 | ||
730 | /* Power sequence - OFF -> UP -> ON */ | 730 | /* Power sequence - OFF -> UP -> ON */ |
731 | if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { | 731 | if (ios->power_mode == MMC_POWER_UP) { |
732 | /* power up SD bus */ | ||
733 | if (host->set_pwr) | ||
734 | host->set_pwr(host->pdev, 1); | ||
735 | } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { | ||
732 | /* power down SD bus */ | 736 | /* power down SD bus */ |
733 | if (ios->power_mode == MMC_POWER_OFF && host->set_pwr) | 737 | if (ios->power_mode == MMC_POWER_OFF && host->set_pwr) |
734 | host->set_pwr(host->pdev, 0); | 738 | host->set_pwr(host->pdev, 0); |
735 | tmio_mmc_clk_stop(host); | 739 | tmio_mmc_clk_stop(host); |
736 | } else if (ios->power_mode == MMC_POWER_UP) { | ||
737 | /* power up SD bus */ | ||
738 | if (host->set_pwr) | ||
739 | host->set_pwr(host->pdev, 1); | ||
740 | } else { | 740 | } else { |
741 | /* start bus clock */ | 741 | /* start bus clock */ |
742 | tmio_mmc_clk_start(host); | 742 | tmio_mmc_clk_start(host); |
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index 96c0b34ba8db..657b9f4b6f9b 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
@@ -400,7 +400,7 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr) | |||
400 | doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE); | 400 | doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE); |
401 | doc200x_hwcontrol(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); | 401 | doc200x_hwcontrol(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); |
402 | 402 | ||
403 | /* We can't' use dev_ready here, but at least we wait for the | 403 | /* We can't use dev_ready here, but at least we wait for the |
404 | * command to complete | 404 | * command to complete |
405 | */ | 405 | */ |
406 | udelay(50); | 406 | udelay(50); |
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c index 88495c48a81d..241b185e6569 100644 --- a/drivers/net/amd8111e.c +++ b/drivers/net/amd8111e.c | |||
@@ -106,7 +106,7 @@ MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version "M | |||
106 | MODULE_LICENSE("GPL"); | 106 | MODULE_LICENSE("GPL"); |
107 | MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); | 107 | MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); |
108 | module_param_array(speed_duplex, int, NULL, 0); | 108 | module_param_array(speed_duplex, int, NULL, 0); |
109 | MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotitate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex"); | 109 | MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotiate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex"); |
110 | module_param_array(coalesce, bool, NULL, 0); | 110 | module_param_array(coalesce, bool, NULL, 0); |
111 | MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0: Disable"); | 111 | MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0: Disable"); |
112 | module_param_array(dynamic_ipg, bool, NULL, 0); | 112 | module_param_array(dynamic_ipg, bool, NULL, 0); |
diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h index 7cb375e0e29c..925929d764ca 100644 --- a/drivers/net/atl1c/atl1c.h +++ b/drivers/net/atl1c/atl1c.h | |||
@@ -566,9 +566,9 @@ struct atl1c_adapter { | |||
566 | #define __AT_TESTING 0x0001 | 566 | #define __AT_TESTING 0x0001 |
567 | #define __AT_RESETTING 0x0002 | 567 | #define __AT_RESETTING 0x0002 |
568 | #define __AT_DOWN 0x0003 | 568 | #define __AT_DOWN 0x0003 |
569 | u8 work_event; | 569 | unsigned long work_event; |
570 | #define ATL1C_WORK_EVENT_RESET 0x01 | 570 | #define ATL1C_WORK_EVENT_RESET 0 |
571 | #define ATL1C_WORK_EVENT_LINK_CHANGE 0x02 | 571 | #define ATL1C_WORK_EVENT_LINK_CHANGE 1 |
572 | u32 msg_enable; | 572 | u32 msg_enable; |
573 | 573 | ||
574 | bool have_msi; | 574 | bool have_msi; |
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c index 7d9d5067a65c..a6e1c36e48e6 100644 --- a/drivers/net/atl1c/atl1c_main.c +++ b/drivers/net/atl1c/atl1c_main.c | |||
@@ -325,7 +325,7 @@ static void atl1c_link_chg_event(struct atl1c_adapter *adapter) | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | adapter->work_event |= ATL1C_WORK_EVENT_LINK_CHANGE; | 328 | set_bit(ATL1C_WORK_EVENT_LINK_CHANGE, &adapter->work_event); |
329 | schedule_work(&adapter->common_task); | 329 | schedule_work(&adapter->common_task); |
330 | } | 330 | } |
331 | 331 | ||
@@ -337,20 +337,16 @@ static void atl1c_common_task(struct work_struct *work) | |||
337 | adapter = container_of(work, struct atl1c_adapter, common_task); | 337 | adapter = container_of(work, struct atl1c_adapter, common_task); |
338 | netdev = adapter->netdev; | 338 | netdev = adapter->netdev; |
339 | 339 | ||
340 | if (adapter->work_event & ATL1C_WORK_EVENT_RESET) { | 340 | if (test_and_clear_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event)) { |
341 | adapter->work_event &= ~ATL1C_WORK_EVENT_RESET; | ||
342 | netif_device_detach(netdev); | 341 | netif_device_detach(netdev); |
343 | atl1c_down(adapter); | 342 | atl1c_down(adapter); |
344 | atl1c_up(adapter); | 343 | atl1c_up(adapter); |
345 | netif_device_attach(netdev); | 344 | netif_device_attach(netdev); |
346 | return; | ||
347 | } | 345 | } |
348 | 346 | ||
349 | if (adapter->work_event & ATL1C_WORK_EVENT_LINK_CHANGE) { | 347 | if (test_and_clear_bit(ATL1C_WORK_EVENT_LINK_CHANGE, |
350 | adapter->work_event &= ~ATL1C_WORK_EVENT_LINK_CHANGE; | 348 | &adapter->work_event)) |
351 | atl1c_check_link_status(adapter); | 349 | atl1c_check_link_status(adapter); |
352 | } | ||
353 | return; | ||
354 | } | 350 | } |
355 | 351 | ||
356 | 352 | ||
@@ -369,7 +365,7 @@ static void atl1c_tx_timeout(struct net_device *netdev) | |||
369 | struct atl1c_adapter *adapter = netdev_priv(netdev); | 365 | struct atl1c_adapter *adapter = netdev_priv(netdev); |
370 | 366 | ||
371 | /* Do the reset outside of interrupt context */ | 367 | /* Do the reset outside of interrupt context */ |
372 | adapter->work_event |= ATL1C_WORK_EVENT_RESET; | 368 | set_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event); |
373 | schedule_work(&adapter->common_task); | 369 | schedule_work(&adapter->common_task); |
374 | } | 370 | } |
375 | 371 | ||
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index 7cb5a114c733..02a0443d1821 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -1873,6 +1873,7 @@ static void be_worker(struct work_struct *work) | |||
1873 | be_detect_dump_ue(adapter); | 1873 | be_detect_dump_ue(adapter); |
1874 | 1874 | ||
1875 | reschedule: | 1875 | reschedule: |
1876 | adapter->work_counter++; | ||
1876 | schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000)); | 1877 | schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000)); |
1877 | } | 1878 | } |
1878 | 1879 | ||
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 8e6d618b5305..d8383a9af9ad 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -8413,6 +8413,8 @@ bnx2_remove_one(struct pci_dev *pdev) | |||
8413 | 8413 | ||
8414 | unregister_netdev(dev); | 8414 | unregister_netdev(dev); |
8415 | 8415 | ||
8416 | del_timer_sync(&bp->timer); | ||
8417 | |||
8416 | if (bp->mips_firmware) | 8418 | if (bp->mips_firmware) |
8417 | release_firmware(bp->mips_firmware); | 8419 | release_firmware(bp->mips_firmware); |
8418 | if (bp->rv2p_firmware) | 8420 | if (bp->rv2p_firmware) |
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c index e83ac6dd6fc0..16581df5ee4e 100644 --- a/drivers/net/bnx2x/bnx2x_cmn.c +++ b/drivers/net/bnx2x/bnx2x_cmn.c | |||
@@ -2019,15 +2019,23 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb, | |||
2019 | static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb, | 2019 | static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb, |
2020 | u32 *parsing_data, u32 xmit_type) | 2020 | u32 *parsing_data, u32 xmit_type) |
2021 | { | 2021 | { |
2022 | *parsing_data |= ((tcp_hdrlen(skb)/4) << | 2022 | *parsing_data |= |
2023 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) & | 2023 | ((((u8 *)skb_transport_header(skb) - skb->data) >> 1) << |
2024 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW; | 2024 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) & |
2025 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W; | ||
2025 | 2026 | ||
2026 | *parsing_data |= ((((u8 *)tcp_hdr(skb) - skb->data) / 2) << | 2027 | if (xmit_type & XMIT_CSUM_TCP) { |
2027 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) & | 2028 | *parsing_data |= ((tcp_hdrlen(skb) / 4) << |
2028 | ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W; | 2029 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) & |
2030 | ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW; | ||
2029 | 2031 | ||
2030 | return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data; | 2032 | return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data; |
2033 | } else | ||
2034 | /* We support checksum offload for TCP and UDP only. | ||
2035 | * No need to pass the UDP header length - it's a constant. | ||
2036 | */ | ||
2037 | return skb_transport_header(skb) + | ||
2038 | sizeof(struct udphdr) - skb->data; | ||
2031 | } | 2039 | } |
2032 | 2040 | ||
2033 | /** | 2041 | /** |
@@ -2043,7 +2051,7 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb, | |||
2043 | struct eth_tx_parse_bd_e1x *pbd, | 2051 | struct eth_tx_parse_bd_e1x *pbd, |
2044 | u32 xmit_type) | 2052 | u32 xmit_type) |
2045 | { | 2053 | { |
2046 | u8 hlen = (skb_network_header(skb) - skb->data) / 2; | 2054 | u8 hlen = (skb_network_header(skb) - skb->data) >> 1; |
2047 | 2055 | ||
2048 | /* for now NS flag is not used in Linux */ | 2056 | /* for now NS flag is not used in Linux */ |
2049 | pbd->global_data = | 2057 | pbd->global_data = |
@@ -2051,9 +2059,15 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb, | |||
2051 | ETH_TX_PARSE_BD_E1X_LLC_SNAP_EN_SHIFT)); | 2059 | ETH_TX_PARSE_BD_E1X_LLC_SNAP_EN_SHIFT)); |
2052 | 2060 | ||
2053 | pbd->ip_hlen_w = (skb_transport_header(skb) - | 2061 | pbd->ip_hlen_w = (skb_transport_header(skb) - |
2054 | skb_network_header(skb)) / 2; | 2062 | skb_network_header(skb)) >> 1; |
2055 | 2063 | ||
2056 | hlen += pbd->ip_hlen_w + tcp_hdrlen(skb) / 2; | 2064 | hlen += pbd->ip_hlen_w; |
2065 | |||
2066 | /* We support checksum offload for TCP and UDP only */ | ||
2067 | if (xmit_type & XMIT_CSUM_TCP) | ||
2068 | hlen += tcp_hdrlen(skb) / 2; | ||
2069 | else | ||
2070 | hlen += sizeof(struct udphdr) / 2; | ||
2057 | 2071 | ||
2058 | pbd->total_hlen_w = cpu_to_le16(hlen); | 2072 | pbd->total_hlen_w = cpu_to_le16(hlen); |
2059 | hlen = hlen*2; | 2073 | hlen = hlen*2; |
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 494bf960442d..31912f17653f 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -1482,8 +1482,11 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best, | |||
1482 | 1482 | ||
1483 | static int agg_device_up(const struct aggregator *agg) | 1483 | static int agg_device_up(const struct aggregator *agg) |
1484 | { | 1484 | { |
1485 | return (netif_running(agg->slave->dev) && | 1485 | struct port *port = agg->lag_ports; |
1486 | netif_carrier_ok(agg->slave->dev)); | 1486 | if (!port) |
1487 | return 0; | ||
1488 | return (netif_running(port->slave->dev) && | ||
1489 | netif_carrier_ok(port->slave->dev)); | ||
1487 | } | 1490 | } |
1488 | 1491 | ||
1489 | /** | 1492 | /** |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index f75d3144b8a5..53c0f04b1b23 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -3040,11 +3040,14 @@ static void ehea_rereg_mrs(void) | |||
3040 | 3040 | ||
3041 | if (dev->flags & IFF_UP) { | 3041 | if (dev->flags & IFF_UP) { |
3042 | mutex_lock(&port->port_lock); | 3042 | mutex_lock(&port->port_lock); |
3043 | port_napi_enable(port); | ||
3044 | ret = ehea_restart_qps(dev); | 3043 | ret = ehea_restart_qps(dev); |
3045 | check_sqs(port); | 3044 | if (!ret) { |
3046 | if (!ret) | 3045 | check_sqs(port); |
3046 | port_napi_enable(port); | ||
3047 | netif_wake_queue(dev); | 3047 | netif_wake_queue(dev); |
3048 | } else { | ||
3049 | netdev_err(dev, "Unable to restart QPS\n"); | ||
3050 | } | ||
3048 | mutex_unlock(&port->port_lock); | 3051 | mutex_unlock(&port->port_lock); |
3049 | } | 3052 | } |
3050 | } | 3053 | } |
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c index 61035fc5599b..b9fbc83d64a7 100644 --- a/drivers/net/fs_enet/mac-fec.c +++ b/drivers/net/fs_enet/mac-fec.c | |||
@@ -226,8 +226,8 @@ static void set_multicast_finish(struct net_device *dev) | |||
226 | } | 226 | } |
227 | 227 | ||
228 | FC(fecp, r_cntrl, FEC_RCNTRL_PROM); | 228 | FC(fecp, r_cntrl, FEC_RCNTRL_PROM); |
229 | FW(fecp, hash_table_high, fep->fec.hthi); | 229 | FW(fecp, grp_hash_table_high, fep->fec.hthi); |
230 | FW(fecp, hash_table_low, fep->fec.htlo); | 230 | FW(fecp, grp_hash_table_low, fep->fec.htlo); |
231 | } | 231 | } |
232 | 232 | ||
233 | static void set_multicast_list(struct net_device *dev) | 233 | static void set_multicast_list(struct net_device *dev) |
@@ -273,8 +273,8 @@ static void restart(struct net_device *dev) | |||
273 | /* | 273 | /* |
274 | * Reset all multicast. | 274 | * Reset all multicast. |
275 | */ | 275 | */ |
276 | FW(fecp, hash_table_high, fep->fec.hthi); | 276 | FW(fecp, grp_hash_table_high, fep->fec.hthi); |
277 | FW(fecp, hash_table_low, fep->fec.htlo); | 277 | FW(fecp, grp_hash_table_low, fep->fec.htlo); |
278 | 278 | ||
279 | /* | 279 | /* |
280 | * Set maximum receive buffer size. | 280 | * Set maximum receive buffer size. |
diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index a31661948c42..9bd7746cbfcf 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c | |||
@@ -139,11 +139,11 @@ static int ftmac100_reset(struct ftmac100 *priv) | |||
139 | * that hardware reset completed (what the f*ck). | 139 | * that hardware reset completed (what the f*ck). |
140 | * We still need to wait for a while. | 140 | * We still need to wait for a while. |
141 | */ | 141 | */ |
142 | usleep_range(500, 1000); | 142 | udelay(500); |
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | usleep_range(1000, 10000); | 146 | udelay(1000); |
147 | } | 147 | } |
148 | 148 | ||
149 | netdev_err(netdev, "software reset failed\n"); | 149 | netdev_err(netdev, "software reset failed\n"); |
@@ -772,7 +772,7 @@ static int ftmac100_mdio_read(struct net_device *netdev, int phy_id, int reg) | |||
772 | if ((phycr & FTMAC100_PHYCR_MIIRD) == 0) | 772 | if ((phycr & FTMAC100_PHYCR_MIIRD) == 0) |
773 | return phycr & FTMAC100_PHYCR_MIIRDATA; | 773 | return phycr & FTMAC100_PHYCR_MIIRDATA; |
774 | 774 | ||
775 | usleep_range(100, 1000); | 775 | udelay(100); |
776 | } | 776 | } |
777 | 777 | ||
778 | netdev_err(netdev, "mdio read timed out\n"); | 778 | netdev_err(netdev, "mdio read timed out\n"); |
@@ -801,7 +801,7 @@ static void ftmac100_mdio_write(struct net_device *netdev, int phy_id, int reg, | |||
801 | if ((phycr & FTMAC100_PHYCR_MIIWR) == 0) | 801 | if ((phycr & FTMAC100_PHYCR_MIIWR) == 0) |
802 | return; | 802 | return; |
803 | 803 | ||
804 | usleep_range(100, 1000); | 804 | udelay(100); |
805 | } | 805 | } |
806 | 806 | ||
807 | netdev_err(netdev, "mdio write timed out\n"); | 807 | netdev_err(netdev, "mdio write timed out\n"); |
diff --git a/drivers/net/mii.c b/drivers/net/mii.c index 0a6c6a2e7550..d4fc00b1ff93 100644 --- a/drivers/net/mii.c +++ b/drivers/net/mii.c | |||
@@ -49,6 +49,10 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr) | |||
49 | result |= ADVERTISED_100baseT_Half; | 49 | result |= ADVERTISED_100baseT_Half; |
50 | if (advert & ADVERTISE_100FULL) | 50 | if (advert & ADVERTISE_100FULL) |
51 | result |= ADVERTISED_100baseT_Full; | 51 | result |= ADVERTISED_100baseT_Full; |
52 | if (advert & ADVERTISE_PAUSE_CAP) | ||
53 | result |= ADVERTISED_Pause; | ||
54 | if (advert & ADVERTISE_PAUSE_ASYM) | ||
55 | result |= ADVERTISED_Asym_Pause; | ||
52 | 56 | ||
53 | return result; | 57 | return result; |
54 | } | 58 | } |
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index dfb67eb2a94b..eb41e44921e6 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c | |||
@@ -671,6 +671,7 @@ static int netconsole_netdev_event(struct notifier_block *this, | |||
671 | goto done; | 671 | goto done; |
672 | 672 | ||
673 | spin_lock_irqsave(&target_list_lock, flags); | 673 | spin_lock_irqsave(&target_list_lock, flags); |
674 | restart: | ||
674 | list_for_each_entry(nt, &target_list, list) { | 675 | list_for_each_entry(nt, &target_list, list) { |
675 | netconsole_target_get(nt); | 676 | netconsole_target_get(nt); |
676 | if (nt->np.dev == dev) { | 677 | if (nt->np.dev == dev) { |
@@ -683,9 +684,16 @@ static int netconsole_netdev_event(struct notifier_block *this, | |||
683 | * rtnl_lock already held | 684 | * rtnl_lock already held |
684 | */ | 685 | */ |
685 | if (nt->np.dev) { | 686 | if (nt->np.dev) { |
687 | spin_unlock_irqrestore( | ||
688 | &target_list_lock, | ||
689 | flags); | ||
686 | __netpoll_cleanup(&nt->np); | 690 | __netpoll_cleanup(&nt->np); |
691 | spin_lock_irqsave(&target_list_lock, | ||
692 | flags); | ||
687 | dev_put(nt->np.dev); | 693 | dev_put(nt->np.dev); |
688 | nt->np.dev = NULL; | 694 | nt->np.dev = NULL; |
695 | netconsole_target_put(nt); | ||
696 | goto restart; | ||
689 | } | 697 | } |
690 | /* Fall through */ | 698 | /* Fall through */ |
691 | case NETDEV_GOING_DOWN: | 699 | case NETDEV_GOING_DOWN: |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 493b0de3848b..397c36810a15 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -170,6 +170,16 @@ static const struct { | |||
170 | }; | 170 | }; |
171 | #undef _R | 171 | #undef _R |
172 | 172 | ||
173 | static const struct rtl_firmware_info { | ||
174 | int mac_version; | ||
175 | const char *fw_name; | ||
176 | } rtl_firmware_infos[] = { | ||
177 | { .mac_version = RTL_GIGA_MAC_VER_25, .fw_name = FIRMWARE_8168D_1 }, | ||
178 | { .mac_version = RTL_GIGA_MAC_VER_26, .fw_name = FIRMWARE_8168D_2 }, | ||
179 | { .mac_version = RTL_GIGA_MAC_VER_29, .fw_name = FIRMWARE_8105E_1 }, | ||
180 | { .mac_version = RTL_GIGA_MAC_VER_30, .fw_name = FIRMWARE_8105E_1 } | ||
181 | }; | ||
182 | |||
173 | enum cfg_version { | 183 | enum cfg_version { |
174 | RTL_CFG_0 = 0x00, | 184 | RTL_CFG_0 = 0x00, |
175 | RTL_CFG_1, | 185 | RTL_CFG_1, |
@@ -565,6 +575,7 @@ struct rtl8169_private { | |||
565 | u32 saved_wolopts; | 575 | u32 saved_wolopts; |
566 | 576 | ||
567 | const struct firmware *fw; | 577 | const struct firmware *fw; |
578 | #define RTL_FIRMWARE_UNKNOWN ERR_PTR(-EAGAIN); | ||
568 | }; | 579 | }; |
569 | 580 | ||
570 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); | 581 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); |
@@ -1789,25 +1800,26 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1789 | 1800 | ||
1790 | static void rtl_release_firmware(struct rtl8169_private *tp) | 1801 | static void rtl_release_firmware(struct rtl8169_private *tp) |
1791 | { | 1802 | { |
1792 | release_firmware(tp->fw); | 1803 | if (!IS_ERR_OR_NULL(tp->fw)) |
1793 | tp->fw = NULL; | 1804 | release_firmware(tp->fw); |
1805 | tp->fw = RTL_FIRMWARE_UNKNOWN; | ||
1794 | } | 1806 | } |
1795 | 1807 | ||
1796 | static int rtl_apply_firmware(struct rtl8169_private *tp, const char *fw_name) | 1808 | static void rtl_apply_firmware(struct rtl8169_private *tp) |
1797 | { | 1809 | { |
1798 | const struct firmware **fw = &tp->fw; | 1810 | const struct firmware *fw = tp->fw; |
1799 | int rc = !*fw; | ||
1800 | |||
1801 | if (rc) { | ||
1802 | rc = request_firmware(fw, fw_name, &tp->pci_dev->dev); | ||
1803 | if (rc < 0) | ||
1804 | goto out; | ||
1805 | } | ||
1806 | 1811 | ||
1807 | /* TODO: release firmware once rtl_phy_write_fw signals failures. */ | 1812 | /* TODO: release firmware once rtl_phy_write_fw signals failures. */ |
1808 | rtl_phy_write_fw(tp, *fw); | 1813 | if (!IS_ERR_OR_NULL(fw)) |
1809 | out: | 1814 | rtl_phy_write_fw(tp, fw); |
1810 | return rc; | 1815 | } |
1816 | |||
1817 | static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val) | ||
1818 | { | ||
1819 | if (rtl_readphy(tp, reg) != val) | ||
1820 | netif_warn(tp, hw, tp->dev, "chipset not ready for firmware\n"); | ||
1821 | else | ||
1822 | rtl_apply_firmware(tp); | ||
1811 | } | 1823 | } |
1812 | 1824 | ||
1813 | static void rtl8169s_hw_phy_config(struct rtl8169_private *tp) | 1825 | static void rtl8169s_hw_phy_config(struct rtl8169_private *tp) |
@@ -2246,10 +2258,8 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp) | |||
2246 | 2258 | ||
2247 | rtl_writephy(tp, 0x1f, 0x0005); | 2259 | rtl_writephy(tp, 0x1f, 0x0005); |
2248 | rtl_writephy(tp, 0x05, 0x001b); | 2260 | rtl_writephy(tp, 0x05, 0x001b); |
2249 | if ((rtl_readphy(tp, 0x06) != 0xbf00) || | 2261 | |
2250 | (rtl_apply_firmware(tp, FIRMWARE_8168D_1) < 0)) { | 2262 | rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xbf00); |
2251 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2252 | } | ||
2253 | 2263 | ||
2254 | rtl_writephy(tp, 0x1f, 0x0000); | 2264 | rtl_writephy(tp, 0x1f, 0x0000); |
2255 | } | 2265 | } |
@@ -2351,10 +2361,8 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp) | |||
2351 | 2361 | ||
2352 | rtl_writephy(tp, 0x1f, 0x0005); | 2362 | rtl_writephy(tp, 0x1f, 0x0005); |
2353 | rtl_writephy(tp, 0x05, 0x001b); | 2363 | rtl_writephy(tp, 0x05, 0x001b); |
2354 | if ((rtl_readphy(tp, 0x06) != 0xb300) || | 2364 | |
2355 | (rtl_apply_firmware(tp, FIRMWARE_8168D_2) < 0)) { | 2365 | rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xb300); |
2356 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2357 | } | ||
2358 | 2366 | ||
2359 | rtl_writephy(tp, 0x1f, 0x0000); | 2367 | rtl_writephy(tp, 0x1f, 0x0000); |
2360 | } | 2368 | } |
@@ -2474,8 +2482,7 @@ static void rtl8105e_hw_phy_config(struct rtl8169_private *tp) | |||
2474 | rtl_writephy(tp, 0x18, 0x0310); | 2482 | rtl_writephy(tp, 0x18, 0x0310); |
2475 | msleep(100); | 2483 | msleep(100); |
2476 | 2484 | ||
2477 | if (rtl_apply_firmware(tp, FIRMWARE_8105E_1) < 0) | 2485 | rtl_apply_firmware(tp); |
2478 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2479 | 2486 | ||
2480 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | 2487 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); |
2481 | } | 2488 | } |
@@ -3237,6 +3244,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3237 | tp->timer.data = (unsigned long) dev; | 3244 | tp->timer.data = (unsigned long) dev; |
3238 | tp->timer.function = rtl8169_phy_timer; | 3245 | tp->timer.function = rtl8169_phy_timer; |
3239 | 3246 | ||
3247 | tp->fw = RTL_FIRMWARE_UNKNOWN; | ||
3248 | |||
3240 | rc = register_netdev(dev); | 3249 | rc = register_netdev(dev); |
3241 | if (rc < 0) | 3250 | if (rc < 0) |
3242 | goto err_out_msi_4; | 3251 | goto err_out_msi_4; |
@@ -3288,10 +3297,10 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3288 | 3297 | ||
3289 | cancel_delayed_work_sync(&tp->task); | 3298 | cancel_delayed_work_sync(&tp->task); |
3290 | 3299 | ||
3291 | rtl_release_firmware(tp); | ||
3292 | |||
3293 | unregister_netdev(dev); | 3300 | unregister_netdev(dev); |
3294 | 3301 | ||
3302 | rtl_release_firmware(tp); | ||
3303 | |||
3295 | if (pci_dev_run_wake(pdev)) | 3304 | if (pci_dev_run_wake(pdev)) |
3296 | pm_runtime_get_noresume(&pdev->dev); | 3305 | pm_runtime_get_noresume(&pdev->dev); |
3297 | 3306 | ||
@@ -3303,6 +3312,37 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3303 | pci_set_drvdata(pdev, NULL); | 3312 | pci_set_drvdata(pdev, NULL); |
3304 | } | 3313 | } |
3305 | 3314 | ||
3315 | static void rtl_request_firmware(struct rtl8169_private *tp) | ||
3316 | { | ||
3317 | int i; | ||
3318 | |||
3319 | /* Return early if the firmware is already loaded / cached. */ | ||
3320 | if (!IS_ERR(tp->fw)) | ||
3321 | goto out; | ||
3322 | |||
3323 | for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) { | ||
3324 | const struct rtl_firmware_info *info = rtl_firmware_infos + i; | ||
3325 | |||
3326 | if (info->mac_version == tp->mac_version) { | ||
3327 | const char *name = info->fw_name; | ||
3328 | int rc; | ||
3329 | |||
3330 | rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev); | ||
3331 | if (rc < 0) { | ||
3332 | netif_warn(tp, ifup, tp->dev, "unable to load " | ||
3333 | "firmware patch %s (%d)\n", name, rc); | ||
3334 | goto out_disable_request_firmware; | ||
3335 | } | ||
3336 | goto out; | ||
3337 | } | ||
3338 | } | ||
3339 | |||
3340 | out_disable_request_firmware: | ||
3341 | tp->fw = NULL; | ||
3342 | out: | ||
3343 | return; | ||
3344 | } | ||
3345 | |||
3306 | static int rtl8169_open(struct net_device *dev) | 3346 | static int rtl8169_open(struct net_device *dev) |
3307 | { | 3347 | { |
3308 | struct rtl8169_private *tp = netdev_priv(dev); | 3348 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -3334,11 +3374,13 @@ static int rtl8169_open(struct net_device *dev) | |||
3334 | 3374 | ||
3335 | smp_mb(); | 3375 | smp_mb(); |
3336 | 3376 | ||
3377 | rtl_request_firmware(tp); | ||
3378 | |||
3337 | retval = request_irq(dev->irq, rtl8169_interrupt, | 3379 | retval = request_irq(dev->irq, rtl8169_interrupt, |
3338 | (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, | 3380 | (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, |
3339 | dev->name, dev); | 3381 | dev->name, dev); |
3340 | if (retval < 0) | 3382 | if (retval < 0) |
3341 | goto err_release_ring_2; | 3383 | goto err_release_fw_2; |
3342 | 3384 | ||
3343 | napi_enable(&tp->napi); | 3385 | napi_enable(&tp->napi); |
3344 | 3386 | ||
@@ -3359,7 +3401,8 @@ static int rtl8169_open(struct net_device *dev) | |||
3359 | out: | 3401 | out: |
3360 | return retval; | 3402 | return retval; |
3361 | 3403 | ||
3362 | err_release_ring_2: | 3404 | err_release_fw_2: |
3405 | rtl_release_firmware(tp); | ||
3363 | rtl8169_rx_clear(tp); | 3406 | rtl8169_rx_clear(tp); |
3364 | err_free_rx_1: | 3407 | err_free_rx_1: |
3365 | dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, | 3408 | dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index b8c5f35577e4..7a5daefb6f33 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -12327,8 +12327,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
12327 | if (val & VCPU_CFGSHDW_ASPM_DBNC) | 12327 | if (val & VCPU_CFGSHDW_ASPM_DBNC) |
12328 | tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; | 12328 | tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; |
12329 | if ((val & VCPU_CFGSHDW_WOL_ENABLE) && | 12329 | if ((val & VCPU_CFGSHDW_WOL_ENABLE) && |
12330 | (val & VCPU_CFGSHDW_WOL_MAGPKT)) | 12330 | (val & VCPU_CFGSHDW_WOL_MAGPKT)) { |
12331 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; | 12331 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; |
12332 | device_set_wakeup_enable(&tp->pdev->dev, true); | ||
12333 | } | ||
12332 | goto done; | 12334 | goto done; |
12333 | } | 12335 | } |
12334 | 12336 | ||
@@ -12461,8 +12463,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
12461 | tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; | 12463 | tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; |
12462 | 12464 | ||
12463 | if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && | 12465 | if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && |
12464 | (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE)) | 12466 | (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE)) { |
12465 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; | 12467 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; |
12468 | device_set_wakeup_enable(&tp->pdev->dev, true); | ||
12469 | } | ||
12466 | 12470 | ||
12467 | if (cfg2 & (1 << 17)) | 12471 | if (cfg2 & (1 << 17)) |
12468 | tp->phy_flags |= TG3_PHYFLG_CAPACITIVE_COUPLING; | 12472 | tp->phy_flags |= TG3_PHYFLG_CAPACITIVE_COUPLING; |
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 341f7056a800..a301479ecc60 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
@@ -460,7 +460,7 @@ static const struct driver_info cdc_info = { | |||
460 | .manage_power = cdc_manage_power, | 460 | .manage_power = cdc_manage_power, |
461 | }; | 461 | }; |
462 | 462 | ||
463 | static const struct driver_info mbm_info = { | 463 | static const struct driver_info wwan_info = { |
464 | .description = "Mobile Broadband Network Device", | 464 | .description = "Mobile Broadband Network Device", |
465 | .flags = FLAG_WWAN, | 465 | .flags = FLAG_WWAN, |
466 | .bind = usbnet_cdc_bind, | 466 | .bind = usbnet_cdc_bind, |
@@ -471,6 +471,7 @@ static const struct driver_info mbm_info = { | |||
471 | 471 | ||
472 | /*-------------------------------------------------------------------------*/ | 472 | /*-------------------------------------------------------------------------*/ |
473 | 473 | ||
474 | #define HUAWEI_VENDOR_ID 0x12D1 | ||
474 | 475 | ||
475 | static const struct usb_device_id products [] = { | 476 | static const struct usb_device_id products [] = { |
476 | /* | 477 | /* |
@@ -587,8 +588,17 @@ static const struct usb_device_id products [] = { | |||
587 | }, { | 588 | }, { |
588 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, | 589 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, |
589 | USB_CDC_PROTO_NONE), | 590 | USB_CDC_PROTO_NONE), |
590 | .driver_info = (unsigned long)&mbm_info, | 591 | .driver_info = (unsigned long)&wwan_info, |
591 | 592 | ||
593 | }, { | ||
594 | /* Various Huawei modems with a network port like the UMG1831 */ | ||
595 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | ||
596 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
597 | .idVendor = HUAWEI_VENDOR_ID, | ||
598 | .bInterfaceClass = USB_CLASS_COMM, | ||
599 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
600 | .bInterfaceProtocol = 255, | ||
601 | .driver_info = (unsigned long)&wwan_info, | ||
592 | }, | 602 | }, |
593 | { }, // END | 603 | { }, // END |
594 | }; | 604 | }; |
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 967371f04454..1033ef6476a4 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c | |||
@@ -54,13 +54,13 @@ | |||
54 | #include <linux/usb/usbnet.h> | 54 | #include <linux/usb/usbnet.h> |
55 | #include <linux/usb/cdc.h> | 55 | #include <linux/usb/cdc.h> |
56 | 56 | ||
57 | #define DRIVER_VERSION "7-Feb-2011" | 57 | #define DRIVER_VERSION "23-Apr-2011" |
58 | 58 | ||
59 | /* CDC NCM subclass 3.2.1 */ | 59 | /* CDC NCM subclass 3.2.1 */ |
60 | #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 | 60 | #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 |
61 | 61 | ||
62 | /* Maximum NTB length */ | 62 | /* Maximum NTB length */ |
63 | #define CDC_NCM_NTB_MAX_SIZE_TX 16384 /* bytes */ | 63 | #define CDC_NCM_NTB_MAX_SIZE_TX (16384 + 4) /* bytes, must be short terminated */ |
64 | #define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */ | 64 | #define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */ |
65 | 65 | ||
66 | /* Minimum value for MaxDatagramSize, ch. 6.2.9 */ | 66 | /* Minimum value for MaxDatagramSize, ch. 6.2.9 */ |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 47a6c870b51f..48d4efdb4959 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
@@ -730,7 +730,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) | |||
730 | msleep(10); | 730 | msleep(10); |
731 | bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); | 731 | bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); |
732 | timeout++; | 732 | timeout++; |
733 | } while ((bmcr & MII_BMCR) && (timeout < 100)); | 733 | } while ((bmcr & BMCR_RESET) && (timeout < 100)); |
734 | 734 | ||
735 | if (timeout >= 100) { | 735 | if (timeout >= 100) { |
736 | netdev_warn(dev->net, "timeout on PHY Reset"); | 736 | netdev_warn(dev->net, "timeout on PHY Reset"); |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 069c1cf0fdf7..009bba3d753e 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -736,6 +736,7 @@ int usbnet_open (struct net_device *net) | |||
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | set_bit(EVENT_DEV_OPEN, &dev->flags); | ||
739 | netif_start_queue (net); | 740 | netif_start_queue (net); |
740 | netif_info(dev, ifup, dev->net, | 741 | netif_info(dev, ifup, dev->net, |
741 | "open: enable queueing (rx %d, tx %d) mtu %d %s framing\n", | 742 | "open: enable queueing (rx %d, tx %d) mtu %d %s framing\n", |
@@ -1259,6 +1260,9 @@ void usbnet_disconnect (struct usb_interface *intf) | |||
1259 | if (dev->driver_info->unbind) | 1260 | if (dev->driver_info->unbind) |
1260 | dev->driver_info->unbind (dev, intf); | 1261 | dev->driver_info->unbind (dev, intf); |
1261 | 1262 | ||
1263 | usb_kill_urb(dev->interrupt); | ||
1264 | usb_free_urb(dev->interrupt); | ||
1265 | |||
1262 | free_netdev(net); | 1266 | free_netdev(net); |
1263 | usb_put_dev (xdev); | 1267 | usb_put_dev (xdev); |
1264 | } | 1268 | } |
@@ -1498,6 +1502,10 @@ int usbnet_resume (struct usb_interface *intf) | |||
1498 | int retval; | 1502 | int retval; |
1499 | 1503 | ||
1500 | if (!--dev->suspend_count) { | 1504 | if (!--dev->suspend_count) { |
1505 | /* resume interrupt URBs */ | ||
1506 | if (dev->interrupt && test_bit(EVENT_DEV_OPEN, &dev->flags)) | ||
1507 | usb_submit_urb(dev->interrupt, GFP_NOIO); | ||
1508 | |||
1501 | spin_lock_irq(&dev->txq.lock); | 1509 | spin_lock_irq(&dev->txq.lock); |
1502 | while ((res = usb_get_from_anchor(&dev->deferred))) { | 1510 | while ((res = usb_get_from_anchor(&dev->deferred))) { |
1503 | 1511 | ||
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 2de9b90c5f8f..3b99f64104fd 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -403,6 +403,17 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, | |||
403 | if (tb[IFLA_ADDRESS] == NULL) | 403 | if (tb[IFLA_ADDRESS] == NULL) |
404 | random_ether_addr(dev->dev_addr); | 404 | random_ether_addr(dev->dev_addr); |
405 | 405 | ||
406 | if (tb[IFLA_IFNAME]) | ||
407 | nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ); | ||
408 | else | ||
409 | snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d"); | ||
410 | |||
411 | if (strchr(dev->name, '%')) { | ||
412 | err = dev_alloc_name(dev, dev->name); | ||
413 | if (err < 0) | ||
414 | goto err_alloc_name; | ||
415 | } | ||
416 | |||
406 | err = register_netdevice(dev); | 417 | err = register_netdevice(dev); |
407 | if (err < 0) | 418 | if (err < 0) |
408 | goto err_register_dev; | 419 | goto err_register_dev; |
@@ -422,6 +433,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, | |||
422 | 433 | ||
423 | err_register_dev: | 434 | err_register_dev: |
424 | /* nothing to do */ | 435 | /* nothing to do */ |
436 | err_alloc_name: | ||
425 | err_configure_peer: | 437 | err_configure_peer: |
426 | unregister_netdevice(peer); | 438 | unregister_netdevice(peer); |
427 | return err; | 439 | return err; |
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index dcd19bc337d1..b29c80def35e 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c | |||
@@ -506,7 +506,7 @@ bool ath_stoprecv(struct ath_softc *sc) | |||
506 | "confusing the DMA engine when we start RX up\n"); | 506 | "confusing the DMA engine when we start RX up\n"); |
507 | ATH_DBG_WARN_ON_ONCE(!stopped); | 507 | ATH_DBG_WARN_ON_ONCE(!stopped); |
508 | } | 508 | } |
509 | return stopped || reset; | 509 | return stopped && !reset; |
510 | } | 510 | } |
511 | 511 | ||
512 | void ath_flushrecv(struct ath_softc *sc) | 512 | void ath_flushrecv(struct ath_softc *sc) |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index d59b0168c14a..5af40d9170a0 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -72,6 +72,7 @@ MODULE_FIRMWARE("b43/ucode11.fw"); | |||
72 | MODULE_FIRMWARE("b43/ucode13.fw"); | 72 | MODULE_FIRMWARE("b43/ucode13.fw"); |
73 | MODULE_FIRMWARE("b43/ucode14.fw"); | 73 | MODULE_FIRMWARE("b43/ucode14.fw"); |
74 | MODULE_FIRMWARE("b43/ucode15.fw"); | 74 | MODULE_FIRMWARE("b43/ucode15.fw"); |
75 | MODULE_FIRMWARE("b43/ucode16_mimo.fw"); | ||
75 | MODULE_FIRMWARE("b43/ucode5.fw"); | 76 | MODULE_FIRMWARE("b43/ucode5.fw"); |
76 | MODULE_FIRMWARE("b43/ucode9.fw"); | 77 | MODULE_FIRMWARE("b43/ucode9.fw"); |
77 | 78 | ||
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 5c40502f869a..79ac081832fb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c | |||
@@ -316,12 +316,18 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
316 | 316 | ||
317 | hdr_len = ieee80211_hdrlen(fc); | 317 | hdr_len = ieee80211_hdrlen(fc); |
318 | 318 | ||
319 | /* Find index into station table for destination station */ | 319 | /* For management frames use broadcast id to do not break aggregation */ |
320 | sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta); | 320 | if (!ieee80211_is_data(fc)) |
321 | if (sta_id == IWL_INVALID_STATION) { | 321 | sta_id = ctx->bcast_sta_id; |
322 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | 322 | else { |
323 | hdr->addr1); | 323 | /* Find index into station table for destination station */ |
324 | goto drop_unlock; | 324 | sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta); |
325 | |||
326 | if (sta_id == IWL_INVALID_STATION) { | ||
327 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | ||
328 | hdr->addr1); | ||
329 | goto drop_unlock; | ||
330 | } | ||
325 | } | 331 | } |
326 | 332 | ||
327 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); | 333 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); |
@@ -1127,12 +1133,16 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | |||
1127 | q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { | 1133 | q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { |
1128 | 1134 | ||
1129 | tx_info = &txq->txb[txq->q.read_ptr]; | 1135 | tx_info = &txq->txb[txq->q.read_ptr]; |
1130 | iwl4965_tx_status(priv, tx_info, | 1136 | |
1131 | txq_id >= IWL4965_FIRST_AMPDU_QUEUE); | 1137 | if (WARN_ON_ONCE(tx_info->skb == NULL)) |
1138 | continue; | ||
1132 | 1139 | ||
1133 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; | 1140 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; |
1134 | if (hdr && ieee80211_is_data_qos(hdr->frame_control)) | 1141 | if (ieee80211_is_data_qos(hdr->frame_control)) |
1135 | nfreed++; | 1142 | nfreed++; |
1143 | |||
1144 | iwl4965_tx_status(priv, tx_info, | ||
1145 | txq_id >= IWL4965_FIRST_AMPDU_QUEUE); | ||
1136 | tx_info->skb = NULL; | 1146 | tx_info->skb = NULL; |
1137 | 1147 | ||
1138 | priv->cfg->ops->lib->txq_free_tfd(priv, txq); | 1148 | priv->cfg->ops->lib->txq_free_tfd(priv, txq); |
diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 15eb8b707157..bda0d61b2c0d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c | |||
@@ -48,8 +48,21 @@ module_param(led_mode, int, S_IRUGO); | |||
48 | MODULE_PARM_DESC(led_mode, "0=system default, " | 48 | MODULE_PARM_DESC(led_mode, "0=system default, " |
49 | "1=On(RF On)/Off(RF Off), 2=blinking"); | 49 | "1=On(RF On)/Off(RF Off), 2=blinking"); |
50 | 50 | ||
51 | /* Throughput OFF time(ms) ON time (ms) | ||
52 | * >300 25 25 | ||
53 | * >200 to 300 40 40 | ||
54 | * >100 to 200 55 55 | ||
55 | * >70 to 100 65 65 | ||
56 | * >50 to 70 75 75 | ||
57 | * >20 to 50 85 85 | ||
58 | * >10 to 20 95 95 | ||
59 | * >5 to 10 110 110 | ||
60 | * >1 to 5 130 130 | ||
61 | * >0 to 1 167 167 | ||
62 | * <=0 SOLID ON | ||
63 | */ | ||
51 | static const struct ieee80211_tpt_blink iwl_blink[] = { | 64 | static const struct ieee80211_tpt_blink iwl_blink[] = { |
52 | { .throughput = 0 * 1024 - 1, .blink_time = 334 }, | 65 | { .throughput = 0, .blink_time = 334 }, |
53 | { .throughput = 1 * 1024 - 1, .blink_time = 260 }, | 66 | { .throughput = 1 * 1024 - 1, .blink_time = 260 }, |
54 | { .throughput = 5 * 1024 - 1, .blink_time = 220 }, | 67 | { .throughput = 5 * 1024 - 1, .blink_time = 220 }, |
55 | { .throughput = 10 * 1024 - 1, .blink_time = 190 }, | 68 | { .throughput = 10 * 1024 - 1, .blink_time = 190 }, |
@@ -101,6 +114,11 @@ static int iwl_legacy_led_cmd(struct iwl_priv *priv, | |||
101 | if (priv->blink_on == on && priv->blink_off == off) | 114 | if (priv->blink_on == on && priv->blink_off == off) |
102 | return 0; | 115 | return 0; |
103 | 116 | ||
117 | if (off == 0) { | ||
118 | /* led is SOLID_ON */ | ||
119 | on = IWL_LED_SOLID; | ||
120 | } | ||
121 | |||
104 | IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", | 122 | IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", |
105 | priv->cfg->base_params->led_compensation); | 123 | priv->cfg->base_params->led_compensation); |
106 | led_cmd.on = iwl_legacy_blink_compensation(priv, on, | 124 | led_cmd.on = iwl_legacy_blink_compensation(priv, on, |
diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d484c3678163..a62fe24ee594 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c | |||
@@ -2984,15 +2984,15 @@ static void iwl4965_bg_txpower_work(struct work_struct *work) | |||
2984 | struct iwl_priv *priv = container_of(work, struct iwl_priv, | 2984 | struct iwl_priv *priv = container_of(work, struct iwl_priv, |
2985 | txpower_work); | 2985 | txpower_work); |
2986 | 2986 | ||
2987 | mutex_lock(&priv->mutex); | ||
2988 | |||
2987 | /* If a scan happened to start before we got here | 2989 | /* If a scan happened to start before we got here |
2988 | * then just return; the statistics notification will | 2990 | * then just return; the statistics notification will |
2989 | * kick off another scheduled work to compensate for | 2991 | * kick off another scheduled work to compensate for |
2990 | * any temperature delta we missed here. */ | 2992 | * any temperature delta we missed here. */ |
2991 | if (test_bit(STATUS_EXIT_PENDING, &priv->status) || | 2993 | if (test_bit(STATUS_EXIT_PENDING, &priv->status) || |
2992 | test_bit(STATUS_SCANNING, &priv->status)) | 2994 | test_bit(STATUS_SCANNING, &priv->status)) |
2993 | return; | 2995 | goto out; |
2994 | |||
2995 | mutex_lock(&priv->mutex); | ||
2996 | 2996 | ||
2997 | /* Regardless of if we are associated, we must reconfigure the | 2997 | /* Regardless of if we are associated, we must reconfigure the |
2998 | * TX power since frames can be sent on non-radar channels while | 2998 | * TX power since frames can be sent on non-radar channels while |
@@ -3002,7 +3002,7 @@ static void iwl4965_bg_txpower_work(struct work_struct *work) | |||
3002 | /* Update last_temperature to keep is_calib_needed from running | 3002 | /* Update last_temperature to keep is_calib_needed from running |
3003 | * when it isn't needed... */ | 3003 | * when it isn't needed... */ |
3004 | priv->last_temperature = priv->temperature; | 3004 | priv->last_temperature = priv->temperature; |
3005 | 3005 | out: | |
3006 | mutex_unlock(&priv->mutex); | 3006 | mutex_unlock(&priv->mutex); |
3007 | } | 3007 | } |
3008 | 3008 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index dfdbea6e8f99..fbbde0712fa5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | |||
@@ -335,7 +335,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
335 | struct ieee80211_channel *channel = conf->channel; | 335 | struct ieee80211_channel *channel = conf->channel; |
336 | const struct iwl_channel_info *ch_info; | 336 | const struct iwl_channel_info *ch_info; |
337 | int ret = 0; | 337 | int ret = 0; |
338 | bool ht_changed[NUM_IWL_RXON_CTX] = {}; | ||
339 | 338 | ||
340 | IWL_DEBUG_MAC80211(priv, "changed %#x", changed); | 339 | IWL_DEBUG_MAC80211(priv, "changed %#x", changed); |
341 | 340 | ||
@@ -383,10 +382,8 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
383 | 382 | ||
384 | for_each_context(priv, ctx) { | 383 | for_each_context(priv, ctx) { |
385 | /* Configure HT40 channels */ | 384 | /* Configure HT40 channels */ |
386 | if (ctx->ht.enabled != conf_is_ht(conf)) { | 385 | if (ctx->ht.enabled != conf_is_ht(conf)) |
387 | ctx->ht.enabled = conf_is_ht(conf); | 386 | ctx->ht.enabled = conf_is_ht(conf); |
388 | ht_changed[ctx->ctxid] = true; | ||
389 | } | ||
390 | 387 | ||
391 | if (ctx->ht.enabled) { | 388 | if (ctx->ht.enabled) { |
392 | if (conf_is_ht40_minus(conf)) { | 389 | if (conf_is_ht40_minus(conf)) { |
@@ -455,8 +452,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
455 | if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) | 452 | if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) |
456 | continue; | 453 | continue; |
457 | iwlagn_commit_rxon(priv, ctx); | 454 | iwlagn_commit_rxon(priv, ctx); |
458 | if (ht_changed[ctx->ctxid]) | ||
459 | iwlagn_update_qos(priv, ctx); | ||
460 | } | 455 | } |
461 | out: | 456 | out: |
462 | mutex_unlock(&priv->mutex); | 457 | mutex_unlock(&priv->mutex); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index a709d05c5868..0712b67283a4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c | |||
@@ -568,12 +568,17 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
568 | 568 | ||
569 | hdr_len = ieee80211_hdrlen(fc); | 569 | hdr_len = ieee80211_hdrlen(fc); |
570 | 570 | ||
571 | /* Find index into station table for destination station */ | 571 | /* For management frames use broadcast id to do not break aggregation */ |
572 | sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta); | 572 | if (!ieee80211_is_data(fc)) |
573 | if (sta_id == IWL_INVALID_STATION) { | 573 | sta_id = ctx->bcast_sta_id; |
574 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | 574 | else { |
575 | hdr->addr1); | 575 | /* Find index into station table for destination station */ |
576 | goto drop_unlock; | 576 | sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta); |
577 | if (sta_id == IWL_INVALID_STATION) { | ||
578 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | ||
579 | hdr->addr1); | ||
580 | goto drop_unlock; | ||
581 | } | ||
577 | } | 582 | } |
578 | 583 | ||
579 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); | 584 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); |
@@ -1224,12 +1229,16 @@ int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | |||
1224 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { | 1229 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { |
1225 | 1230 | ||
1226 | tx_info = &txq->txb[txq->q.read_ptr]; | 1231 | tx_info = &txq->txb[txq->q.read_ptr]; |
1227 | iwlagn_tx_status(priv, tx_info, | 1232 | |
1228 | txq_id >= IWLAGN_FIRST_AMPDU_QUEUE); | 1233 | if (WARN_ON_ONCE(tx_info->skb == NULL)) |
1234 | continue; | ||
1229 | 1235 | ||
1230 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; | 1236 | hdr = (struct ieee80211_hdr *)tx_info->skb->data; |
1231 | if (hdr && ieee80211_is_data_qos(hdr->frame_control)) | 1237 | if (ieee80211_is_data_qos(hdr->frame_control)) |
1232 | nfreed++; | 1238 | nfreed++; |
1239 | |||
1240 | iwlagn_tx_status(priv, tx_info, | ||
1241 | txq_id >= IWLAGN_FIRST_AMPDU_QUEUE); | ||
1233 | tx_info->skb = NULL; | 1242 | tx_info->skb = NULL; |
1234 | 1243 | ||
1235 | if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl) | 1244 | if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl) |
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index fe77e8223841..e8c19def1b0f 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -173,7 +173,7 @@ static int pcmcia_access_config(struct pcmcia_device *p_dev, | |||
173 | c = p_dev->function_config; | 173 | c = p_dev->function_config; |
174 | 174 | ||
175 | if (!(c->state & CONFIG_LOCKED)) { | 175 | if (!(c->state & CONFIG_LOCKED)) { |
176 | dev_dbg(&p_dev->dev, "Configuration isn't't locked\n"); | 176 | dev_dbg(&p_dev->dev, "Configuration isn't locked\n"); |
177 | mutex_unlock(&s->ops_mutex); | 177 | mutex_unlock(&s->ops_mutex); |
178 | return -EACCES; | 178 | return -EACCES; |
179 | } | 179 | } |
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 174036dda786..20494b5edc3c 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
@@ -257,6 +257,8 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
257 | goto out_irq; | 257 | goto out_irq; |
258 | } | 258 | } |
259 | 259 | ||
260 | dev_set_drvdata(&pdev->dev, info); | ||
261 | |||
260 | info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, | 262 | info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, |
261 | &max8925_rtc_ops, THIS_MODULE); | 263 | &max8925_rtc_ops, THIS_MODULE); |
262 | ret = PTR_ERR(info->rtc_dev); | 264 | ret = PTR_ERR(info->rtc_dev); |
@@ -265,7 +267,6 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
265 | goto out_rtc; | 267 | goto out_rtc; |
266 | } | 268 | } |
267 | 269 | ||
268 | dev_set_drvdata(&pdev->dev, info); | ||
269 | platform_set_drvdata(pdev, info); | 270 | platform_set_drvdata(pdev, info); |
270 | 271 | ||
271 | return 0; | 272 | return 0; |
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c index 29143eda9dd9..85dddb1e4126 100644 --- a/drivers/s390/block/dasd_diag.c +++ b/drivers/s390/block/dasd_diag.c | |||
@@ -239,7 +239,6 @@ static void dasd_ext_handler(unsigned int ext_int_code, | |||
239 | addr_t ip; | 239 | addr_t ip; |
240 | int rc; | 240 | int rc; |
241 | 241 | ||
242 | kstat_cpu(smp_processor_id()).irqs[EXTINT_DSD]++; | ||
243 | switch (ext_int_code >> 24) { | 242 | switch (ext_int_code >> 24) { |
244 | case DASD_DIAG_CODE_31BIT: | 243 | case DASD_DIAG_CODE_31BIT: |
245 | ip = (addr_t) param32; | 244 | ip = (addr_t) param32; |
@@ -250,6 +249,7 @@ static void dasd_ext_handler(unsigned int ext_int_code, | |||
250 | default: | 249 | default: |
251 | return; | 250 | return; |
252 | } | 251 | } |
252 | kstat_cpu(smp_processor_id()).irqs[EXTINT_DSD]++; | ||
253 | if (!ip) { /* no intparm: unsolicited interrupt */ | 253 | if (!ip) { /* no intparm: unsolicited interrupt */ |
254 | DBF_EVENT(DBF_NOTICE, "%s", "caught unsolicited " | 254 | DBF_EVENT(DBF_NOTICE, "%s", "caught unsolicited " |
255 | "interrupt"); | 255 | "interrupt"); |
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index 414427d64a8f..607998f0b7d8 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c | |||
@@ -381,10 +381,10 @@ static void kvm_extint_handler(unsigned int ext_int_code, | |||
381 | u16 subcode; | 381 | u16 subcode; |
382 | u32 param; | 382 | u32 param; |
383 | 383 | ||
384 | kstat_cpu(smp_processor_id()).irqs[EXTINT_VRT]++; | ||
385 | subcode = ext_int_code >> 16; | 384 | subcode = ext_int_code >> 16; |
386 | if ((subcode & 0xff00) != VIRTIO_SUBCODE_64) | 385 | if ((subcode & 0xff00) != VIRTIO_SUBCODE_64) |
387 | return; | 386 | return; |
387 | kstat_cpu(smp_processor_id()).irqs[EXTINT_VRT]++; | ||
388 | 388 | ||
389 | /* The LSB might be overloaded, we have to mask it */ | 389 | /* The LSB might be overloaded, we have to mask it */ |
390 | vq = (struct virtqueue *)(param64 & ~1UL); | 390 | vq = (struct virtqueue *)(param64 & ~1UL); |
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c index 564e6ecd17c2..0119b8147797 100644 --- a/drivers/scsi/device_handler/scsi_dh.c +++ b/drivers/scsi/device_handler/scsi_dh.c | |||
@@ -394,12 +394,14 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data) | |||
394 | unsigned long flags; | 394 | unsigned long flags; |
395 | struct scsi_device *sdev; | 395 | struct scsi_device *sdev; |
396 | struct scsi_device_handler *scsi_dh = NULL; | 396 | struct scsi_device_handler *scsi_dh = NULL; |
397 | struct device *dev = NULL; | ||
397 | 398 | ||
398 | spin_lock_irqsave(q->queue_lock, flags); | 399 | spin_lock_irqsave(q->queue_lock, flags); |
399 | sdev = q->queuedata; | 400 | sdev = q->queuedata; |
400 | if (sdev && sdev->scsi_dh_data) | 401 | if (sdev && sdev->scsi_dh_data) |
401 | scsi_dh = sdev->scsi_dh_data->scsi_dh; | 402 | scsi_dh = sdev->scsi_dh_data->scsi_dh; |
402 | if (!scsi_dh || !get_device(&sdev->sdev_gendev) || | 403 | dev = get_device(&sdev->sdev_gendev); |
404 | if (!scsi_dh || !dev || | ||
403 | sdev->sdev_state == SDEV_CANCEL || | 405 | sdev->sdev_state == SDEV_CANCEL || |
404 | sdev->sdev_state == SDEV_DEL) | 406 | sdev->sdev_state == SDEV_DEL) |
405 | err = SCSI_DH_NOSYS; | 407 | err = SCSI_DH_NOSYS; |
@@ -410,12 +412,13 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data) | |||
410 | if (err) { | 412 | if (err) { |
411 | if (fn) | 413 | if (fn) |
412 | fn(data, err); | 414 | fn(data, err); |
413 | return err; | 415 | goto out; |
414 | } | 416 | } |
415 | 417 | ||
416 | if (scsi_dh->activate) | 418 | if (scsi_dh->activate) |
417 | err = scsi_dh->activate(sdev, fn, data); | 419 | err = scsi_dh->activate(sdev, fn, data); |
418 | put_device(&sdev->sdev_gendev); | 420 | out: |
421 | put_device(dev); | ||
419 | return err; | 422 | return err; |
420 | } | 423 | } |
421 | EXPORT_SYMBOL_GPL(scsi_dh_activate); | 424 | EXPORT_SYMBOL_GPL(scsi_dh_activate); |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index 1c6d2b405eef..d72f1f2b1392 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c | |||
@@ -688,6 +688,13 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc, | |||
688 | goto out; | 688 | goto out; |
689 | } | 689 | } |
690 | 690 | ||
691 | /* Check for overflow and wraparound */ | ||
692 | if (karg.data_sge_offset * 4 > ioc->request_sz || | ||
693 | karg.data_sge_offset > (UINT_MAX / 4)) { | ||
694 | ret = -EINVAL; | ||
695 | goto out; | ||
696 | } | ||
697 | |||
691 | /* copy in request message frame from user */ | 698 | /* copy in request message frame from user */ |
692 | if (copy_from_user(mpi_request, mf, karg.data_sge_offset*4)) { | 699 | if (copy_from_user(mpi_request, mf, karg.data_sge_offset*4)) { |
693 | printk(KERN_ERR "failure at %s:%d/%s()!\n", __FILE__, __LINE__, | 700 | printk(KERN_ERR "failure at %s:%d/%s()!\n", __FILE__, __LINE__, |
@@ -1963,7 +1970,7 @@ _ctl_diag_read_buffer(void __user *arg, enum block_state state) | |||
1963 | Mpi2DiagBufferPostReply_t *mpi_reply; | 1970 | Mpi2DiagBufferPostReply_t *mpi_reply; |
1964 | int rc, i; | 1971 | int rc, i; |
1965 | u8 buffer_type; | 1972 | u8 buffer_type; |
1966 | unsigned long timeleft; | 1973 | unsigned long timeleft, request_size, copy_size; |
1967 | u16 smid; | 1974 | u16 smid; |
1968 | u16 ioc_status; | 1975 | u16 ioc_status; |
1969 | u8 issue_reset = 0; | 1976 | u8 issue_reset = 0; |
@@ -1999,6 +2006,8 @@ _ctl_diag_read_buffer(void __user *arg, enum block_state state) | |||
1999 | return -ENOMEM; | 2006 | return -ENOMEM; |
2000 | } | 2007 | } |
2001 | 2008 | ||
2009 | request_size = ioc->diag_buffer_sz[buffer_type]; | ||
2010 | |||
2002 | if ((karg.starting_offset % 4) || (karg.bytes_to_read % 4)) { | 2011 | if ((karg.starting_offset % 4) || (karg.bytes_to_read % 4)) { |
2003 | printk(MPT2SAS_ERR_FMT "%s: either the starting_offset " | 2012 | printk(MPT2SAS_ERR_FMT "%s: either the starting_offset " |
2004 | "or bytes_to_read are not 4 byte aligned\n", ioc->name, | 2013 | "or bytes_to_read are not 4 byte aligned\n", ioc->name, |
@@ -2006,13 +2015,23 @@ _ctl_diag_read_buffer(void __user *arg, enum block_state state) | |||
2006 | return -EINVAL; | 2015 | return -EINVAL; |
2007 | } | 2016 | } |
2008 | 2017 | ||
2018 | if (karg.starting_offset > request_size) | ||
2019 | return -EINVAL; | ||
2020 | |||
2009 | diag_data = (void *)(request_data + karg.starting_offset); | 2021 | diag_data = (void *)(request_data + karg.starting_offset); |
2010 | dctlprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: diag_buffer(%p), " | 2022 | dctlprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: diag_buffer(%p), " |
2011 | "offset(%d), sz(%d)\n", ioc->name, __func__, | 2023 | "offset(%d), sz(%d)\n", ioc->name, __func__, |
2012 | diag_data, karg.starting_offset, karg.bytes_to_read)); | 2024 | diag_data, karg.starting_offset, karg.bytes_to_read)); |
2013 | 2025 | ||
2026 | /* Truncate data on requests that are too large */ | ||
2027 | if ((diag_data + karg.bytes_to_read < diag_data) || | ||
2028 | (diag_data + karg.bytes_to_read > request_data + request_size)) | ||
2029 | copy_size = request_size - karg.starting_offset; | ||
2030 | else | ||
2031 | copy_size = karg.bytes_to_read; | ||
2032 | |||
2014 | if (copy_to_user((void __user *)uarg->diagnostic_data, | 2033 | if (copy_to_user((void __user *)uarg->diagnostic_data, |
2015 | diag_data, karg.bytes_to_read)) { | 2034 | diag_data, copy_size)) { |
2016 | printk(MPT2SAS_ERR_FMT "%s: Unable to write " | 2035 | printk(MPT2SAS_ERR_FMT "%s: Unable to write " |
2017 | "mpt_diag_read_buffer_t data @ %p\n", ioc->name, | 2036 | "mpt_diag_read_buffer_t data @ %p\n", ioc->name, |
2018 | __func__, diag_data); | 2037 | __func__, diag_data); |
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 96d5ad0c1e42..7f636b118287 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c | |||
@@ -3814,6 +3814,9 @@ static long pmcraid_ioctl_passthrough( | |||
3814 | rc = -EFAULT; | 3814 | rc = -EFAULT; |
3815 | goto out_free_buffer; | 3815 | goto out_free_buffer; |
3816 | } | 3816 | } |
3817 | } else if (request_size < 0) { | ||
3818 | rc = -EINVAL; | ||
3819 | goto out_free_buffer; | ||
3817 | } | 3820 | } |
3818 | 3821 | ||
3819 | /* check if we have any additional command parameters */ | 3822 | /* check if we have any additional command parameters */ |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index e44ff64233fd..e63912510fb9 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -322,14 +322,8 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) | |||
322 | kfree(evt); | 322 | kfree(evt); |
323 | } | 323 | } |
324 | 324 | ||
325 | if (sdev->request_queue) { | 325 | /* NULL queue means the device can't be used */ |
326 | sdev->request_queue->queuedata = NULL; | 326 | sdev->request_queue = NULL; |
327 | /* user context needed to free queue */ | ||
328 | scsi_free_queue(sdev->request_queue); | ||
329 | /* temporary expedient, try to catch use of queue lock | ||
330 | * after free of sdev */ | ||
331 | sdev->request_queue = NULL; | ||
332 | } | ||
333 | 327 | ||
334 | scsi_target_reap(scsi_target(sdev)); | 328 | scsi_target_reap(scsi_target(sdev)); |
335 | 329 | ||
@@ -937,6 +931,12 @@ void __scsi_remove_device(struct scsi_device *sdev) | |||
937 | if (sdev->host->hostt->slave_destroy) | 931 | if (sdev->host->hostt->slave_destroy) |
938 | sdev->host->hostt->slave_destroy(sdev); | 932 | sdev->host->hostt->slave_destroy(sdev); |
939 | transport_destroy_device(dev); | 933 | transport_destroy_device(dev); |
934 | |||
935 | /* cause the request function to reject all I/O requests */ | ||
936 | sdev->request_queue->queuedata = NULL; | ||
937 | |||
938 | /* Freeing the queue signals to block that we're done */ | ||
939 | scsi_free_queue(sdev->request_queue); | ||
940 | put_device(dev); | 940 | put_device(dev); |
941 | } | 941 | } |
942 | 942 | ||
diff --git a/drivers/staging/rt2860/common/cmm_data_pci.c b/drivers/staging/rt2860/common/cmm_data_pci.c index bef0bbd8cef7..f01a51c381f1 100644 --- a/drivers/staging/rt2860/common/cmm_data_pci.c +++ b/drivers/staging/rt2860/common/cmm_data_pci.c | |||
@@ -444,7 +444,7 @@ int RTMPCheckRxError(struct rt_rtmp_adapter *pAd, | |||
444 | return (NDIS_STATUS_FAILURE); | 444 | return (NDIS_STATUS_FAILURE); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | /* Drop not U2M frames, can't's drop here because we will drop beacon in this case */ | 447 | /* Drop not U2M frames, can't drop here because we will drop beacon in this case */ |
448 | /* I am kind of doubting the U2M bit operation */ | 448 | /* I am kind of doubting the U2M bit operation */ |
449 | /* if (pRxD->U2M == 0) */ | 449 | /* if (pRxD->U2M == 0) */ |
450 | /* return(NDIS_STATUS_FAILURE); */ | 450 | /* return(NDIS_STATUS_FAILURE); */ |
diff --git a/drivers/staging/rt2860/common/cmm_data_usb.c b/drivers/staging/rt2860/common/cmm_data_usb.c index 5637857ae9eb..83a62faa7e57 100644 --- a/drivers/staging/rt2860/common/cmm_data_usb.c +++ b/drivers/staging/rt2860/common/cmm_data_usb.c | |||
@@ -860,7 +860,7 @@ int RTMPCheckRxError(struct rt_rtmp_adapter *pAd, | |||
860 | DBGPRINT_RAW(RT_DEBUG_ERROR, ("received packet too long\n")); | 860 | DBGPRINT_RAW(RT_DEBUG_ERROR, ("received packet too long\n")); |
861 | return NDIS_STATUS_FAILURE; | 861 | return NDIS_STATUS_FAILURE; |
862 | } | 862 | } |
863 | /* Drop not U2M frames, can't's drop here because we will drop beacon in this case */ | 863 | /* Drop not U2M frames, can't drop here because we will drop beacon in this case */ |
864 | /* I am kind of doubting the U2M bit operation */ | 864 | /* I am kind of doubting the U2M bit operation */ |
865 | /* if (pRxD->U2M == 0) */ | 865 | /* if (pRxD->U2M == 0) */ |
866 | /* return(NDIS_STATUS_FAILURE); */ | 866 | /* return(NDIS_STATUS_FAILURE); */ |
diff --git a/drivers/staging/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c index 20dae73d3b78..506547b603e1 100644 --- a/drivers/staging/spectra/ffsport.c +++ b/drivers/staging/spectra/ffsport.c | |||
@@ -653,7 +653,7 @@ static int SBD_setup_device(struct spectra_nand_dev *dev, int which) | |||
653 | } | 653 | } |
654 | dev->queue->queuedata = dev; | 654 | dev->queue->queuedata = dev; |
655 | 655 | ||
656 | /* As Linux block layer does't support >4KB hardware sector, */ | 656 | /* As Linux block layer doesn't support >4KB hardware sector, */ |
657 | /* Here we force report 512 byte hardware sector size to Kernel */ | 657 | /* Here we force report 512 byte hardware sector size to Kernel */ |
658 | blk_queue_logical_block_size(dev->queue, 512); | 658 | blk_queue_logical_block_size(dev->queue, 512); |
659 | 659 | ||
diff --git a/drivers/staging/tidspbridge/dynload/cload.c b/drivers/staging/tidspbridge/dynload/cload.c index 5cecd237e3f6..fe1ef0addb09 100644 --- a/drivers/staging/tidspbridge/dynload/cload.c +++ b/drivers/staging/tidspbridge/dynload/cload.c | |||
@@ -718,7 +718,7 @@ static void dload_symbols(struct dload_state *dlthis) | |||
718 | * as a temporary for .dllview record construction. | 718 | * as a temporary for .dllview record construction. |
719 | * Allocate storage for the whole table. Add 1 to the section count | 719 | * Allocate storage for the whole table. Add 1 to the section count |
720 | * in case a trampoline section is auto-generated as well as the | 720 | * in case a trampoline section is auto-generated as well as the |
721 | * size of the trampoline section name so DLLView does't get lost. | 721 | * size of the trampoline section name so DLLView doesn't get lost. |
722 | */ | 722 | */ |
723 | 723 | ||
724 | siz = sym_count * sizeof(struct local_symbol); | 724 | siz = sym_count * sizeof(struct local_symbol); |
diff --git a/drivers/staging/tty/specialix.c b/drivers/staging/tty/specialix.c index cb24c6d999db..5c3598ec7456 100644 --- a/drivers/staging/tty/specialix.c +++ b/drivers/staging/tty/specialix.c | |||
@@ -978,7 +978,7 @@ static void sx_change_speed(struct specialix_board *bp, | |||
978 | spin_lock_irqsave(&bp->lock, flags); | 978 | spin_lock_irqsave(&bp->lock, flags); |
979 | sx_out(bp, CD186x_CAR, port_No(port)); | 979 | sx_out(bp, CD186x_CAR, port_No(port)); |
980 | 980 | ||
981 | /* The Specialix board does't implement the RTS lines. | 981 | /* The Specialix board doesn't implement the RTS lines. |
982 | They are used to set the IRQ level. Don't touch them. */ | 982 | They are used to set the IRQ level. Don't touch them. */ |
983 | if (sx_crtscts(tty)) | 983 | if (sx_crtscts(tty)) |
984 | port->MSVR = MSVR_DTR | (sx_in(bp, CD186x_MSVR) & MSVR_RTS); | 984 | port->MSVR = MSVR_DTR | (sx_in(bp, CD186x_MSVR) & MSVR_RTS); |