Skip to content

Commit 5cab385

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: agp: zero pages before sending to userspace drm: check for minor master before allowing drop master. drm: set/clear is_master when master changed drm: clean dirty memory after device release drm: count reaches -1
2 parents 2edbdd1 + 59de2be commit 5cab385

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

drivers/char/agp/generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ int agp_generic_alloc_pages(struct agp_bridge_data *bridge, struct agp_memory *m
12261226
int i, ret = -ENOMEM;
12271227

12281228
for (i = 0; i < num_pages; i++) {
1229-
page = alloc_page(GFP_KERNEL | GFP_DMA32);
1229+
page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO);
12301230
/* agp_free_memory() needs gart address */
12311231
if (page == NULL)
12321232
goto out;
@@ -1257,7 +1257,7 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
12571257
{
12581258
struct page * page;
12591259

1260-
page = alloc_page(GFP_KERNEL | GFP_DMA32);
1260+
page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO);
12611261
if (page == NULL)
12621262
return NULL;
12631263

drivers/gpu/drm/drm_stub.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ void drm_master_put(struct drm_master **master)
159159
int drm_setmaster_ioctl(struct drm_device *dev, void *data,
160160
struct drm_file *file_priv)
161161
{
162+
if (file_priv->is_master)
163+
return 0;
164+
162165
if (file_priv->minor->master && file_priv->minor->master != file_priv->master)
163166
return -EINVAL;
164167

@@ -169,6 +172,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
169172
file_priv->minor->master != file_priv->master) {
170173
mutex_lock(&dev->struct_mutex);
171174
file_priv->minor->master = drm_master_get(file_priv->master);
175+
file_priv->is_master = 1;
172176
mutex_unlock(&dev->struct_mutex);
173177
}
174178

@@ -178,10 +182,15 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
178182
int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
179183
struct drm_file *file_priv)
180184
{
181-
if (!file_priv->master)
185+
if (!file_priv->is_master)
182186
return -EINVAL;
187+
188+
if (!file_priv->minor->master)
189+
return -EINVAL;
190+
183191
mutex_lock(&dev->struct_mutex);
184192
drm_master_put(&file_priv->minor->master);
193+
file_priv->is_master = 0;
185194
mutex_unlock(&dev->struct_mutex);
186195
return 0;
187196
}

drivers/gpu/drm/drm_sysfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ void drm_sysfs_destroy(void)
132132
*/
133133
static void drm_sysfs_device_release(struct device *dev)
134134
{
135+
memset(dev, 0, sizeof(struct device));
135136
return;
136137
}
137138

drivers/gpu/drm/via/via_dma.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,13 @@ static int via_wait_idle(drm_via_private_t * dev_priv)
481481
{
482482
int count = 10000000;
483483

484-
while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && count--);
484+
while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && --count)
485+
;
485486

486-
while (count-- && (VIA_READ(VIA_REG_STATUS) &
487+
while (count && (VIA_READ(VIA_REG_STATUS) &
487488
(VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY |
488-
VIA_3D_ENG_BUSY))) ;
489+
VIA_3D_ENG_BUSY)))
490+
--count;
489491
return count;
490492
}
491493

@@ -705,7 +707,7 @@ static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *
705707
switch (d_siz->func) {
706708
case VIA_CMDBUF_SPACE:
707709
while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size)
708-
&& count--) {
710+
&& --count) {
709711
if (!d_siz->wait) {
710712
break;
711713
}
@@ -717,7 +719,7 @@ static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *
717719
break;
718720
case VIA_CMDBUF_LAG:
719721
while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size)
720-
&& count--) {
722+
&& --count) {
721723
if (!d_siz->wait) {
722724
break;
723725
}

0 commit comments

Comments
 (0)