* [PATCH] drm/crtc: constify drm_crtc_index parameter
@ 2016-10-10 15:26 Jani Nikula
2016-10-10 15:29 ` [Intel-gfx] " Daniel Vetter
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jani Nikula @ 2016-10-10 15:26 UTC (permalink / raw)
To: dri-devel; +Cc: jani.nikula, intel-gfx
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
I needed this for some stuff that turned out to be a dead end. But this
seems to be the right thing to do anyway.
---
include/drm/drm_crtc.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 61932f55f788..0aa292526567 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1342,7 +1342,7 @@ extern void drm_crtc_cleanup(struct drm_crtc *crtc);
* Given a registered CRTC, return the index of that CRTC within a DRM
* device's list of CRTCs.
*/
-static inline unsigned int drm_crtc_index(struct drm_crtc *crtc)
+static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc)
{
return crtc->index;
}
--
2.1.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/crtc: constify drm_crtc_index parameter
2016-10-10 15:26 [PATCH] drm/crtc: constify drm_crtc_index parameter Jani Nikula
@ 2016-10-10 15:29 ` Daniel Vetter
2016-10-10 15:34 ` Chris Wilson
2016-10-10 16:04 ` Ville Syrjälä
2 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2016-10-10 15:29 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx, dri-devel
On Mon, Oct 10, 2016 at 06:26:10PM +0300, Jani Nikula wrote:
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> ---
>
> I needed this for some stuff that turned out to be a dead end. But this
> seems to be the right thing to do anyway.
Applied to drm-misc. There's also the connector and plane versions of
this, care to spin them too?
-Daniel
> ---
> include/drm/drm_crtc.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 61932f55f788..0aa292526567 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1342,7 +1342,7 @@ extern void drm_crtc_cleanup(struct drm_crtc *crtc);
> * Given a registered CRTC, return the index of that CRTC within a DRM
> * device's list of CRTCs.
> */
> -static inline unsigned int drm_crtc_index(struct drm_crtc *crtc)
> +static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc)
> {
> return crtc->index;
> }
> --
> 2.1.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/crtc: constify drm_crtc_index parameter
2016-10-10 15:26 [PATCH] drm/crtc: constify drm_crtc_index parameter Jani Nikula
2016-10-10 15:29 ` [Intel-gfx] " Daniel Vetter
@ 2016-10-10 15:34 ` Chris Wilson
2016-10-10 16:04 ` Ville Syrjälä
2 siblings, 0 replies; 7+ messages in thread
From: Chris Wilson @ 2016-10-10 15:34 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx, dri-devel
On Mon, Oct 10, 2016 at 06:26:10PM +0300, Jani Nikula wrote:
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Plus equivalents in drm_plane.h, drm_encoder.h ...
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/crtc: constify drm_crtc_index parameter
2016-10-10 15:26 [PATCH] drm/crtc: constify drm_crtc_index parameter Jani Nikula
2016-10-10 15:29 ` [Intel-gfx] " Daniel Vetter
2016-10-10 15:34 ` Chris Wilson
@ 2016-10-10 16:04 ` Ville Syrjälä
2016-10-10 16:10 ` Daniel Vetter
2 siblings, 1 reply; 7+ messages in thread
From: Ville Syrjälä @ 2016-10-10 16:04 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx, dri-devel
On Mon, Oct 10, 2016 at 06:26:10PM +0300, Jani Nikula wrote:
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> ---
>
> I needed this for some stuff that turned out to be a dead end. But this
> seems to be the right thing to do anyway.
> ---
> include/drm/drm_crtc.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 61932f55f788..0aa292526567 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1342,7 +1342,7 @@ extern void drm_crtc_cleanup(struct drm_crtc *crtc);
> * Given a registered CRTC, return the index of that CRTC within a DRM
> * device's list of CRTCs.
> */
> -static inline unsigned int drm_crtc_index(struct drm_crtc *crtc)
> +static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc)
> {
> return crtc->index;
BTW speaking about the index stuff. It dawned on me recently that calling
drm_crtc_cleanup() & co. is totally not safe except maybe during the
final cleanup.
If you would do something like:
a = drm_crtc_init();
b = drm_crtc_init();
drm_crtc_cleanup(a);
c = drm_crtc_init();
b and c would end up with the same index.
Or if you would do just
a = drm_crtc_init();
b = drm_crtc_init();
drm_crtc_cleanup(a);
We'd end up with num_crtc==1, but b->index==1, so we'd actually access
beyond the allocated arrays in a bunch of places.
This would need to fixed somehow, or at least documented clearly that if
you have to call any of the cleanup functions during init, you have to
abort the entire thing.
--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/crtc: constify drm_crtc_index parameter
2016-10-10 16:04 ` Ville Syrjälä
@ 2016-10-10 16:10 ` Daniel Vetter
2016-10-10 16:30 ` Ville Syrjälä
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2016-10-10 16:10 UTC (permalink / raw)
To: Ville Syrjälä; +Cc: Jani Nikula, intel-gfx, dri-devel
On Mon, Oct 10, 2016 at 6:04 PM, Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
> On Mon, Oct 10, 2016 at 06:26:10PM +0300, Jani Nikula wrote:
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>>
>> ---
>>
>> I needed this for some stuff that turned out to be a dead end. But this
>> seems to be the right thing to do anyway.
>> ---
>> include/drm/drm_crtc.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
>> index 61932f55f788..0aa292526567 100644
>> --- a/include/drm/drm_crtc.h
>> +++ b/include/drm/drm_crtc.h
>> @@ -1342,7 +1342,7 @@ extern void drm_crtc_cleanup(struct drm_crtc *crtc);
>> * Given a registered CRTC, return the index of that CRTC within a DRM
>> * device's list of CRTCs.
>> */
>> -static inline unsigned int drm_crtc_index(struct drm_crtc *crtc)
>> +static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc)
>> {
>> return crtc->index;
>
> BTW speaking about the index stuff. It dawned on me recently that calling
> drm_crtc_cleanup() & co. is totally not safe except maybe during the
> final cleanup.
>
> If you would do something like:
> a = drm_crtc_init();
> b = drm_crtc_init();
> drm_crtc_cleanup(a);
> c = drm_crtc_init();
>
> b and c would end up with the same index.
>
>
> Or if you would do just
> a = drm_crtc_init();
> b = drm_crtc_init();
> drm_crtc_cleanup(a);
>
> We'd end up with num_crtc==1, but b->index==1, so we'd actually access
> beyond the allocated arrays in a bunch of places.
>
> This would need to fixed somehow, or at least documented clearly that if
> you have to call any of the cleanup functions during init, you have to
> abort the entire thing.
You can't hotplug CRTCs, like you can't hotplug anything else than
connectors. And for connectors we have an ida to make sure you never
end up with duplicated indizes. So I think we're safe.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm/crtc: constify drm_crtc_index parameter
2016-10-10 16:10 ` Daniel Vetter
@ 2016-10-10 16:30 ` Ville Syrjälä
2016-10-10 17:19 ` [Intel-gfx] " Daniel Vetter
0 siblings, 1 reply; 7+ messages in thread
From: Ville Syrjälä @ 2016-10-10 16:30 UTC (permalink / raw)
To: Daniel Vetter; +Cc: Jani Nikula, intel-gfx, dri-devel
On Mon, Oct 10, 2016 at 06:10:42PM +0200, Daniel Vetter wrote:
> On Mon, Oct 10, 2016 at 6:04 PM, Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> > On Mon, Oct 10, 2016 at 06:26:10PM +0300, Jani Nikula wrote:
> >> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> >>
> >> ---
> >>
> >> I needed this for some stuff that turned out to be a dead end. But this
> >> seems to be the right thing to do anyway.
> >> ---
> >> include/drm/drm_crtc.h | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> >> index 61932f55f788..0aa292526567 100644
> >> --- a/include/drm/drm_crtc.h
> >> +++ b/include/drm/drm_crtc.h
> >> @@ -1342,7 +1342,7 @@ extern void drm_crtc_cleanup(struct drm_crtc *crtc);
> >> * Given a registered CRTC, return the index of that CRTC within a DRM
> >> * device's list of CRTCs.
> >> */
> >> -static inline unsigned int drm_crtc_index(struct drm_crtc *crtc)
> >> +static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc)
> >> {
> >> return crtc->index;
> >
> > BTW speaking about the index stuff. It dawned on me recently that calling
> > drm_crtc_cleanup() & co. is totally not safe except maybe during the
> > final cleanup.
> >
> > If you would do something like:
> > a = drm_crtc_init();
> > b = drm_crtc_init();
> > drm_crtc_cleanup(a);
> > c = drm_crtc_init();
> >
> > b and c would end up with the same index.
> >
> >
> > Or if you would do just
> > a = drm_crtc_init();
> > b = drm_crtc_init();
> > drm_crtc_cleanup(a);
> >
> > We'd end up with num_crtc==1, but b->index==1, so we'd actually access
> > beyond the allocated arrays in a bunch of places.
> >
> > This would need to fixed somehow, or at least documented clearly that if
> > you have to call any of the cleanup functions during init, you have to
> > abort the entire thing.
>
> You can't hotplug CRTCs, like you can't hotplug anything else than
> connectors. And for connectors we have an ida to make sure you never
> end up with duplicated indizes. So I think we're safe.
Except in i915 we don't abort the driver load if we would fail part
way into the crtc init. So we'd just keep going with bogus indexes
and whatnot. I think I wrote a patch to change that, but I'd have
find it again to be sure. Other drivers may or may not have the same
problem.
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/crtc: constify drm_crtc_index parameter
2016-10-10 16:30 ` Ville Syrjälä
@ 2016-10-10 17:19 ` Daniel Vetter
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2016-10-10 17:19 UTC (permalink / raw)
To: Ville Syrjälä; +Cc: Jani Nikula, intel-gfx, dri-devel
On Mon, Oct 10, 2016 at 6:30 PM, Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>> You can't hotplug CRTCs, like you can't hotplug anything else than
>> connectors. And for connectors we have an ida to make sure you never
>> end up with duplicated indizes. So I think we're safe.
>
> Except in i915 we don't abort the driver load if we would fail part
> way into the crtc init. So we'd just keep going with bogus indexes
> and whatnot. I think I wrote a patch to change that, but I'd have
> find it again to be sure. Other drivers may or may not have the same
> problem.
Hm, we should at least make sure we don't leave any partially
initialized modeset objects behind when the modeset part of the driver
fails to load.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-10-10 17:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-10 15:26 [PATCH] drm/crtc: constify drm_crtc_index parameter Jani Nikula
2016-10-10 15:29 ` [Intel-gfx] " Daniel Vetter
2016-10-10 15:34 ` Chris Wilson
2016-10-10 16:04 ` Ville Syrjälä
2016-10-10 16:10 ` Daniel Vetter
2016-10-10 16:30 ` Ville Syrjälä
2016-10-10 17:19 ` [Intel-gfx] " Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).