Message ID | 20240813105134.17439-9-jose.exposito89@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | VKMS: Add configfs support | expand |
Le 13/08/24 - 12:44, José Expósito a écrit : > Add a list of connector configurations to vkms_config and add as many > connector as configured during output initialization. > > For backwards compatibility, create a single connector in the default > configuration. > > Signed-off-by: José Expósito <jose.exposito89@gmail.com> > --- > drivers/gpu/drm/vkms/vkms_config.c | 40 ++++++++++++++++++++++++++++++ > drivers/gpu/drm/vkms/vkms_config.h | 12 +++++++++ > drivers/gpu/drm/vkms/vkms_output.c | 11 +++++--- > 3 files changed, 59 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c > index 6a8dfebee24e..a456f9db3c66 100644 > --- a/drivers/gpu/drm/vkms/vkms_config.c > +++ b/drivers/gpu/drm/vkms/vkms_config.c > @@ -19,6 +19,7 @@ struct vkms_config *vkms_config_create(char *dev_name) > config->dev_name = dev_name; > config->crtcs = (struct list_head)LIST_HEAD_INIT(config->crtcs); > config->encoders = (struct list_head)LIST_HEAD_INIT(config->encoders); > + config->connectors = (struct list_head)LIST_HEAD_INIT(config->connectors); Again, this cast seems useless > return config; > } > @@ -30,6 +31,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, > struct vkms_config *config; > struct vkms_config_crtc *crtc_cfg; > struct vkms_config_encoder *encoder_cfg; > + struct vkms_config_connector *connector_cfg; > > config = vkms_config_create(DEFAULT_DEVICE_NAME); > if (IS_ERR(config)) > @@ -46,6 +48,10 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, > if (IS_ERR(encoder_cfg)) > return ERR_CAST(encoder_cfg); > > + connector_cfg = vkms_config_add_connector(config, BIT(0)); > + if (IS_ERR(connector_cfg)) > + return ERR_CAST(connector_cfg); > + The config pointer is leaked here. > return config; > } > > @@ -53,6 +59,7 @@ void vkms_config_destroy(struct vkms_config *config) > { > struct vkms_config_crtc *crtc_cfg, *crtc_tmp; > struct vkms_config_encoder *encoder_cfg, *encoder_tmp; > + struct vkms_config_connector *connector_cfg, *connector_tmp; > > list_for_each_entry_safe(crtc_cfg, crtc_tmp, &config->crtcs, list) > vkms_config_destroy_crtc(config, crtc_cfg); > @@ -60,6 +67,9 @@ void vkms_config_destroy(struct vkms_config *config) > list_for_each_entry_safe(encoder_cfg, encoder_tmp, &config->encoders, list) > vkms_config_destroy_encoder(config, encoder_cfg); > > + list_for_each_entry_safe(connector_cfg, connector_tmp, &config->connectors, list) > + vkms_config_destroy_connector(config, connector_cfg); > + > kfree(config); > } > > @@ -70,6 +80,7 @@ static int vkms_config_show(struct seq_file *m, void *data) > struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); > struct vkms_config_crtc *crtc_cfg; > struct vkms_config_encoder *encoder_cfg; > + struct vkms_config_connector *connector_cfg; > int n; > > seq_printf(m, "dev_name=%s\n", vkmsdev->config->dev_name); > @@ -90,6 +101,13 @@ static int vkms_config_show(struct seq_file *m, void *data) > n++; > } > > + n = 0; > + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { > + seq_printf(m, "connector(%d).possible_encoders=%d\n", n, > + connector_cfg->possible_encoders); > + n++; > + } > + > return 0; > } > > @@ -166,3 +184,25 @@ void vkms_config_destroy_encoder(struct vkms_config *config, > list_del(&encoder_cfg->list); > kfree(encoder_cfg); > } > + > +struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, > + uint32_t possible_encoders) > +{ > + struct vkms_config_connector *connector_cfg; > + > + connector_cfg = kzalloc(sizeof(*connector_cfg), GFP_KERNEL); > + if (!connector_cfg) > + return ERR_PTR(-ENOMEM); > + > + connector_cfg->possible_encoders = possible_encoders; For config_encoder destruction you need to remove it from this possible_encoders list. > + list_add_tail(&connector_cfg->list, &config->connectors); > + > + return connector_cfg; > +} > + > +void vkms_config_destroy_connector(struct vkms_config *config, > + struct vkms_config_connector *connector_cfg) > +{ > + list_del(&connector_cfg->list); > + kfree(connector_cfg); > +} > diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h > index b717b5c0d3d9..f1dd59fc6300 100644 > --- a/drivers/gpu/drm/vkms/vkms_config.h > +++ b/drivers/gpu/drm/vkms/vkms_config.h > @@ -20,12 +20,18 @@ struct vkms_config_encoder { > uint32_t possible_crtcs; > }; > > +struct vkms_config_connector { > + struct list_head list; > + uint32_t possible_encoders; > +}; > + > struct vkms_config { > char *dev_name; > bool cursor; > bool overlay; > struct list_head crtcs; > struct list_head encoders; > + struct list_head connectors; > /* only set when instantiated */ > struct vkms_device *dev; > }; > @@ -52,4 +58,10 @@ struct vkms_config_encoder *vkms_config_add_encoder(struct vkms_config *config, > void vkms_config_destroy_encoder(struct vkms_config *config, > struct vkms_config_encoder *encoder_cfg); > > +/* Connectors */ > +struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, > + uint32_t possible_encoders); > +void vkms_config_destroy_connector(struct vkms_config *config, > + struct vkms_config_connector *connector_cfg); > + > #endif /* _VKMS_CONFIG_H_ */ > diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c > index 4413cf88afc7..021a491de817 100644 > --- a/drivers/gpu/drm/vkms/vkms_output.c > +++ b/drivers/gpu/drm/vkms/vkms_output.c > @@ -100,6 +100,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) > { > struct drm_device *dev = &vkmsdev->drm; > struct drm_connector *connector; > + struct vkms_config_connector *connector_cfg; > struct drm_encoder *encoder; > struct vkms_config_encoder *encoder_cfg; > struct vkms_crtc *vkms_crtc; > @@ -142,10 +143,6 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) > } > } > > - connector = vkms_connector_init(vkmsdev, BIT(index)); > - if (IS_ERR(connector)) > - return PTR_ERR(connector); > - > list_for_each_entry(encoder_cfg, &vkmsdev->config->encoders, list) { > encoder = vkms_encoder_init(vkmsdev, encoder_cfg->possible_crtcs, > encoder_cfg->index); > @@ -153,6 +150,12 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) > return PTR_ERR(encoder); > } > > + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { > + connector = vkms_connector_init(vkmsdev, connector_cfg->possible_encoders); > + if (IS_ERR(connector)) > + return PTR_ERR(connector); > + } > + > drm_mode_config_reset(dev); > > return 0; > -- > 2.46.0 >
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 6a8dfebee24e..a456f9db3c66 100644 --- a/drivers/gpu/drm/vkms/vkms_config.c +++ b/drivers/gpu/drm/vkms/vkms_config.c @@ -19,6 +19,7 @@ struct vkms_config *vkms_config_create(char *dev_name) config->dev_name = dev_name; config->crtcs = (struct list_head)LIST_HEAD_INIT(config->crtcs); config->encoders = (struct list_head)LIST_HEAD_INIT(config->encoders); + config->connectors = (struct list_head)LIST_HEAD_INIT(config->connectors); return config; } @@ -30,6 +31,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, struct vkms_config *config; struct vkms_config_crtc *crtc_cfg; struct vkms_config_encoder *encoder_cfg; + struct vkms_config_connector *connector_cfg; config = vkms_config_create(DEFAULT_DEVICE_NAME); if (IS_ERR(config)) @@ -46,6 +48,10 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor, if (IS_ERR(encoder_cfg)) return ERR_CAST(encoder_cfg); + connector_cfg = vkms_config_add_connector(config, BIT(0)); + if (IS_ERR(connector_cfg)) + return ERR_CAST(connector_cfg); + return config; } @@ -53,6 +59,7 @@ void vkms_config_destroy(struct vkms_config *config) { struct vkms_config_crtc *crtc_cfg, *crtc_tmp; struct vkms_config_encoder *encoder_cfg, *encoder_tmp; + struct vkms_config_connector *connector_cfg, *connector_tmp; list_for_each_entry_safe(crtc_cfg, crtc_tmp, &config->crtcs, list) vkms_config_destroy_crtc(config, crtc_cfg); @@ -60,6 +67,9 @@ void vkms_config_destroy(struct vkms_config *config) list_for_each_entry_safe(encoder_cfg, encoder_tmp, &config->encoders, list) vkms_config_destroy_encoder(config, encoder_cfg); + list_for_each_entry_safe(connector_cfg, connector_tmp, &config->connectors, list) + vkms_config_destroy_connector(config, connector_cfg); + kfree(config); } @@ -70,6 +80,7 @@ static int vkms_config_show(struct seq_file *m, void *data) struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); struct vkms_config_crtc *crtc_cfg; struct vkms_config_encoder *encoder_cfg; + struct vkms_config_connector *connector_cfg; int n; seq_printf(m, "dev_name=%s\n", vkmsdev->config->dev_name); @@ -90,6 +101,13 @@ static int vkms_config_show(struct seq_file *m, void *data) n++; } + n = 0; + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { + seq_printf(m, "connector(%d).possible_encoders=%d\n", n, + connector_cfg->possible_encoders); + n++; + } + return 0; } @@ -166,3 +184,25 @@ void vkms_config_destroy_encoder(struct vkms_config *config, list_del(&encoder_cfg->list); kfree(encoder_cfg); } + +struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, + uint32_t possible_encoders) +{ + struct vkms_config_connector *connector_cfg; + + connector_cfg = kzalloc(sizeof(*connector_cfg), GFP_KERNEL); + if (!connector_cfg) + return ERR_PTR(-ENOMEM); + + connector_cfg->possible_encoders = possible_encoders; + list_add_tail(&connector_cfg->list, &config->connectors); + + return connector_cfg; +} + +void vkms_config_destroy_connector(struct vkms_config *config, + struct vkms_config_connector *connector_cfg) +{ + list_del(&connector_cfg->list); + kfree(connector_cfg); +} diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h index b717b5c0d3d9..f1dd59fc6300 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -20,12 +20,18 @@ struct vkms_config_encoder { uint32_t possible_crtcs; }; +struct vkms_config_connector { + struct list_head list; + uint32_t possible_encoders; +}; + struct vkms_config { char *dev_name; bool cursor; bool overlay; struct list_head crtcs; struct list_head encoders; + struct list_head connectors; /* only set when instantiated */ struct vkms_device *dev; }; @@ -52,4 +58,10 @@ struct vkms_config_encoder *vkms_config_add_encoder(struct vkms_config *config, void vkms_config_destroy_encoder(struct vkms_config *config, struct vkms_config_encoder *encoder_cfg); +/* Connectors */ +struct vkms_config_connector *vkms_config_add_connector(struct vkms_config *config, + uint32_t possible_encoders); +void vkms_config_destroy_connector(struct vkms_config *config, + struct vkms_config_connector *connector_cfg); + #endif /* _VKMS_CONFIG_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 4413cf88afc7..021a491de817 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -100,6 +100,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) { struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; + struct vkms_config_connector *connector_cfg; struct drm_encoder *encoder; struct vkms_config_encoder *encoder_cfg; struct vkms_crtc *vkms_crtc; @@ -142,10 +143,6 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) } } - connector = vkms_connector_init(vkmsdev, BIT(index)); - if (IS_ERR(connector)) - return PTR_ERR(connector); - list_for_each_entry(encoder_cfg, &vkmsdev->config->encoders, list) { encoder = vkms_encoder_init(vkmsdev, encoder_cfg->possible_crtcs, encoder_cfg->index); @@ -153,6 +150,12 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) return PTR_ERR(encoder); } + list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, list) { + connector = vkms_connector_init(vkmsdev, connector_cfg->possible_encoders); + if (IS_ERR(connector)) + return PTR_ERR(connector); + } + drm_mode_config_reset(dev); return 0;
Add a list of connector configurations to vkms_config and add as many connector as configured during output initialization. For backwards compatibility, create a single connector in the default configuration. Signed-off-by: José Expósito <jose.exposito89@gmail.com> --- drivers/gpu/drm/vkms/vkms_config.c | 40 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 12 +++++++++ drivers/gpu/drm/vkms/vkms_output.c | 11 +++++--- 3 files changed, 59 insertions(+), 4 deletions(-)