Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4799076imd; Tue, 30 Oct 2018 07:36:11 -0700 (PDT) X-Google-Smtp-Source: AJdET5d9+fA3wstOnr6fMxFIwYnwAuwBFzK6fqZhfzyxkwlzfkK3gcI+xrDHtEmGS9JCbaT5LgUs X-Received: by 2002:a65:664e:: with SMTP id z14-v6mr17593766pgv.347.1540910171025; Tue, 30 Oct 2018 07:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540910170; cv=none; d=google.com; s=arc-20160816; b=T86hjMzItTycUiCyswa2icJhjTQoy1dReLComGueILqoZS8ubRrkn9FCtQz3eOh07m C0Qq27Nj8eZiMKp2eCMUnJhbG4HqRyXOvZaYrKswev5I7a3ONllI/QKtPV9Jqf3Gs/T5 oT7YHuM+90LMKlj62iskbiWA+dDH+CZ4UalAisvmwA/j3z77CeVvYNw+TsVxNCaMdpfY TMiMcZxHedOZE8SqmkIlfVnQPJqzxYY4/pgF8CaAMkIMPfCk5Wcu6cVwX76uTbjfu/yI Prv2XD+KeQlGyzqMYmvam0Jwz4BV92R3Ixr6EyASSIrB6Pr8sB+QFjXnUSizoULk8v2n zpeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=5sDRN6IPWQ3x7HrGoo2fr8elXUd6LLxUE4O0TljxdAc=; b=cK/sRJW2j2kxHpO5zo1ZTa2mDZW9PRaH+d/asXx5iAWcos4Afi1gocTp/LZjobcuIm oHdjPWSQy86fNlLNfMrG3pSd3AuxLwk2yy8C8kfwBwLxM2O2LBR9OaXDXu53kEurfrEi e9l9kHjzY/EUIUEVSmrPE+g+mxEkQoII0/nOhF/2m44Lh/vhHFWr1BJQkdGJ3QlBz1fi KaczyAoe5YhSs0RVWctW0LaWjs1HXB8z5F2I/58c54VbY/uNp8ujhrK6QNxFi2qe77k7 TzsorLK+yLi5b8ODxNOKZQCDPx9cCUrKYxIUBD2RzNjyegsJfa7UMSc/BXYUyrTdWf9y 0t8Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16-v6si15248183pfy.64.2018.10.30.07.35.53; Tue, 30 Oct 2018 07:36:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbeJ3X2r (ORCPT + 99 others); Tue, 30 Oct 2018 19:28:47 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:42799 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbeJ3X2r (ORCPT ); Tue, 30 Oct 2018 19:28:47 -0400 Received: by mail-qk1-f195.google.com with SMTP id u68so3400063qkg.9 for ; Tue, 30 Oct 2018 07:35:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5sDRN6IPWQ3x7HrGoo2fr8elXUd6LLxUE4O0TljxdAc=; b=C2aWaU984rFSmUZQ1Dw4DELER6HEfEQqIppteB7SNorGk0Z0H+4uVFdgrlD8sale2P 8KZ3/rRa9siD1n/VOOwLwZDfiBXycDtlMqSItCcbXy8Fd53vOTfR592FO7tGD8J6zBus xwLg+cFhv3uRyYldL0VvXjurfd0hku423n00WAMpQgL4Q1D4W5WtRZS1f1PofYV9tqcL G277QLYknUoB+ysF9T7g9cCmYiMTI6n51t7DRclI12NFjao9HTYwe6RSaXmQwaXlWsJl 4L+ExJ+DUvZMAoffxnTHjNmz0d20O/etjcYfncnLWf0Nkb2eSQTSXhkHzXcNYDDgC/cu VAuA== X-Gm-Message-State: AGRZ1gK6/V9EOtVlOX6DQkUeQPVs1IN5L+kiGxbwp3TzpZEg5OwUGr2Z 2fbaJP3li1agBdIJgO1vYVesPnl1pBnwdmhP8VXjS/fT X-Received: by 2002:ae9:e102:: with SMTP id g2mr639438qkm.343.1540910103230; Tue, 30 Oct 2018 07:35:03 -0700 (PDT) MIME-Version: 1.0 References: <20181019085958.32694-1-ckeepax@opensource.cirrus.com> <20181019085958.32694-2-ckeepax@opensource.cirrus.com> <20181028223116.GJ1882@kunai> <20181030115120.GI16508@imbe.wolfsonmicro.main> In-Reply-To: <20181030115120.GI16508@imbe.wolfsonmicro.main> From: Benjamin Tissoires Date: Tue, 30 Oct 2018 15:34:51 +0100 Message-ID: Subject: Re: [PATCH 2/2] i2c: Clear client->irq in i2c_device_remove To: ckeepax@opensource.cirrus.com Cc: Wolfram Sang , Linux I2C , lkml , patches@opensource.cirrus.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 30, 2018 at 12:51 PM Charles Keepax wrote: > > On Mon, Oct 29, 2018 at 11:15:47AM +0100, Benjamin Tissoires wrote: > > On Sun, Oct 28, 2018 at 11:31 PM Wolfram Sang wrote: > > > > > > On Fri, Oct 19, 2018 at 09:59:58AM +0100, Charles Keepax wrote: > > > > The IRQ will be mapped in i2c_device_probe only if client->irq is zero and > > > > i2c_device_remove does not clear this. When rebinding an I2C device, > > > > whos IRQ provider has also been rebound this means that an IRQ mapping > > > > will never be created, causing the I2C device to fail to acquire its > > > > IRQ. Fix this issue by clearing client->irq in i2c_device_remove, > > > > forcing i2c_device_probe to lookup the mapping again. > > > > > > > > Signed-off-by: Charles Keepax > > > > > > Adding Benjamin here again. Also, should there be a Fixes: tag? > > > > Not sure if the circumstances are preventing me to think straight, but > > how can you reprobe the i2c_device? > > You just head into /sys/bus/i2c/drivers/ and use the > unbind file to remove the driver. You can then probe the driver > again using the bind file. Right... not sure why I haven't seen that one yesterday > > > And in all cases, for the Host notify part, having the IRQ already set > > shouldn't be an issue. > > To be clear this isn't a theoretical issue this is something I > can replicate very easily. The problem comes in when you unbind > both the I2C device and the device that is providing its IRQ. In > my case the I2C device is a speaker amp and the device providing > IRQs is an audio CODEC. > > When the device providing the IRQ is unbound it will delete the > IRQ mapping. For the I2C device to acquire its IRQ something > needs to recreate that mapping, this would normally happen (in a > DT system) as a result of the of_irq_get/_by_name. But as > client->irq is already set this doesn't happen, causing the I2C > device to fail probe because it couldn't locate its IRQ. Right. I completely missed the fact that the driver of the IRQ could be reset during the period the device is unbound. That's a pretty strong case for this patch. > > I can provide some stack traces or something if that would help > to clarify the issue? No, that's fine. Now I get this, and I totally agree with the approach: Reviewed-by: Benjamin Tissoires Cheers, Benjamin