Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp40838ioo; Wed, 25 May 2022 20:00:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCmVpR+y6t3Uf0CQQwQGqydIez2zuAgvb989QetR3gXQQ7lsj74PFV8JyqULWvTEwCQG86 X-Received: by 2002:aa7:cfd8:0:b0:42a:c287:362a with SMTP id r24-20020aa7cfd8000000b0042ac287362amr36912829edy.357.1653534031004; Wed, 25 May 2022 20:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653534030; cv=none; d=google.com; s=arc-20160816; b=JzvS1+K65YZ2VHMCv8EMigGXYlaD0/hCBgbVZgJWIPkFh/R+vY/0G2cjJnwrZ0aEjy XnP1s3PCfGOVi722kAe9PRb4OipWlBc0FSMj/CvlYIs8MNACLGzI7zBtZ6tyZHk1+3RL RYMswjGXMOaXMoCabtJvVrWZQ9mgjRXJWjDrayjcmoy8Ag4QZiivymv4NrYuefJq/n37 mWC7VUDxmm9RCXmoAbPi/9L9JifShNI/MspgR6ePPiwqCQdRqKaqewpie1YCbvm8mkC0 H7PKre9HXtnKG4mSKIOimL+4W8aJhpb8Gi0uMwh39K8YibZsdg+eGQ9T5bDqI4+DrHb5 C5wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=En3Np2u2djTMEVwwxBwoJJkxFH8AqiHFqQ265Nknr8o=; b=Q9vEv6y/WZH5M592yRC3Rnwa/dqLzm5uxHaiPY01BixG307y+rmJeDEmCRUKqBp9X6 H2eMGeAXoTG/5mC7/jUCjQ4E3fAdAHHunjDk2GU3jj8YffIogNM9RS1FFojOamaZ6tIQ nBEpaX7w3TOa/QfS9ja208ANs6exXb73sg8znWVdpwVjo91uKNxWlqeuANsYzgmJl5YC 6zgKhqqESpdVDu98P8vs27pzJm++enGY46HAyxgrTuhvAlLxV4bIJBgCNbGuNn2FBWDr 6eCyMvafGQmnnrxXVyMplCHI6WbYUnpI3xOrvXswyHnNrpyw7P6wjLpsZFiJ0Kn8MiQ2 IJ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=EOeeYFyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q26-20020aa7da9a000000b0042bcc8ac275si259764eds.595.2022.05.25.20.00.05; Wed, 25 May 2022 20:00:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=EOeeYFyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242353AbiEYRxu (ORCPT + 99 others); Wed, 25 May 2022 13:53:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343596AbiEYRxt (ORCPT ); Wed, 25 May 2022 13:53:49 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9922DFB4; Wed, 25 May 2022 10:53:32 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id F0B8E5FD08; Wed, 25 May 2022 20:53:28 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1653501209; bh=En3Np2u2djTMEVwwxBwoJJkxFH8AqiHFqQ265Nknr8o=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=EOeeYFyNtIC1PrWeiDG9ODbItxIuP0Rc4ssRlCd8eIecElXctQ7jHLBbqkSEgThD3 +xWvClg/WXHssF2/hWx1/ECjrAEdixt9xrpXjpxb3gwiw13jj+a3bimC08KKpbmrNs ACgELy2KcYz/VHuArMMa/pTIOEQ+2R38fnPYpBdltRJu23Dsht1zl3froF5O/SyAgH NvabuYIeibhaFCub4VRlTDS1cQizZU/XjX2NIxOCVo4Ap/xR1r/XG16g6ZHfPXj8rt e/hMhVNHIOcQ4x9JQezltS8kH5IqQmw4Zx1eu7eRNbFWrBycqrmjnjZp3vgkwME9Tt Mo4bgBNmWyTVQ== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mail.sberdevices.ru (Postfix) with ESMTP; Wed, 25 May 2022 20:53:26 +0300 (MSK) From: Dmitry Rokosov To: Jonathan Cameron CC: Jonathan Cameron , "robh+dt@kernel.org" , "stano.jakubek@gmail.com" , "shawnguo@kernel.org" , "lars@metafoo.de" , "andy.shevchenko@gmail.com" , "stephan@gerhold.net" , "linux-iio@vger.kernel.org" , "devicetree@vger.kernel.org" , kernel , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v1 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver Thread-Topic: [PATCH v1 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver Thread-Index: AQHYVASOybrxT0DjfUWoYWuGUlWOX6z4bouAgAnb/gCAIkALgIAGKs0AgAUw8QA= Date: Wed, 25 May 2022 17:53:11 +0000 Message-ID: <20220525175322.36umsxjwioyfcsac@CAB-WSD-L081021.sigma.sbrf.ru> References: <20220419154555.24191-1-ddrokosov@sberdevices.ru> <20220419154555.24191-3-ddrokosov@sberdevices.ru> <20220420115023.00006a25@Huawei.com> <20220426172406.s4h6g7nrpytaq263@CAB-WSD-L081021.sigma.sbrf.ru> <20220518122515.aby5lbb4xusr6pdt@CAB-WSD-L081021.sigma.sbrf.ru> <20220522113654.0e3c0023@jic23-huawei> In-Reply-To: <20220522113654.0e3c0023@jic23-huawei> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-Type: text/plain; charset="us-ascii" Content-ID: <0CF6C5E8D08B4941B4A2F1C04D4EB0B2@sberdevices.ru> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/05/25 08:39:00 #19569940 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 22, 2022 at 11:36:54AM +0100, Jonathan Cameron wrote: > > Syscall delete_module() tries to stop module first and after calls > > driver exit() function (which executes devm_* handlers inside, includin= g IIO > > trigger unregister). It means we have the chicken or the egg dilemma he= re. > > Module can't be unloaded until module refcnt is not zero and we can't > > execute IIO trigger unregister (decrease module refcnt) only when modul= e > > refcnt is zero. > > I suppose the possible solution to such a problem is a different semant= ic > > for internal triggers (inside driver itself) and external drivers (like > > hwtimer trigger). What do you think? >=20 > Potentially though it's going to be tricky as a driver doesn't generally > have any way to know they are internal and we need to be careful not to > underflow the reference counts. We could hid a flag somewhere and > add an iio_trigger_get_same_owner() or something that sets that flag allo= wing > us to decide not to drop the reference count it if is automatically unass= ociated. > In the path where you get: > 1) iio_trigger_get_same_owner() on probe > 2) sysfs write changes to another trigger. > 3) sysfs write back to original trigger > it is reasonable to assume the need to clear the trigger > before driver removal is possible, whereas clearing the trigger associati= on > if only step 1 happened is no intuitive. I will try to prepare the rfc patch if you don't mind. I propose to continue further discussion there. >=20 > >=20 > > The second one issue is located in the different IIO drivers. Some modu= les > > call iio_trigger_get() before iio_trigger_register(), trig->owner is no= t > > initialized to the right value (THIS_MODULE) and we don't acquire refcn= t > > for proper driver object. >=20 > Ah. Good point. I guess we missed that when we were moving over to > automated setting of the module. >=20 Already submitted v2 patchset here: https://lore.kernel.org/linux-iio/20220524181150.9240-1-ddrokosov@sberdevic= es.ru/ --=20 Thank you, Dmitry=