From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 456D4C41513 for ; Mon, 31 Jul 2023 06:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230040AbjGaG6V (ORCPT ); Mon, 31 Jul 2023 02:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjGaG6U (ORCPT ); Mon, 31 Jul 2023 02:58:20 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F133E139 for ; Sun, 30 Jul 2023 23:58:17 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-99c10ba30afso170725966b.1 for ; Sun, 30 Jul 2023 23:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690786696; x=1691391496; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZvJi1B6SKlzQ1LvbzrEi0ZzvZYawpeN9hQcKBS5Rfqc=; b=BKmNyRCpejCIerfUkMERrQdZqiNhA9Yh/vco9caloYmkQVgWhVgN9OvZr3OI2CIOi/ jdsdUUO6Ma3cwFwhgf/RrPC9VZoDPrUI0IkuJdA+CSu3EthpExJ827siOaI3RNwmRV9h G3GPVmW4kjh3cc64CUzOwMBpDJmXCL1ItJLmO3Tc4ZlDauXS1w6UjyViBuizZHexVdCD emK4rwsoXP4ofEFWSIJ0WIYhHEUwX5ZEjmWQmZKlNBoBtpjmoH1tCcXlQ8d5XGa6mSAu JI/5gJvY1zwJUUYFeAuNwu7JnvZhROKPeMYT1pYftoTFLhRYG4PBZLNPy3buVzGHppgK 9TiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690786696; x=1691391496; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZvJi1B6SKlzQ1LvbzrEi0ZzvZYawpeN9hQcKBS5Rfqc=; b=e5IhNzVlqijj4E1m6JZ7gKV1/CKWs0w48Lnj/ZMWdql/bwtO3zl/zlBbj7MPEXvCaZ DofDWPF6XZNB8bKKGe6HtZfLbWBI0okr54EeodiFvLOEgC08aMXH2ucaClcLru7tJ/tE XuXutRrd8ZiFCsrMPsqd+BhrStBZT2sNRIXeO8Zily4Wl2rVnnR/cxW7OCqTlDk3XkK2 jBVZGdpu2K/XHJ66SODsk58HbufYjPh9fssmj7vQnqFceQMOMMs+ZpRvmD6SOUcHYZHD Se4+nqaneHlHKRktXp2/FPX7yqqbiBqv9+i7Z82LLlr25FVaybtdVUlOQEb0KKdmIGn/ PClg== X-Gm-Message-State: ABy/qLaBIX2ZpH4GVEzfQT2NKaiXNz1Kkdu0/lwhr3aUWRttIZxXCOj4 rnZJywwO3lAnuUDFu2OkfSc3NQ== X-Google-Smtp-Source: APBJJlHUe4q+Zfab2y/AmCUTWA3QzkU6SAznjHOA0UwORooy924a4e1ZAL+djMWbKsbjIH0JJIih0A== X-Received: by 2002:a17:907:a063:b0:994:13c3:2f89 with SMTP id ia3-20020a170907a06300b0099413c32f89mr6423776ejc.27.1690786696488; Sun, 30 Jul 2023 23:58:16 -0700 (PDT) Received: from [192.168.1.20] ([178.197.222.183]) by smtp.gmail.com with ESMTPSA id y6-20020a1709064b0600b009932337747esm5711311eju.86.2023.07.30.23.58.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Jul 2023 23:58:16 -0700 (PDT) Message-ID: Date: Mon, 31 Jul 2023 08:58:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.1 Subject: Re: [PATCH v3 2/2] i2c: Add GPIO-based hotplug gate Content-Language: en-US To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Svyatoslav Ryhel Cc: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Wolfram Sang , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230729160857.6332-1-clamor95@gmail.com> <20230729160857.6332-3-clamor95@gmail.com> <25858c22-ef92-2136-67ef-0d27364c1600@linaro.org> From: Krzysztof Kozlowski In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On 30/07/2023 23:55, Michał Mirosław wrote: > On Sun, Jul 30, 2023 at 10:30:56PM +0200, Krzysztof Kozlowski wrote: >> On 29/07/2023 18:08, Svyatoslav Ryhel wrote: >>> From: Michał Mirosław >>> >>> Implement driver for hot-plugged I2C busses, where some devices on >>> a bus are hot-pluggable and their presence is indicated by GPIO line. > [...] >>> + priv->irq = platform_get_irq(pdev, 0); >>> + if (priv->irq < 0) >>> + return dev_err_probe(&pdev->dev, priv->irq, >>> + "failed to get IRQ %d\n", priv->irq); >>> + >>> + ret = devm_request_threaded_irq(&pdev->dev, priv->irq, NULL, >>> + i2c_hotplug_interrupt, >>> + IRQF_ONESHOT | IRQF_SHARED, >> >> Shared IRQ with devm is a recipe for disaster. Are you sure this is a >> shared one? You have a remove() function which also points that it is >> not safe. You can: >> 1. investigate to be sure it is 100% safe (please document why do you >> think it is safe) > > Could you elaborate on what is unsafe in using devm with shared > interrupts (as compared to non-shared or not devm-managed)? > > The remove function is indeed reversing the order of cleanup. The > shutdown path can be fixed by removing `remove()` and adding > `devm_add_action_or_reset(...deactivate)` before the IRQ is registered. Shared interrupt might be triggered easily by other device between remove() and irq release function (devm_free_irq() or whatever it is called). Best regards, Krzysztof