Skip to content

Commit 7ebd467

Browse files
committed
Merge branch 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: drm/radeon/kms/legacy: only enable load detection property on DVI-I drm/radeon/kms: fix panel scaling adjusted mode setup drivers/gpu/drm/drm_sysfs.c: sysfs files error handling drivers/gpu/drm/radeon/radeon_atombios.c: range check issues gpu: vga_switcheroo, fix lock imbalance drivers/gpu/drm/drm_memory.c: fix check for end of loop drivers/gpu/drm/via/via_video.c: fix off by one issue drm/radeon/kms/agp The wrong AGP chipset can cause a NULL pointer dereference drm/radeon/kms: r300 fix CS checker to allow zbuffer-only fastfill
2 parents d7526f2 + 68b3adb commit 7ebd467

14 files changed

Lines changed: 83 additions & 47 deletions

‎drivers/gpu/drm/drm_memory.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static void *agp_remap(unsigned long offset, unsigned long size,
7777
&& (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
7878
(offset + size))
7979
break;
80-
if (!agpmem)
80+
if (&agpmem->head == &dev->agp->memory)
8181
return NULL;
8282

8383
/*

‎drivers/gpu/drm/drm_sysfs.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,10 @@ static struct bin_attribute edid_attr = {
354354
int drm_sysfs_connector_add(struct drm_connector *connector)
355355
{
356356
struct drm_device *dev = connector->dev;
357-
int ret = 0, i, j;
357+
int attr_cnt = 0;
358+
int opt_cnt = 0;
359+
int i;
360+
int ret = 0;
358361

359362
/* We shouldn't get called more than once for the same connector */
360363
BUG_ON(device_is_registered(&connector->kdev));
@@ -377,8 +380,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
377380

378381
/* Standard attributes */
379382

380-
for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) {
381-
ret = device_create_file(&connector->kdev, &connector_attrs[i]);
383+
for (attr_cnt = 0; attr_cnt < ARRAY_SIZE(connector_attrs); attr_cnt++) {
384+
ret = device_create_file(&connector->kdev, &connector_attrs[attr_cnt]);
382385
if (ret)
383386
goto err_out_files;
384387
}
@@ -394,8 +397,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
394397
case DRM_MODE_CONNECTOR_SVIDEO:
395398
case DRM_MODE_CONNECTOR_Component:
396399
case DRM_MODE_CONNECTOR_TV:
397-
for (i = 0; i < ARRAY_SIZE(connector_attrs_opt1); i++) {
398-
ret = device_create_file(&connector->kdev, &connector_attrs_opt1[i]);
400+
for (opt_cnt = 0; opt_cnt < ARRAY_SIZE(connector_attrs_opt1); opt_cnt++) {
401+
ret = device_create_file(&connector->kdev, &connector_attrs_opt1[opt_cnt]);
399402
if (ret)
400403
goto err_out_files;
401404
}
@@ -414,10 +417,10 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
414417
return 0;
415418

416419
err_out_files:
417-
if (i > 0)
418-
for (j = 0; j < i; j++)
419-
device_remove_file(&connector->kdev,
420-
&connector_attrs[i]);
420+
for (i = 0; i < opt_cnt; i++)
421+
device_remove_file(&connector->kdev, &connector_attrs_opt1[i]);
422+
for (i = 0; i < attr_cnt; i++)
423+
device_remove_file(&connector->kdev, &connector_attrs[i]);
421424
device_unregister(&connector->kdev);
422425

423426
out:

‎drivers/gpu/drm/radeon/atombios.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2912,7 +2912,7 @@ typedef struct _ATOM_ANALOG_TV_INFO_V1_2
29122912
UCHAR ucTV_BootUpDefaultStandard;
29132913
UCHAR ucExt_TV_ASIC_ID;
29142914
UCHAR ucExt_TV_ASIC_SlaveAddr;
2915-
ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING];
2915+
ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING_V1_2];
29162916
}ATOM_ANALOG_TV_INFO_V1_2;
29172917

29182918
typedef struct _ATOM_DPCD_INFO

‎drivers/gpu/drm/radeon/r100.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
29752975

29762976
for (i = 0; i < track->num_cb; i++) {
29772977
if (track->cb[i].robj == NULL) {
2978-
if (!(track->fastfill || track->color_channel_mask ||
2978+
if (!(track->zb_cb_clear || track->color_channel_mask ||
29792979
track->blend_read_enable)) {
29802980
continue;
29812981
}

‎drivers/gpu/drm/radeon/r100_track.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct r100_cs_track {
7575
struct r100_cs_track_texture textures[R300_TRACK_MAX_TEXTURE];
7676
bool z_enabled;
7777
bool separate_cube;
78-
bool fastfill;
78+
bool zb_cb_clear;
7979
bool blend_read_enable;
8080
};
8181

‎drivers/gpu/drm/radeon/r300.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
10441044
break;
10451045
case 0x4d1c:
10461046
/* ZB_BW_CNTL */
1047-
track->fastfill = !!(idx_value & (1 << 2));
1047+
track->zb_cb_clear = !!(idx_value & (1 << 5));
10481048
break;
10491049
case 0x4e04:
10501050
/* RB3D_BLENDCNTL */

‎drivers/gpu/drm/radeon/radeon_agp.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,10 @@ int radeon_agp_init(struct radeon_device *rdev)
134134
int ret;
135135

136136
/* Acquire AGP. */
137-
if (!rdev->ddev->agp->acquired) {
138-
ret = drm_agp_acquire(rdev->ddev);
139-
if (ret) {
140-
DRM_ERROR("Unable to acquire AGP: %d\n", ret);
141-
return ret;
142-
}
137+
ret = drm_agp_acquire(rdev->ddev);
138+
if (ret) {
139+
DRM_ERROR("Unable to acquire AGP: %d\n", ret);
140+
return ret;
143141
}
144142

145143
ret = drm_agp_info(rdev->ddev, &info);

‎drivers/gpu/drm/radeon/radeon_atombios.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
12641264
switch (crev) {
12651265
case 1:
12661266
tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset);
1267-
if (index > MAX_SUPPORTED_TV_TIMING)
1267+
if (index >= MAX_SUPPORTED_TV_TIMING)
12681268
return false;
12691269

12701270
mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total);
@@ -1302,7 +1302,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
13021302
break;
13031303
case 2:
13041304
tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset);
1305-
if (index > MAX_SUPPORTED_TV_TIMING_V1_2)
1305+
if (index >= MAX_SUPPORTED_TV_TIMING_V1_2)
13061306
return false;
13071307

13081308
dtd_timings = &tv_info_v1_2->aModeTimings[index];

‎drivers/gpu/drm/radeon/radeon_connectors.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,8 @@ radeon_add_legacy_connector(struct drm_device *dev,
13161316
radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI");
13171317
if (!radeon_connector->ddc_bus)
13181318
goto failed;
1319+
}
1320+
if (connector_type == DRM_MODE_CONNECTOR_DVII) {
13191321
radeon_connector->dac_load_detect = true;
13201322
drm_connector_attach_property(&radeon_connector->base,
13211323
rdev->mode_info.load_detect_property,

‎drivers/gpu/drm/radeon/radeon_encoders.c‎

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,53 @@ radeon_get_atom_connector_priv_from_encoder(struct drm_encoder *encoder)
254254
return dig_connector;
255255
}
256256

257+
void radeon_panel_mode_fixup(struct drm_encoder *encoder,
258+
struct drm_display_mode *adjusted_mode)
259+
{
260+
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
261+
struct drm_device *dev = encoder->dev;
262+
struct radeon_device *rdev = dev->dev_private;
263+
struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
264+
unsigned hblank = native_mode->htotal - native_mode->hdisplay;
265+
unsigned vblank = native_mode->vtotal - native_mode->vdisplay;
266+
unsigned hover = native_mode->hsync_start - native_mode->hdisplay;
267+
unsigned vover = native_mode->vsync_start - native_mode->vdisplay;
268+
unsigned hsync_width = native_mode->hsync_end - native_mode->hsync_start;
269+
unsigned vsync_width = native_mode->vsync_end - native_mode->vsync_start;
270+
271+
adjusted_mode->clock = native_mode->clock;
272+
adjusted_mode->flags = native_mode->flags;
273+
274+
if (ASIC_IS_AVIVO(rdev)) {
275+
adjusted_mode->hdisplay = native_mode->hdisplay;
276+
adjusted_mode->vdisplay = native_mode->vdisplay;
277+
}
278+
279+
adjusted_mode->htotal = native_mode->hdisplay + hblank;
280+
adjusted_mode->hsync_start = native_mode->hdisplay + hover;
281+
adjusted_mode->hsync_end = adjusted_mode->hsync_start + hsync_width;
282+
283+
adjusted_mode->vtotal = native_mode->vdisplay + vblank;
284+
adjusted_mode->vsync_start = native_mode->vdisplay + vover;
285+
adjusted_mode->vsync_end = adjusted_mode->vsync_start + vsync_width;
286+
287+
drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
288+
289+
if (ASIC_IS_AVIVO(rdev)) {
290+
adjusted_mode->crtc_hdisplay = native_mode->hdisplay;
291+
adjusted_mode->crtc_vdisplay = native_mode->vdisplay;
292+
}
293+
294+
adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + hblank;
295+
adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + hover;
296+
adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + hsync_width;
297+
298+
adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + vblank;
299+
adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + vover;
300+
adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + vsync_width;
301+
302+
}
303+
257304
static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
258305
struct drm_display_mode *mode,
259306
struct drm_display_mode *adjusted_mode)
@@ -275,18 +322,8 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
275322
adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2;
276323

277324
/* get the native mode for LVDS */
278-
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) {
279-
struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
280-
int mode_id = adjusted_mode->base.id;
281-
*adjusted_mode = *native_mode;
282-
if (!ASIC_IS_AVIVO(rdev)) {
283-
adjusted_mode->hdisplay = mode->hdisplay;
284-
adjusted_mode->vdisplay = mode->vdisplay;
285-
adjusted_mode->crtc_hdisplay = mode->hdisplay;
286-
adjusted_mode->crtc_vdisplay = mode->vdisplay;
287-
}
288-
adjusted_mode->base.id = mode_id;
289-
}
325+
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
326+
radeon_panel_mode_fixup(encoder, adjusted_mode);
290327

291328
/* get the native mode for TV */
292329
if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) {

0 commit comments

Comments
 (0)