All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-media@vger.kernel.org, Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org,
	Steve Longerbeam <steve_longerbeam@mentor.com>,
	kernel@pengutronix.de, Sascha Hauer <s.hauer@pengutronix.de>,
	Rob Herring <robh+dt@kernel.org>,
	Sakari Ailus <sakari.ailus@iki.fi>, Pavel Machek <pavel@ucw.cz>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Subject: Re: [PATCH 2/2] [media] platform: add video-multiplexer subdevice driver
Date: Wed, 3 May 2017 13:13:42 +0200	[thread overview]
Message-ID: <e1cda75b-4967-7d79-7f07-b4f392153d73@axentia.se> (raw)
In-Reply-To: <1493800556.3599.15.camel@pengutronix.de>

On 2017-05-03 10:35, Philipp Zabel wrote:
> On Tue, 2017-05-02 at 19:42 +0200, Peter Rosin wrote:
>> On 2017-05-02 17:21, Philipp Zabel wrote:
>>> Thank you, I've resent a version with a mutex lock around vmux->active.
>>
>> I had a bunch of ifs in the above message, so I'm not sure it's needed.
>> I would expect there to be a lock outside somewhere in the media layer.
>> A cursory look gets me to media-entity.c and media_entity_setup_link()
>> which does have a mutex. But I'm no media expert, so maybe there are other
>> ways of getting to video_mux_link_setup that I'm not aware of?
> 
> link_setup is always called under the graph mutex of the /dev/media
> device. That is why I didn't think about locking too hard. In fact, I
> initially wrote this expecting mux_control_get_exclusive to exist and
> the mux select/deselect not to be locked at all.
> 
> But set_format is called from an unlocked ioctl on a /dev/v4l-subdev
> device. Until your comments I didn't notice that it would be possible to
> let link_setup set active = -1 in the middle of the set_format call,
> causing it to return garbage.

Obviously, now that you point it out. I completely missed set_format...

Cheers,
peda

WARNING: multiple messages have this Message-ID (diff)
From: Peter Rosin <peda@axentia.se>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: <linux-media@vger.kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, <devicetree@vger.kernel.org>,
	Steve Longerbeam <steve_longerbeam@mentor.com>,
	<kernel@pengutronix.de>, Sascha Hauer <s.hauer@pengutronix.de>,
	Rob Herring <robh+dt@kernel.org>,
	Sakari Ailus <sakari.ailus@iki.fi>, Pavel Machek <pavel@ucw.cz>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Subject: Re: [PATCH 2/2] [media] platform: add video-multiplexer subdevice driver
Date: Wed, 3 May 2017 13:13:42 +0200	[thread overview]
Message-ID: <e1cda75b-4967-7d79-7f07-b4f392153d73@axentia.se> (raw)
In-Reply-To: <1493800556.3599.15.camel@pengutronix.de>

On 2017-05-03 10:35, Philipp Zabel wrote:
> On Tue, 2017-05-02 at 19:42 +0200, Peter Rosin wrote:
>> On 2017-05-02 17:21, Philipp Zabel wrote:
>>> Thank you, I've resent a version with a mutex lock around vmux->active.
>>
>> I had a bunch of ifs in the above message, so I'm not sure it's needed.
>> I would expect there to be a lock outside somewhere in the media layer.
>> A cursory look gets me to media-entity.c and media_entity_setup_link()
>> which does have a mutex. But I'm no media expert, so maybe there are other
>> ways of getting to video_mux_link_setup that I'm not aware of?
> 
> link_setup is always called under the graph mutex of the /dev/media
> device. That is why I didn't think about locking too hard. In fact, I
> initially wrote this expecting mux_control_get_exclusive to exist and
> the mux select/deselect not to be locked at all.
> 
> But set_format is called from an unlocked ioctl on a /dev/v4l-subdev
> device. Until your comments I didn't notice that it would be possible to
> let link_setup set active = -1 in the middle of the set_format call,
> causing it to return garbage.

Obviously, now that you point it out. I completely missed set_format...

Cheers,
peda

  reply	other threads:[~2017-05-03 11:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 14:13 [PATCH 1/2] [media] dt-bindings: Add bindings for video-multiplexer device Philipp Zabel
2017-04-28 14:13 ` [PATCH 2/2] [media] platform: add video-multiplexer subdevice driver Philipp Zabel
     [not found]   ` <20170428141330.16187-2-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-04-29 21:29     ` Peter Rosin
2017-04-29 21:29       ` Peter Rosin
     [not found]       ` <beb9f7c4-4959-1bb2-03e2-c5ccecbb8368-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2017-04-29 21:42         ` Peter Rosin
2017-04-29 21:42           ` Peter Rosin
     [not found]           ` <df5f38c4-b0e8-64c6-d6ba-c554133f4bbf-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2017-05-02 15:21             ` Philipp Zabel
2017-05-02 15:21               ` Philipp Zabel
     [not found]               ` <1493738491.2391.20.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-05-02 17:42                 ` Peter Rosin
2017-05-02 17:42                   ` Peter Rosin
     [not found]                   ` <74bfa70b-3407-9484-9717-bb2d07356f70-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2017-05-03  8:35                     ` Philipp Zabel
2017-05-03  8:35                       ` Philipp Zabel
2017-05-03 11:13                       ` Peter Rosin [this message]
2017-05-03 11:13                         ` Peter Rosin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1cda75b-4967-7d79-7f07-b4f392153d73@axentia.se \
    --to=peda@axentia.se \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=p.zabel@pengutronix.de \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sakari.ailus@iki.fi \
    --cc=slongerbeam@gmail.com \
    --cc=steve_longerbeam@mentor.com \
    --cc=vladimir_zapolskiy@mentor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.