All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
Cc: linux@arm.linux.org.uk, mturquette@linaro.org,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	linux-arm-kernel@lists.infradead.org, jiada_wang@mentor.com,
	kyungmin.park@samsung.com, myungjoo.ham@samsung.com,
	t.figa@samsung.com, g.liakhovetski@gmx.de,
	linux-kernel@vger.kernel.org, linux-mips@linux-mips.org,
	linux-sh@vger.kernel.org
Subject: Re: [PATCH v6 0/5] clk: clock deregistration support
Date: Mon, 28 Oct 2013 21:44:25 +0100	[thread overview]
Message-ID: <13300609.Rh0Q97QhcX@avalon> (raw)
In-Reply-To: <52434CBC.2070408@gmail.com>

Hi Sylwester,

On Wednesday 25 September 2013 22:51:08 Sylwester Nawrocki wrote:
> On 09/25/2013 11:47 AM, Laurent Pinchart wrote:
> > Doesn't that introduce race conditions ? If the sub-drivers require the
> > clock, they want to be sure that the clock won't disappear beyond their
> > backs. I agree that the circular dependency needs to be solved somehow,
> > but we probably need a more generic solution. The problem will become
> > more widespread in the future with DT-based device instantiation in both
> > V4L2 and KMS.
> 
> It doesn't introduce any new race conditions AFAICT. I doubt all these
> issues can be resolved in one single step. Currently the modular clock
> providers are seriously broken, there is no reference tracking and the clock
> consumers can easily get into a state where they have invalid references to
> clocks supplied by already unregistered drivers.
> 
> With this patch series the clock consumer drivers will not crash thanks
> to the clock object reference counting. So the worst thing may happen is a
> clock left in an unexpected state.
> 
> However there should be no problems with the v4l2-async API, the host driver
> in its de-initialization routine unregisters its sub-drivers (they should
> stop using the clock when notified of such an event), only then the host
> would unregister the clock (subsequently the sub-drivers get re-attached and
> put into deferred probing state).

That in itself is a workaround I believe. Unbinding/rebinding devices from/to 
drivers isn't something the v4l core should do.

> There may be issues when a sub-driver's file handle is opened while the host
> is about to de-initialize. But I doubt resolution of such problems belongs
> to the common clock framework. I have been trying to improve the situation
> in small steps, rather than waiting forever for a perfect solution.
> 
> Do you perhaps have any ideas WRT to a "more generic solution" ? In general
> I have been trying to avoid using v4l2-clk and add what's missing in the
> common clock framework.
> 
> Perhaps we should leave only the kref part in the __clk_get(), __clk_put()
> hooks and be taking reference to a clock in clk_prepare() and releasing it
> in clk_unprepare() ? This way circular reference would exist only between
> clk_prepare(), clk_unprepare() calls.
> 
> Assuming a driver prepares clock in device's open() and unprepares in device
> close() handler perhaps it could all work better, without relying on the
> host to ensure the resource reference tracking. I'm not sure if that is not
> making too many assumptions for a generic API.

This is indeed an architecture decision that goes beyond the boundaries of the 
clock framework. The question boils down to how we want to acquire/release and 
refcount resources. Should drivers acquire and release hotpluggable resources 
at probe and remove time respectively, or only when they need them ? Or should 
they acquire them at probe them and be notified when they should release them 
? The first option adds an overhead but could help solving the circular 
dependency problem in a simpler way.

-- 
Regards,

Laurent Pinchart

WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v6 0/5] clk: clock deregistration support
Date: Mon, 28 Oct 2013 20:44:25 +0000	[thread overview]
Message-ID: <13300609.Rh0Q97QhcX@avalon> (raw)
In-Reply-To: <52434CBC.2070408@gmail.com>

Hi Sylwester,

On Wednesday 25 September 2013 22:51:08 Sylwester Nawrocki wrote:
> On 09/25/2013 11:47 AM, Laurent Pinchart wrote:
> > Doesn't that introduce race conditions ? If the sub-drivers require the
> > clock, they want to be sure that the clock won't disappear beyond their
> > backs. I agree that the circular dependency needs to be solved somehow,
> > but we probably need a more generic solution. The problem will become
> > more widespread in the future with DT-based device instantiation in both
> > V4L2 and KMS.
> 
> It doesn't introduce any new race conditions AFAICT. I doubt all these
> issues can be resolved in one single step. Currently the modular clock
> providers are seriously broken, there is no reference tracking and the clock
> consumers can easily get into a state where they have invalid references to
> clocks supplied by already unregistered drivers.
> 
> With this patch series the clock consumer drivers will not crash thanks
> to the clock object reference counting. So the worst thing may happen is a
> clock left in an unexpected state.
> 
> However there should be no problems with the v4l2-async API, the host driver
> in its de-initialization routine unregisters its sub-drivers (they should
> stop using the clock when notified of such an event), only then the host
> would unregister the clock (subsequently the sub-drivers get re-attached and
> put into deferred probing state).

That in itself is a workaround I believe. Unbinding/rebinding devices from/to 
drivers isn't something the v4l core should do.

> There may be issues when a sub-driver's file handle is opened while the host
> is about to de-initialize. But I doubt resolution of such problems belongs
> to the common clock framework. I have been trying to improve the situation
> in small steps, rather than waiting forever for a perfect solution.
> 
> Do you perhaps have any ideas WRT to a "more generic solution" ? In general
> I have been trying to avoid using v4l2-clk and add what's missing in the
> common clock framework.
> 
> Perhaps we should leave only the kref part in the __clk_get(), __clk_put()
> hooks and be taking reference to a clock in clk_prepare() and releasing it
> in clk_unprepare() ? This way circular reference would exist only between
> clk_prepare(), clk_unprepare() calls.
> 
> Assuming a driver prepares clock in device's open() and unprepares in device
> close() handler perhaps it could all work better, without relying on the
> host to ensure the resource reference tracking. I'm not sure if that is not
> making too many assumptions for a generic API.

This is indeed an architecture decision that goes beyond the boundaries of the 
clock framework. The question boils down to how we want to acquire/release and 
refcount resources. Should drivers acquire and release hotpluggable resources 
at probe and remove time respectively, or only when they need them ? Or should 
they acquire them at probe them and be notified when they should release them 
? The first option adds an overhead but could help solving the circular 
dependency problem in a simpler way.

-- 
Regards,

Laurent Pinchart


WARNING: multiple messages have this Message-ID (diff)
From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 0/5] clk: clock deregistration support
Date: Mon, 28 Oct 2013 21:44:25 +0100	[thread overview]
Message-ID: <13300609.Rh0Q97QhcX@avalon> (raw)
In-Reply-To: <52434CBC.2070408@gmail.com>

Hi Sylwester,

On Wednesday 25 September 2013 22:51:08 Sylwester Nawrocki wrote:
> On 09/25/2013 11:47 AM, Laurent Pinchart wrote:
> > Doesn't that introduce race conditions ? If the sub-drivers require the
> > clock, they want to be sure that the clock won't disappear beyond their
> > backs. I agree that the circular dependency needs to be solved somehow,
> > but we probably need a more generic solution. The problem will become
> > more widespread in the future with DT-based device instantiation in both
> > V4L2 and KMS.
> 
> It doesn't introduce any new race conditions AFAICT. I doubt all these
> issues can be resolved in one single step. Currently the modular clock
> providers are seriously broken, there is no reference tracking and the clock
> consumers can easily get into a state where they have invalid references to
> clocks supplied by already unregistered drivers.
> 
> With this patch series the clock consumer drivers will not crash thanks
> to the clock object reference counting. So the worst thing may happen is a
> clock left in an unexpected state.
> 
> However there should be no problems with the v4l2-async API, the host driver
> in its de-initialization routine unregisters its sub-drivers (they should
> stop using the clock when notified of such an event), only then the host
> would unregister the clock (subsequently the sub-drivers get re-attached and
> put into deferred probing state).

That in itself is a workaround I believe. Unbinding/rebinding devices from/to 
drivers isn't something the v4l core should do.

> There may be issues when a sub-driver's file handle is opened while the host
> is about to de-initialize. But I doubt resolution of such problems belongs
> to the common clock framework. I have been trying to improve the situation
> in small steps, rather than waiting forever for a perfect solution.
> 
> Do you perhaps have any ideas WRT to a "more generic solution" ? In general
> I have been trying to avoid using v4l2-clk and add what's missing in the
> common clock framework.
> 
> Perhaps we should leave only the kref part in the __clk_get(), __clk_put()
> hooks and be taking reference to a clock in clk_prepare() and releasing it
> in clk_unprepare() ? This way circular reference would exist only between
> clk_prepare(), clk_unprepare() calls.
> 
> Assuming a driver prepares clock in device's open() and unprepares in device
> close() handler perhaps it could all work better, without relying on the
> host to ensure the resource reference tracking. I'm not sure if that is not
> making too many assumptions for a generic API.

This is indeed an architecture decision that goes beyond the boundaries of the 
clock framework. The question boils down to how we want to acquire/release and 
refcount resources. Should drivers acquire and release hotpluggable resources 
at probe and remove time respectively, or only when they need them ? Or should 
they acquire them at probe them and be notified when they should release them 
? The first option adds an overhead but could help solving the circular 
dependency problem in a simpler way.

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2013-10-28 20:44 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 14:53 [PATCH v6 0/5] clk: clock deregistration support Sylwester Nawrocki
2013-08-30 14:53 ` Sylwester Nawrocki
2013-08-30 14:53 ` Sylwester Nawrocki
2013-08-30 14:53 ` [PATCH v6 1/5] clk: Provide not locked variant of of_clk_get_from_provider() Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53 ` [PATCH v6 2/5] clkdev: Fix race condition in clock lookup from device tree Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53 ` [PATCH v6 3/5] clk: Add common __clk_get(), __clk_put() implementations Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53 ` [PATCH v6 4/5] clk: Assign module owner of a clock being registered Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53 ` [PATCH v6 5/5] clk: Implement clk_unregister Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-08-30 14:53   ` Sylwester Nawrocki
2013-09-04 15:43   ` Sylwester Nawrocki
2013-09-04 15:43     ` Sylwester Nawrocki
2013-09-04 15:43     ` Sylwester Nawrocki
2013-09-24 21:38 ` [PATCH v6 0/5] clk: clock deregistration support Sylwester Nawrocki
2013-09-24 21:38   ` Sylwester Nawrocki
2013-09-24 21:38   ` Sylwester Nawrocki
2013-09-25  9:47   ` Laurent Pinchart
2013-09-25  9:47     ` Laurent Pinchart
2013-09-25  9:47     ` Laurent Pinchart
2013-09-25 20:51     ` Sylwester Nawrocki
2013-09-25 20:51       ` Sylwester Nawrocki
2013-09-25 20:51       ` Sylwester Nawrocki
2013-10-28 20:44       ` Laurent Pinchart [this message]
2013-10-28 20:44         ` Laurent Pinchart
2013-10-28 20:44         ` Laurent Pinchart
2013-10-15 20:04     ` Sylwester Nawrocki
2013-10-15 20:04       ` Sylwester Nawrocki
2013-10-15 20:04       ` Sylwester Nawrocki
2013-10-28 19:54       ` Mike Turquette
2013-10-28 19:54         ` Mike Turquette
2013-10-28 19:54         ` Mike Turquette
2013-10-28 21:06         ` Laurent Pinchart
2013-10-28 21:06           ` Laurent Pinchart
2013-10-28 21:06           ` Laurent Pinchart
2013-10-28 20:26       ` Laurent Pinchart
2013-10-28 20:26         ` Laurent Pinchart
2013-10-28 20:26         ` Laurent Pinchart
2013-10-02 21:40   ` Mike Turquette
2013-10-02 21:40     ` Mike Turquette
2013-10-02 21:40     ` Mike Turquette
2013-10-28 21:05   ` Laurent Pinchart
2013-10-28 21:05     ` Laurent Pinchart
2013-10-28 21:05     ` Laurent Pinchart
2013-10-29 23:38     ` Sylwester Nawrocki
2013-10-29 23:38       ` Sylwester Nawrocki
2013-10-29 23:38       ` Sylwester Nawrocki

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=13300609.Rh0Q97QhcX@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=jiada_wang@mentor.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mturquette@linaro.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sylvester.nawrocki@gmail.com \
    --cc=t.figa@samsung.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.