mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-05-09 06:18:05 +02:00
NV50: A few minor added safeties + cleanup.
This commit is contained in:
parent
3809209349
commit
e67cd7dda9
10 changed files with 75 additions and 17 deletions
|
|
@ -532,6 +532,8 @@ int nouveau_parse_bios(struct drm_device *dev)
|
|||
int offset;
|
||||
|
||||
dev_priv->bios.data = kzalloc(NV50_PROM__ESIZE, GFP_KERNEL);
|
||||
if (!dev_priv->bios.data)
|
||||
return -ENOMEM;
|
||||
|
||||
if (!nv_shadow_bios(dev, dev_priv->bios.data))
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -463,6 +463,7 @@ int nv50_crtc_create(struct drm_device *dev, int index)
|
|||
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
||||
struct nv50_crtc *crtc = NULL;
|
||||
struct nv50_display *display = NULL;
|
||||
int rval = 0;
|
||||
|
||||
NV50_DEBUG("\n");
|
||||
|
||||
|
|
@ -476,8 +477,10 @@ int nv50_crtc_create(struct drm_device *dev, int index)
|
|||
crtc->dev = dev;
|
||||
|
||||
display = nv50_get_display(dev);
|
||||
if (!display)
|
||||
if (!display) {
|
||||
rval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
list_add_tail(&crtc->head, &display->crtcs);
|
||||
|
||||
|
|
@ -486,6 +489,11 @@ int nv50_crtc_create(struct drm_device *dev, int index)
|
|||
crtc->mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
|
||||
crtc->native_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
|
||||
|
||||
if (!crtc->mode || crtc->native_mode) {
|
||||
rval = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
nv50_fb_create(crtc);
|
||||
nv50_lut_create(crtc);
|
||||
nv50_cursor_create(crtc);
|
||||
|
|
@ -511,5 +519,5 @@ out:
|
|||
if (dev_priv->free_crtc)
|
||||
dev_priv->free_crtc(crtc);
|
||||
|
||||
return -EINVAL;
|
||||
return rval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@ int nv50_cursor_create(struct nv50_crtc *crtc)
|
|||
return -EINVAL;
|
||||
|
||||
crtc->cursor = kzalloc(sizeof(struct nv50_cursor), GFP_KERNEL);
|
||||
if (!crtc->cursor)
|
||||
return -ENOMEM;
|
||||
|
||||
/* function pointers */
|
||||
crtc->cursor->show = nv50_cursor_show;
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
|
|||
struct nv50_output *output = NULL;
|
||||
struct nv50_display *display = NULL;
|
||||
struct dcb_entry *entry = NULL;
|
||||
int rval = 0;
|
||||
|
||||
NV50_DEBUG("\n");
|
||||
|
||||
|
|
@ -135,12 +136,16 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
|
|||
output->dev = dev;
|
||||
|
||||
display = nv50_get_display(dev);
|
||||
if (!display)
|
||||
if (!display) {
|
||||
rval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
entry = &dev_priv->dcb_table.entry[dcb_entry];
|
||||
if (!entry)
|
||||
if (!entry) {
|
||||
rval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (entry->type) {
|
||||
case DCB_OUTPUT_ANALOG:
|
||||
|
|
@ -148,6 +153,7 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
|
|||
DRM_INFO("Detected a DAC output\n");
|
||||
break;
|
||||
default:
|
||||
rval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -157,6 +163,10 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
|
|||
list_add_tail(&output->head, &display->outputs);
|
||||
|
||||
output->native_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
|
||||
if (!output->native_mode) {
|
||||
rval = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Set function pointers. */
|
||||
output->validate_mode = nv50_dac_validate_mode;
|
||||
|
|
@ -172,6 +182,6 @@ out:
|
|||
kfree(output->native_mode);
|
||||
if (dev_priv->free_output)
|
||||
dev_priv->free_output(output);
|
||||
return -EINVAL;
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,6 +189,9 @@ int nv50_display_create(struct drm_device *dev)
|
|||
|
||||
NV50_DEBUG("\n");
|
||||
|
||||
if (!display)
|
||||
return -ENOMEM;
|
||||
|
||||
INIT_LIST_HEAD(&display->crtcs);
|
||||
INIT_LIST_HEAD(&display->outputs);
|
||||
INIT_LIST_HEAD(&display->connectors);
|
||||
|
|
|
|||
|
|
@ -119,6 +119,9 @@ int nv50_fb_create(struct nv50_crtc *crtc)
|
|||
|
||||
crtc->fb = kzalloc(sizeof(struct nv50_fb), GFP_KERNEL);
|
||||
|
||||
if (!crtc->fb)
|
||||
return -ENOMEM;
|
||||
|
||||
crtc->fb->bind = nv50_fb_bind;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,10 @@ static void *nv50_kms_alloc_crtc(struct drm_device *dev)
|
|||
struct nv50_kms_priv *kms_priv = nv50_get_kms_priv(dev);
|
||||
struct nv50_kms_crtc *crtc = kzalloc(sizeof(struct nv50_kms_crtc), GFP_KERNEL);
|
||||
|
||||
list_add_tail(&crtc->head, &kms_priv->crtcs);
|
||||
if (!crtc)
|
||||
return NULL;
|
||||
|
||||
list_add_tail(&crtc->item, &kms_priv->crtcs);
|
||||
|
||||
return &(crtc->priv);
|
||||
}
|
||||
|
|
@ -58,7 +61,10 @@ static void *nv50_kms_alloc_output(struct drm_device *dev)
|
|||
struct nv50_kms_priv *kms_priv = nv50_get_kms_priv(dev);
|
||||
struct nv50_kms_encoder *encoder = kzalloc(sizeof(struct nv50_kms_encoder), GFP_KERNEL);
|
||||
|
||||
list_add_tail(&encoder->head, &kms_priv->encoders);
|
||||
if (!encoder)
|
||||
return NULL;
|
||||
|
||||
list_add_tail(&encoder->item, &kms_priv->encoders);
|
||||
|
||||
return &(encoder->priv);
|
||||
}
|
||||
|
|
@ -68,7 +74,10 @@ static void *nv50_kms_alloc_connector(struct drm_device *dev)
|
|||
struct nv50_kms_priv *kms_priv = nv50_get_kms_priv(dev);
|
||||
struct nv50_kms_connector *connector = kzalloc(sizeof(struct nv50_kms_connector), GFP_KERNEL);
|
||||
|
||||
list_add_tail(&connector->head, &kms_priv->connectors);
|
||||
if (!connector)
|
||||
return NULL;
|
||||
|
||||
list_add_tail(&connector->item, &kms_priv->connectors);
|
||||
|
||||
return &(connector->priv);
|
||||
}
|
||||
|
|
@ -77,7 +86,7 @@ static void nv50_kms_free_crtc(void *crtc)
|
|||
{
|
||||
struct nv50_kms_crtc *kms_crtc = from_nv50_crtc(crtc);
|
||||
|
||||
list_del(&kms_crtc->head);
|
||||
list_del(&kms_crtc->item);
|
||||
|
||||
kfree(kms_crtc);
|
||||
}
|
||||
|
|
@ -86,7 +95,7 @@ static void nv50_kms_free_output(void *output)
|
|||
{
|
||||
struct nv50_kms_encoder *kms_encoder = from_nv50_output(output);
|
||||
|
||||
list_del(&kms_encoder->head);
|
||||
list_del(&kms_encoder->item);
|
||||
|
||||
kfree(kms_encoder);
|
||||
}
|
||||
|
|
@ -95,7 +104,7 @@ static void nv50_kms_free_connector(void *connector)
|
|||
{
|
||||
struct nv50_kms_connector *kms_connector = from_nv50_connector(connector);
|
||||
|
||||
list_del(&kms_connector->head);
|
||||
list_del(&kms_connector->item);
|
||||
|
||||
kfree(kms_connector);
|
||||
}
|
||||
|
|
@ -107,6 +116,8 @@ static void nv50_kms_free_connector(void *connector)
|
|||
static struct nouveau_hw_mode *nv50_kms_to_hw_mode(struct drm_display_mode *mode)
|
||||
{
|
||||
struct nouveau_hw_mode *hw_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
|
||||
if (!hw_mode)
|
||||
return NULL;
|
||||
|
||||
/* create hw values. */
|
||||
hw_mode->clock = mode->clock;
|
||||
|
|
@ -870,6 +881,9 @@ int nv50_kms_init(struct drm_device *dev)
|
|||
struct nv50_display *display = NULL;
|
||||
int rval = 0;
|
||||
|
||||
if (!kms_priv)
|
||||
return -ENOMEM;
|
||||
|
||||
dev_priv->kms_priv = kms_priv;
|
||||
|
||||
/* function pointers */
|
||||
|
|
|
|||
|
|
@ -44,21 +44,21 @@
|
|||
/* Link internal modesetting structure to interface. */
|
||||
|
||||
struct nv50_kms_crtc {
|
||||
struct list_head head;
|
||||
struct list_head item;
|
||||
|
||||
struct nv50_crtc priv;
|
||||
struct drm_crtc pub;
|
||||
};
|
||||
|
||||
struct nv50_kms_encoder {
|
||||
struct list_head head;
|
||||
struct list_head item;
|
||||
|
||||
struct nv50_output priv;
|
||||
struct drm_encoder pub;
|
||||
};
|
||||
|
||||
struct nv50_kms_connector {
|
||||
struct list_head head;
|
||||
struct list_head item;
|
||||
|
||||
struct nv50_connector priv;
|
||||
struct drm_connector pub;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ static int nv50_lut_alloc(struct nv50_crtc *crtc)
|
|||
|
||||
NV50_DEBUG("\n");
|
||||
|
||||
if (!file_priv)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Any file_priv should do as it's pointer is used as identification. */
|
||||
block = nouveau_mem_alloc(crtc->dev, 0, 4096, flags, file_priv);
|
||||
|
||||
|
|
@ -137,6 +140,9 @@ int nv50_lut_create(struct nv50_crtc *crtc)
|
|||
|
||||
crtc->lut = kzalloc(sizeof(struct nv50_lut), GFP_KERNEL);
|
||||
|
||||
if (!crtc->lut)
|
||||
return -ENOMEM;
|
||||
|
||||
rval = nv50_lut_alloc(crtc);
|
||||
if (rval != 0)
|
||||
return rval;
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
|
|||
struct nv50_output *output = NULL;
|
||||
struct nv50_display *display = NULL;
|
||||
struct dcb_entry *entry = NULL;
|
||||
int rval = 0;
|
||||
|
||||
NV50_DEBUG("\n");
|
||||
|
||||
|
|
@ -151,12 +152,16 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
|
|||
output->dev = dev;
|
||||
|
||||
display = nv50_get_display(dev);
|
||||
if (!display)
|
||||
if (!display) {
|
||||
rval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
entry = &dev_priv->dcb_table.entry[dcb_entry];
|
||||
if (!entry)
|
||||
if (!entry) {
|
||||
rval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (entry->type) {
|
||||
case DCB_OUTPUT_TMDS:
|
||||
|
|
@ -168,6 +173,7 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
|
|||
DRM_INFO("Detected a LVDS output\n");
|
||||
break;
|
||||
default:
|
||||
rval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -177,6 +183,10 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
|
|||
list_add_tail(&output->head, &display->outputs);
|
||||
|
||||
output->native_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
|
||||
if (!output->native_mode) {
|
||||
rval = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Set function pointers. */
|
||||
output->validate_mode = nv50_sor_validate_mode;
|
||||
|
|
@ -200,5 +210,5 @@ out:
|
|||
kfree(output->native_mode);
|
||||
if (dev_priv->free_output)
|
||||
dev_priv->free_output(output);
|
||||
return -EINVAL;
|
||||
return rval;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue