Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7112958ybi; Thu, 13 Jun 2019 09:46:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzvLhXB+owtXxozC2pS3i5HNQODbp3Oo9DKJA1c4+VwXDrLiNtxkWhVXPzKATMzW/IMTFa X-Received: by 2002:a63:454a:: with SMTP id u10mr29679487pgk.291.1560444383382; Thu, 13 Jun 2019 09:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560444383; cv=none; d=google.com; s=arc-20160816; b=trvaH5LfmeGJhlH+ObH5Hed+thHzSW+9jCzyqO8OqoAZAUbhbJAHYASDdyhECBU6Uk os4wDu74XPmlI8cRKIFVFBupREJcX1E3FDsU0dba6TrVWmzas/eGxy2A1F4/F91GItzi Sva5WPBZACyBOy8WQW3xvKdgMj2OhaZB17ZA1V2typnOtbAxTriKete2+AaSClmdCFLM 24F5i5PwLkwoL3swgSB74WNn2rTRBfELyupGcMrwkJy+uGIgDeHAtnVMXKk4kWNF5EmU fgZUm4+RcPlkJHtBAjv9XJq4ZhMGt05ooFTlSNz+jhKzCt/gJYEyeaPa/Niqls/tSVIJ CVng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Mavl67rhLTRO6P1dOjIAeUo2MeOZwtyE1mbTLO/0ct8=; b=RfyZjIGmyaLRmuhM8RrDBy+CRdMJUNUD5XF63wcwpFubxDHJhoHE99iqxnYaRk+LIx dS9rc/aKwD9mUOgkm7RMwp/XJ9TFniylQh82yGyiq6NAp66iNRvOb8jFcL361dy6QLXB HGGTkDoLC/ZeUS9uQIXV++Nw0js8OLAQ8EuyciO27JRHQyVoXpq6b8ejIgZceqzjIcTU p+FISKOlV77ZLPG5WNhjxckqmQkRtA6kww21LdnT3B6JUaBFAw9j3vklcByoTKr0MRWw QVvjfi1OLLoz8v8bdVVksjlC1CjuSJcUrjn+hggIlvDwjx8+gYKdRIjUUUHF0SdmrvGf HmOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h5si122290pgd.419.2019.06.13.09.46.08; Thu, 13 Jun 2019 09:46:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392964AbfFMQp4 (ORCPT + 99 others); Thu, 13 Jun 2019 12:45:56 -0400 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:47215 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730319AbfFMFoV (ORCPT ); Thu, 13 Jun 2019 01:44:21 -0400 Received: from [192.168.2.10] ([46.9.252.75]) by smtp-cloud7.xs4all.net with ESMTPA id bIX1hL32N5qKabIX4hDxVJ; Thu, 13 Jun 2019 07:44:19 +0200 Subject: Re: [PATCH 0/2] Use Media Dev Allocator to fix vimc dev lifetime bugs To: helen.koike@collabora.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Hans Verkuil Message-ID: Date: Thu, 13 Jun 2019 07:44:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfDwxpIXPhJN75Jw4Kp1rhsRbTfMtOhFu8gNd1BX+22wfx+C4LbiSCZR9QW2IynSwuVRELuLWlzdy123Z9GqnH8K5Ut/QIsYFRlAz8e0zn4l6PAyDEFF/ 8e5YMZHzequKkwwJdLY6CDvGb6f67csd4nqD0iAmn5DG+zJOYvS2GJhtfMdwRNhsusrA9doOHJSgntKDjUYCKH3PYUxKW3v7DiivRZS2/2y5kkIK/M9krJ3w nAjQl97buif4pFG7oZdhdmwC0o4QazU2MJ2AM5aYGV0Ex+YrIZPXv2BRycaklV+EvDc/9SX4cMhE95rGSGmURw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/24/19 5:31 AM, Shuah Khan wrote: > media_device is embedded in struct vimc_device and when vimc is removed > vimc_device and the embedded media_device goes with it, while the active > stream and vimc_capture continue to access it. > > Fix the media_device lifetime problem by changing vimc to create shared > media_device using Media Device Allocator API and vimc_capture getting > a reference to vimc module. With this change, vimc module can be removed > only when the references are gone. vimc can be removed after vimc_capture > is removed. > > Media Device Allocator API supports just USB devices. Enhance it > adding a genetic device allocate interface to support other media > drivers. > > The new interface takes pointer to struct device instead and creates > media device. This interface allows a group of drivers that have a > common root device to share media device resource and ensure media > device doesn't get deleted as long as one of the drivers holds its > reference. > > The new interface has been tested with vimc component driver to fix > panics when vimc module is removed while streaming is in progress. Helen, can you review this series? I'm not sure this is the right approach for a driver like vimc, and even if it is, then it is odd that vimc-capture is the only vimc module that's handled here. My gut feeling is that this should be handled inside vimc directly and not using the media-dev-allocator. Regards, Hans > > Shuah Khan (2): > media: add generic device allocate interface to media-dev-allocator > vimc: fix BUG: unable to handle kernel NULL pointer dereference > > drivers/media/Makefile | 4 +- > drivers/media/media-dev-allocator.c | 39 ++++++++++++++ > drivers/media/platform/vimc/vimc-capture.c | 17 +++++- > drivers/media/platform/vimc/vimc-core.c | 60 ++++++++++++---------- > include/media/media-dev-allocator.h | 46 ++++++++++++++--- > 5 files changed, 130 insertions(+), 36 deletions(-) >