From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751915AbbIOLCi (ORCPT ); Tue, 15 Sep 2015 07:02:38 -0400 Received: from mga02.intel.com ([134.134.136.20]:33042 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750750AbbIOLCg (ORCPT ); Tue, 15 Sep 2015 07:02:36 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,535,1437462000"; d="scan'208";a="804746946" Subject: Re: [PATCH v4 2/2] [media] media-device: split media initialization and registration To: Javier Martinez Canillas , linux-kernel@vger.kernel.org Cc: Luis de Bethencourt , linux-sh@vger.kernel.org, Sylwester Nawrocki , =?UTF-8?Q?S=c3=b6ren_Brinkmann?= , linux-samsung-soc@vger.kernel.org, Hyun Kwon , Matthias Schwarzott , Kyungmin Park , Tommi Rantala , Laurent Pinchart , Hans Verkuil , linux-media@vger.kernel.org, Kukjin Kim , Krzysztof Kozlowski , Mauro Carvalho Chehab , Michal Simek , Olli Salonen , linux-arm-kernel@lists.infradead.org, Stefan Richter , Antti Palosaari , Shuah Khan , =?UTF-8?Q?Rafael_Louren=c3=a7o_de_Lima_Chehab?= References: <1442313147-24566-1-git-send-email-javier@osg.samsung.com> <1442313147-24566-3-git-send-email-javier@osg.samsung.com> From: Sakari Ailus X-Enigmail-Draft-Status: N1110 Message-ID: <55F7FAA2.2090605@linux.intel.com> Date: Tue, 15 Sep 2015 14:01:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:38.0) Gecko/20100101 SeaMonkey/2.35 MIME-Version: 1.0 In-Reply-To: <1442313147-24566-3-git-send-email-javier@osg.samsung.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Javier, Javier Martinez Canillas wrote: > The media device node is registered and so made visible to user-space > before entities are registered and links created which means that the > media graph obtained by user-space could be only partially enumerated > if that happens too early before all the graph has been created. > > To avoid this race condition, split the media init and registration > in separate functions and only register the media device node when > all the pending subdevices have been registered, either explicitly > by the driver or asynchronously using v4l2_async_register_subdev(). > > The media_device_register() had a check for drivers not filling dev > and model fields but all drivers in mainline set them and not doing > it will be a driver bug so change the function return to void and > add a BUG_ON() for dev being NULL instead. > > Also, add a media_device_cleanup() function that will destroy the > graph_mutex that is initialized in media_device_init(). > > Suggested-by: Sakari Ailus > Signed-off-by: Javier Martinez Canillas Thanks! For drivers/media/media-device.c, drivers/media/platform/omap3isp/isp.c and include/media/media-device.h: Acked-by: Sakari Ailus Laurent, could you ack these if you're fine with them? They depend on Mauro's patches so they should be applied after them. -- Kind regards, Sakari Ailus sakari.ailus@linux.intel.com