Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4075986rwb; Mon, 31 Jul 2023 00:20:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHYUceRNAa0MmZcukncJJWMztC5x9aV42lEV2pVZT6Kl2U5qi5/AM+nArm7pthaaCIdhZ5s X-Received: by 2002:a05:6a00:1953:b0:687:189c:4e3d with SMTP id s19-20020a056a00195300b00687189c4e3dmr7617514pfk.10.1690788035783; Mon, 31 Jul 2023 00:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690788035; cv=none; d=google.com; s=arc-20160816; b=dT+CFgLiFlWy9qWZzUfmJraQBQfTe7M/aP0flqmTXrQ6P/yWlZef6SuWVTnyCBv/W/ y1No/EuqerK2kwQf+1Jg2d0quhfRIygwUIgtNhhhPmDV7K+L8ZWVL9++IPbqzZOhmUYE i35SYUO1au6HifR8/DaI0B+cEm5hxi76sMm86lH8ngZ/s93TYJRDNxhYQe2L1sEx1pqb N8n5RVq4UrjwXZyTJUS9TjsbOhxJqxhgvIE+GKlFFigMpXYKlvsUmGlnz2QQ1kHNZ3U2 2w3Je7Nov+YitRReeYWGELeA3sqrN5Zc/ncvIqE0h0HtwKOM1pTC+weR/q+1SZKBh9jz n3hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ZvJi1B6SKlzQ1LvbzrEi0ZzvZYawpeN9hQcKBS5Rfqc=; fh=S8IwIIGkE0KR8lZ9VSpJpk/sojAjisYJZhMBLOpuH4k=; b=hr49eQQUHh97GxXf2DTholO6yeBKOBccMAZ+1gilcBkOipG/GCGdd9loIVk5gM44NJ XwSaitWVgjkIgvDmNpjoBEBJWUhgzyvJzSdFvEBwVLb0KURL8ppB0eui2PIg9S9IO6f7 pXHUYq+GTw/Q0t8RojX3DB7LchZZHvq8oUUG0Z9OhzhiE7eZWdIHDg2QnoAGc+31Apf5 8EfAn4M1dEnpqcX5u3TyVOPoFh37lBfoQH08u17kCb1L63+rdXimfGXCalES5s7OEHQX 1g3glR9LXAsCEwQFZbkaX8P/DPLMPt8YhrV18aZBeB1pouu9eP32yawSgZ39q1uqtU/M k7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BKmNyRCp; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k198-20020a636fcf000000b00545072f800fsi6786578pgc.320.2023.07.31.00.20.23; Mon, 31 Jul 2023 00:20:35 -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=@linaro.org header.s=google header.b=BKmNyRCp; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbjGaG6V (ORCPT + 99 others); Mon, 31 Jul 2023 02:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjGaG6T (ORCPT ); Mon, 31 Jul 2023 02:58:19 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1245136 for ; Sun, 30 Jul 2023 23:58:17 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-99bc9e3cbf1so872223766b.0 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=iBiuNG4/tNqJB7gGMSb+QbyhCfKDjP7jLWuKJKxPL/YCwLGN8wwxwblFcaHAmRJdau YTV75Y9lMvhkcG9n/dgB1ftkYkW2wK3Qc4+ZJwXLnYM6y9rKtfXUf0lBEOIJlIPJ/3vm 7OWLJJtAxhctsfpLAdJqkW98TjjZ4N9tARSRixjEMAufNNf5ny5JO8tgLi8IiqnA+3B5 aMsxUvjZz82zwi4PXLJfc65pZBxPt3+8zQ3byZf/h/By674SdN6tEv1eYbVK+EqOF+kd 9cQNbXcqRhgLxur2zp49wrR4oPUbt18pE5VFsMIn7dGga0j8sUF/UQw+qSDCZvfbSOqn 2gJA== X-Gm-Message-State: ABy/qLaZPJcDlEesn9j+FGlHDIE0ZhNKL9OzwnYkxxt7qRcBFpFR/f/w OOYvBmFrwQlUtM1DVNnXuqg6JA== 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 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, 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 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