Received: by 10.192.165.148 with SMTP id m20csp452409imm; Wed, 25 Apr 2018 02:12:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+JMz3CLM3rPCnyf2yhcVFG4NHGgO3WXpGqxckMg4TFBD1H+DIPxIu0aIn+CqXdK4k74OTa X-Received: by 10.99.49.205 with SMTP id x196mr20991009pgx.397.1524647535935; Wed, 25 Apr 2018 02:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524647535; cv=none; d=google.com; s=arc-20160816; b=lkIAeLMnhsxWlpJh/hcCFILcyRynfz5Yawb+hqYoWSph/nZY3MgCx+WlJ/vFY7HIch NCb05g+IJ+NNIV3SECpEwwYR9+xIXV3zWqI0rRLOyMbK1APATmGEYihSvVTwNImbm6Cj 8YOSnpcCPt1QmRFT0KGelMb/t7aIllU1K/ZR+/rt3FqLbz2VlMqU7pr35rRtxItT+Kh+ 8LZ2OwfOH6PNSCi4gNc/9+i53cUn7jrHIQnj2NJbEhP+c0ffhRamIG0oNwJ8Zuv0LcmO RFmr9UteBKu7U7YlZtQLr7oMLSmX1+7AtTZaLhFQ6+myFDCfN/PiqNxqZaLjmzeE2adn DI8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=7wL3VNjlw21l5++LSb1MSO5n0iKrPnlzrwCtFnfrwew=; b=ixZeZbRWuF19nHiXwSrDGQAcsvWNaLPVzfd7WsNIOpLHjYr7ubELQYC+PbQ9f2qkwF s8PlHhq0xf97xFsephiVkwzeqB4bc+pB70vnBVD1x7m2qxZTYzrcpRCqHpSERfAJyWqw 7gtAZHNFcJQgeuc06zahTilF9Rhu5ZHRNd1hMHXFlJBMGscq3GoXmtwvfiDg0ozk+yge Z1CF/BuPhosCNcjne2oWjDm8AS1O7idHwKniA3XhPw6LUZXlFn3mbE+O1NzvbZnEcq7n 5PfbiMuLO0FagXHT7sDFd5A7c5sD/3heVkpnmM9zcR+OAqCQqNe4tFlhsu5YXWW4vQNY 7NPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axentia.se header.s=selector1 header.b=vb9u9B+m; 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 132si12876858pgb.470.2018.04.25.02.12.01; Wed, 25 Apr 2018 02:12:15 -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; dkim=pass header.i=@axentia.se header.s=selector1 header.b=vb9u9B+m; 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 S1751710AbeDYJJk (ORCPT + 99 others); Wed, 25 Apr 2018 05:09:40 -0400 Received: from mail-he1eur01on0125.outbound.protection.outlook.com ([104.47.0.125]:42336 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751621AbeDYJJe (ORCPT ); Wed, 25 Apr 2018 05:09:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7wL3VNjlw21l5++LSb1MSO5n0iKrPnlzrwCtFnfrwew=; b=vb9u9B+maJgZZE8VnV9G2SQixszFtNJJvdPJ/43V40dW+6b9RFaY3HU+V5WUmyGTuJRKmeXaq8eyM4acmIUFqAnUx3H4VxA6EvdUybRbr1ZCsLKdLpfMAnpy68t8GzI3rYNdbAYNnMliykNhx0ipPhWwzo4jS3D1FJwm4/jPfTo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from [192.168.13.3] (85.226.244.23) by HE1PR0202MB2778.eurprd02.prod.outlook.com (2603:10a6:3:e8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.14; Wed, 25 Apr 2018 09:09:28 +0000 Subject: Re: [PATCH v4 7/8] drm/i2c: tda998x: register as a drm bridge To: Russell King - ARM Linux , Jyri Sarha Cc: linux-kernel@vger.kernel.org, David Airlie , Rob Herring , Mark Rutland , Nicolas Ferre , Alexandre Belloni , Boris Brezillon , Tomi Valkeinen , Laurent Pinchart , Jacopo Mondi , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20180423072301.11962-1-peda@axentia.se> <20180423072301.11962-8-peda@axentia.se> <20180423160833.GF16141@n2100.armlinux.org.uk> <5d6866d0-75bc-4de8-9b87-4fee5430e9dd@axentia.se> <20180424080833.GJ16141@n2100.armlinux.org.uk> <8448e90a-4562-b564-c160-1b5c67e0f92f@axentia.se> <0cbee3bd-8987-5f2f-519d-f8d1b426f2a3@ti.com> <20180424170625.GL16141@n2100.armlinux.org.uk> From: Peter Rosin Organization: Axentia Technologies AB Message-ID: Date: Wed, 25 Apr 2018 11:09:25 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180424170625.GL16141@n2100.armlinux.org.uk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: HE1P192CA0014.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::24) To HE1PR0202MB2778.eurprd02.prod.outlook.com (2603:10a6:3:e8::20) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(7021125)(5600026)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020);SRVR:HE1PR0202MB2778; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0202MB2778;3:dS25E0nozKmAMSKB/UEl70v8V5kAISz/eze3He6DAdccyKXihZh2thBtRySgs5Et9xo8Ddub8aNHXpu9J2GUHFnWAjrCAWiIrGsu7qE0InktgHew5izkr+6gghE8gG/stOuklxQL0MYZskwgWMGcsIGTOz9Quj0rCOOSixj0Mac4IHg3Oeu4AymPZngfFrhS6Z2VEevdhKS/csUQXSe5AgkdDiaAtYAvixxjze0X+Y7SiHBFLW6IsV4hlaRKnaAv;25:PslC2MEXy29DNRF5UdGSm31+uKiqr/F7Xb07tghO59nFZAob+EJ6TmvyflC/QkV+ZcaOPyWSZQ4uJTrGLzA/dPaKCNkeYL7ZcgRvLTrwsnDVp/u5nqBCZP2N+9ltZBlrSx06/Dm0d6ylemsk2D1ylY3MjM5633jZ31Ftlt93ot1ob8rlOQZMWXDBnRjhYvJh8yhuHa1XS2IN/Gr4557xX7XByX07H7G9hitm0lkvvWHJggf2JuYIb2o5GjMyNa/4sqZfzz7yE5LVCH6xPTMHKcGxwFqzb5XFKHiZC+tUVNrx87lfI8bKEoG0pGnj20JtSbJ4iuT1x0JUBCWNl/EPlA==;31:OD80PlVsZvAcefpOug2BPKZEKcZUSQLIapIq+ViAFxSCDdEzyscJ1EhHChtVvtof6yVGD1H02lZ+7d8KQwBVaJrAi2AjW5ODAiY7kLcz2PnrcSJDGCGVbhBGckjvMjge9Lq2EHSP5WN+2CCUOba7mOXjf821hU689UHRv1cqJ9LYHyx3avGnk9ggZj6wi2hVLmJtrcdBMSv0pm9tmO5LNuc+7ouAcsPHSjRdj9g6CF0= X-MS-TrafficTypeDiagnostic: HE1PR0202MB2778: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3231232)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6041310)(20161123564045)(20161123562045)(20161123560045)(2016111802025)(20161123558120)(6043046)(6072148)(201708071742011);SRVR:HE1PR0202MB2778;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0202MB2778; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0202MB2778;4:EmwzBrTQ2o3cRDvz0dvLjinBYOwnlKPq8/2381nsbTMMch+LbGvUPJ3M5fii7ya7uDQIFDS/Xd1grlvfTjHe9NpaQgtwY9J0T3KeYcO5AKYWvUEma4582zF+vMB2bvwYLc/CrQuQ3ai6WKwz6SYLTK/1GwcTBP4aicZIHXoi96aDHvYiumSeo5xtruL8xPubZdZ4RvKouSNTL6SKZALuUDc4G/1WCp/vpqLzAwpdYtsmtCn3nTxIzUisBmgxwII1Fq0NfNutNZGS/nuQdvtcuQ== X-Forefront-PRVS: 06530126A4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(396003)(366004)(376002)(39380400002)(346002)(39830400003)(377424004)(199004)(189003)(65956001)(66066001)(8676002)(65806001)(54906003)(186003)(81156014)(81166006)(16526019)(58126008)(16576012)(110136005)(230700001)(47776003)(316002)(6116002)(3846002)(5890100001)(2486003)(86362001)(8936002)(53546011)(52116002)(93886005)(386003)(59450400001)(36916002)(117156002)(52146003)(23676004)(476003)(2616005)(478600001)(486006)(4326008)(956004)(68736007)(25786009)(31696002)(3260700006)(7736002)(446003)(76176011)(11346002)(6486002)(5660300001)(6246003)(65826007)(6666003)(305945005)(106356001)(64126003)(105586002)(74482002)(77096007)(36756003)(2906002)(7416002)(97736004)(26005)(50466002)(31686004)(229853002)(53936002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0202MB2778;H:[192.168.13.3];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjAyMDJNQjI3Nzg7MjM6NGhBOE9LcHROaHlCcDlqNVhWZ2dBSkxO?= =?utf-8?B?L1Nka0oyblhSdEJ6Z3BmMEpUN1M4NThFdE44bmt0ZGVoRXJJTkhqWTc2VDJG?= =?utf-8?B?dEExUms0cHEwTW9laitwVVlYdlBFZnJqSnFSbVNLbjRXOVcwWk5PdHl4cEt4?= =?utf-8?B?MitHMmhoS2NPN0tTUVlFZlF5UVhnb2d4ZllrSHVUc1JjMFJhRWhLclROYytj?= =?utf-8?B?aG9rMVY0ck9BdW5xbVhqVTgycUNWQlgrOUdadlBUVWMrU3IxbWdWVlk2SkhR?= =?utf-8?B?bGNzRVkvQ3E3YkJEekQ3NUVMbUhLNllPY3NEekRZbGIwRmxUaHFUTmZZcW9v?= =?utf-8?B?OUQ3Q090K01QS1pBdm9OZ3d3QmJZZmJRK211UG1zNnZhaWR6NE51Z2JNRUt1?= =?utf-8?B?VXE0RTE1eHFJTGlxT243bDZSU1JsU0NZUFlsLzdiZ0ZqV3FsVll1b0h4Y1V4?= =?utf-8?B?MHIxSXBScCt1ektTNXBYeklJRkx4ZG5UM0pmb2ZCK25oVjZXRkxHQmVWUjBk?= =?utf-8?B?cmo0eWRpbUJDUWJ6bkU3U3ZXeGs1WmVQYmJQKzR0QkRKYWx1KzBwSEVlQTdq?= =?utf-8?B?T0oydWtNWXRVWUJRSVBRaDU3NE41V3ZxTCtzWmp4MW9PNEZFaStxWXdtYVdO?= =?utf-8?B?L3Q3RnB3L3B3TUc1VnZrOTFMc0kvSUUrZTVFNlgxZURxVnlEYlVBMkZGYzhw?= =?utf-8?B?akwwQmM1UE9SdW9UZVBVcmNrSnIwSlVnZ3VjTmV0WE9wTzdVVzhXUThFSU91?= =?utf-8?B?ZFJyQkJLV2VCeE5De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UhwW9XPB0LbfuB0Il1rw/c/qnZgMM9ROcl+wEmVBokOXd5uJFcP3GHpOBUxq+RpHk1EM5RPLMSDGJ4SrtVrqAzQ52/QhUxyaFsTdrApD3W0jvDeFTAE6J6M1CXlg3ESCPlhZjSCN6xjKMsM0u7/aMoaUZ/k/pSqn/DNVF36vS8mqfOEb5ojyDBAPRna4Q/BGbQrJACytOQ7iNncUUWKmOBkaqUtF44Es22uABM8HLMcW7TvkyNzebLxSYjF1FRCNCWu9RF5W5mxyX50G2Llx/UeSqUJwXFDixoIkkQcRRPvxIPv1QvzSNWpMkhEWH7s1/WYULayttrrVCsKQ==;5:f8H+l/gMKDIWasYijf3eo75iUTQ8udhb3wRfcErzHUx6H/cn+Ao3PZZtTEullPNd/4aOyu1MAqhBifwI3uUh/JtuS1hj1OC81pV3YJBQRX+ajMBrtgaioAud4wsAc6J0Q8svDPaWquu27P93qfksnUcJSYa9CTxZUNKniNCphrw=;24:J5cq+QtsQ2KsNV6U5UDVVUt3P61k32nF0gEZ8oZXIA4GpPAaUWtWWo3LrFX3kMCqjbXiRFDjRxiiqqOX5nf+YY5rBZBAnCUWiA+/kb8OJTs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0202MB2778;7:Teno7W2unP4hq8qt+oyv8nak+GzusY7rWJ2049GeCbeb/xF8R51+yMjuflQjjmXN1F5V+XTk3Hp8SX/kXyMHosyEz57ewf+vlCtzCQe735p3rzZIsOay2ETUijiz/sxxJRMHiReWATDprdMOvZCwZnMp5/HLUr0KccptZMD5epCMGoa9DiY1tLzsmBFyj5X7JyFFTO2uXN5JQt5PBLEyWx8j4HxqS1yxL5kN+HXWSVl7S7w0Q6BVolx/D8m6PVWx X-MS-Office365-Filtering-Correlation-Id: edb77828-f696-4b32-2f09-08d5aa8c4029 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2018 09:09:28.7314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: edb77828-f696-4b32-2f09-08d5aa8c4029 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0202MB2778 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-04-24 19:06, Russell King - ARM Linux wrote: > On Tue, Apr 24, 2018 at 07:04:16PM +0300, Jyri Sarha wrote: >> On 24/04/18 13:14, Peter Rosin wrote: >>> On 2018-04-24 10:08, Russell King - ARM Linux wrote: >>>> On Tue, Apr 24, 2018 at 08:58:42AM +0200, Peter Rosin wrote: >>>>> On 2018-04-23 18:08, Russell King - ARM Linux wrote: >>>>>> On Mon, Apr 23, 2018 at 09:23:00AM +0200, Peter Rosin wrote: >>>>>>> static int tda998x_remove(struct i2c_client *client) >>>>>>> { >>>>>>> - component_del(&client->dev, &tda998x_ops); >>>>>>> + struct device *dev = &client->dev; >>>>>>> + struct tda998x_bridge *bridge = dev_get_drvdata(dev); >>>>>>> + >>>>>>> + drm_bridge_remove(&bridge->bridge); >>>>>>> + component_del(dev, &tda998x_ops); >>>>>>> + >>>>>> >>>>>> I'd like to ask a rather fundamental question about DRM bridge support, >>>>>> because I suspect that there's a major fsckup here. >>>>>> >>>>>> The above is the function that deals with the TDA998x device being >>>>>> unbound from the driver. With the component API, this results in the >>>>>> DRM device correctly being torn down, because one of the hardware >>>>>> devices has gone. >>>>>> >>>>>> With DRM bridge, the bridge is merely removed from the list of >>>>>> bridges: >>>>>> >>>>>> void drm_bridge_remove(struct drm_bridge *bridge) >>>>>> { >>>>>> mutex_lock(&bridge_lock); >>>>>> list_del_init(&bridge->list); >>>>>> mutex_unlock(&bridge_lock); >>>>>> } >>>>>> EXPORT_SYMBOL(drm_bridge_remove); >>>>>> >>>>>> and the memory backing the "struct tda998x_bridge" (which contains >>>>>> the struct drm_bridge) will be freed by the devm subsystem. >>>>>> >>>>>> However, there is no notification into the rest of the DRM subsystem >>>>>> that the device has gone away. Worse, the memory that is still in >>>>>> use by DRM has now been freed, so further use of the DRM device >>>>>> results in a use-after-free bug. >>>>>> >>>>>> This is really not good, and to me looks like a fundamental problem >>>>>> with the DRM bridge code. I see nothing in the DRM bridge code that >>>>>> deals with the lifetime of a "DRM bridge" or indeed the lifetime of >>>>>> the actual device itself. >>>>>> >>>>>> So, from what I can see, there seems to be a fundamental lifetime >>>>>> issue with the design of the DRM bridge code. This needs to be >>>>>> fixed. >>>>> >>>>> Oh crap. A gigantic can of worms... >>>> >>>> Yes, it's especially annoying for me, having put the effort in to >>>> the component helper to cover all these cases. >>>> >>>>> Would a patch (completely untested btw) along this line of thinking make >>>>> any difference whatsoever? >>>> >>>> It looks interesting - from what I can see of the device links code, >>>> it would have the effect of unbinding the DRM device just before >>>> TDA998x is unbound, so that's an improvement. >>>> >>>> However, from what I can see, the link vanishes at that point (as >>>> DL_FLAG_AUTOREMOVE is set), and re-binding the TDA998x device results >>>> in nothing further happening - the link will be recreated, but there >>>> appears to be nothing that triggers the "consumer" to rebind at that >>>> point. Maybe I've missed something? >>> >>> Right, auto-remove is a no-go. So, improving on the previous... >>> >>> (I think drm_panel might suffer from this issue too?) >> >> Yes it does and I took a shot at trying to fix it at the end of the >> previous merge window, but gave up as I run out of time. I re-spun the >> work now after reading this thread. I add you and Russell to cc. > > Right, and these exact problems are what the component helper is > there to sort out, in a subsystem independent way. > > What is the problem with the component helper that people seem to > be soo loathed to use it, instead preferring to come up with sub- > standard and broken alternatives? I think the answer to that is rather obvious. If you design with these components from the get-go, I see no problem with them, but it simply seems way easier to retrofit device-links. Just take a look at my untested patch and patch v3 2/2 from Jyri [1] for panels (that presumably fix the big issue, namely leaving wild pointers). They either don't touch neither suppliers nor consumers or are totally trivial (assigning a new .owner field in suppliers). Compare that with adding a couple of dozen boilerplate lines with hook functions etc to each and every drm_device, drm_panel and drm_bridge. Couple that with the fact that apparently the problem of unbinding and leaving wild pointers hasn't been all that prevalent, implying that the problem of rebinding can't be all that critical either. But what do I know? Cheers, Peter [1] I can't seem to find it in archives, so I'm including it here for reference. It's small enough. diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 29d2c74..7474045 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -101,6 +102,13 @@ int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector) if (panel->connector) return -EBUSY; + panel->link = device_link_add(connector->dev->dev, panel->dev, 0); + if (!panel->link) { + dev_err(panel->dev, "failed to link panel to %s\n", + dev_name(connector->dev->dev)); + return -EINVAL; + } + panel->connector = connector; panel->drm = connector->dev; @@ -123,6 +131,8 @@ EXPORT_SYMBOL(drm_panel_attach); */ int drm_panel_detach(struct drm_panel *panel) { + device_link_del(panel->link); + panel->connector = NULL; panel->drm = NULL; diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 14ac240..26a1b5f 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -89,6 +89,7 @@ struct drm_panel { struct drm_device *drm; struct drm_connector *connector; struct device *dev; + struct device_link *link; const struct drm_panel_funcs *funcs;