Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1380977imp; Fri, 22 Feb 2019 02:16:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ9RwlHWQ3/hpWx40Rzgl+tddX7JLxJCQWPGks8gl8yp2e0R9g/u8QDFs0jCBfztQrcKktK X-Received: by 2002:a17:902:b590:: with SMTP id a16mr3498006pls.22.1550830614267; Fri, 22 Feb 2019 02:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550830614; cv=none; d=google.com; s=arc-20160816; b=FOqTIZ0rRc2Aw3nTwLP42rcqnNxVR4NEsXdeVmpxiEoAG6PlVlsnTJ/FGQCNM1cVzt Ruy1hDv7kgFeD+T8S37IWGxB3WZf2KfBQ6ud+wnonbWW00WBJCkqsZMVjudAw29pYYWo AoFiZa8rNwxvTZshHds2FxwUBy7fBzh/rc4CF1jgU8AJFZKSkHoAdhio8OgUAWORIVpq IDzRq0HilI2ijC444bGfl7Fau94x1M8Nj99AjARI+TQSPAVjC6kP4veSCiWMo/Wsvaup 8Bze3BFFLIKLajLi6ti5je7ZgrPDBXqXmRz/NlSsShZH4+Q/XPYiCXqh1lt2qJzvEGsV 5tVQ== 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=qZ6nSlzjEg37eprWB6RPmDzUgKkp6Tp+DrOR6ANqsY4=; b=uNCkpBGr1dfUoD/uK7QzCpgEo5a/FgIZGlX40ieEVPxH63Ga8ShzYbtaTw+4jM7nUp OIkJ0sPpZrKTm4CTcNIfdyzojgUZNeAhEIxXvWJjOrA5R+MIPtnwz9S+HsGMF2pwvqnK k275qkHLahh3L0sfKCC/sAW4fiXyErvVhmG8U4bCZDeRzv8hvv/Ul0bmemOq0bS7YuvD FEx1gywp9VevNEo4YiDeinHgT7BgdHOFexnLopgfVcbG74U6aibRnFEQmQ7urhRXO6Oj 9MvCcd4xIksPvcNT0RLPQweOdOLAu8x3ARTikVqQTV0oYTcWu/RnvndFn4Zkejt4ZskQ FNMw== 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 l17si234209pfe.1.2019.02.22.02.16.38; Fri, 22 Feb 2019 02:16:54 -0800 (PST) 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 S1726297AbfBVKQM (ORCPT + 99 others); Fri, 22 Feb 2019 05:16:12 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35444 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726122AbfBVKQL (ORCPT ); Fri, 22 Feb 2019 05:16:11 -0500 Received: by mail-qt1-f196.google.com with SMTP id p48so1885891qtk.2 for ; Fri, 22 Feb 2019 02:16:10 -0800 (PST) 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=qZ6nSlzjEg37eprWB6RPmDzUgKkp6Tp+DrOR6ANqsY4=; b=Nvhyjohshvx4k10wL6hmDx2OoUhqEOaZ1sg+KEaLEoY2Rh/xy1OMhcFOmWX2j6uwSe YyqrGYufUN8JOmOxAEO3IeT+VsVnZi2BWNEAMfB9Aa+yHi1tEy2Db0fYW5X2Ze51KHTa +m3RabV9z01bO2iZYMtf+qLGxmU4fTAtNFPpNOZgqCdlYWFMzogHKPsIj7bbSDJ8DrAd 1TuuwoBdp7uGiDzZFU/7lZhFgcpL9i5ixPFkptKAgfxzYY9oytZNpEjy9oiRBOGTFq9E bcAfydRyKGt64lWJ+EYiUg8pGhpI3+CBamRQe0IX8xF2W5yB2OdN8hUoKoQXYAd0a/Vr rSSw== X-Gm-Message-State: AHQUAubDNvrx9O63yd0eT1sQIIplKTetBPTtECop6DoOuJH7SrPMjN11 +HpBBiRMitCv/JM2Rqqkm+wGwRBo2qQJoyepOzCdfg== X-Received: by 2002:a0c:8830:: with SMTP id 45mr2428694qvl.17.1550830570525; Fri, 22 Feb 2019 02:16:10 -0800 (PST) MIME-Version: 1.0 References: <20190219193027.13882-1-jbroadus@gmail.com> <20190221232609.d4vxl3osj6mwooey@katana> In-Reply-To: <20190221232609.d4vxl3osj6mwooey@katana> From: Benjamin Tissoires Date: Fri, 22 Feb 2019 11:15:59 +0100 Message-ID: Subject: Re: [PATCH] i2c: Allow recovery of the initial IRQ by an I2C client device. To: Wolfram Sang Cc: Jim Broadus , ckeepax@opensource.cirrus.com, Linux I2C , lkml 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 Fri, Feb 22, 2019 at 12:26 AM Wolfram Sang wrote: > > On Tue, Feb 19, 2019 at 11:30:27AM -0800, Jim Broadus wrote: > > A previous change allowed I2C client devices to discover new IRQs upon > > reprobe by clearing the IRQ in i2c_device_remove. However, if an IRQ was > > assigned in i2c_new_device, that information is lost. > > > > For example, the touchscreen and trackpad devices on a Dell Inspiron laptop > > are I2C devices whose IRQs are defined by ACPI extended IRQ types. The > > client device structures are initialized during an ACPI walk. After > > removing the i2c_hid device, modprobe fails. > > > > This change caches the initial IRQ value in i2c_new_device and then resets > > the client device IRQ to the initial value in i2c_device_remove. > > > > Fixes: 6f108dd70d30 ("i2c: Clear client->irq in i2c_device_remove") > > Signed-off-by: Jim Broadus > > Adding Benjamin to CC Sorry, I should have answered earlier. I am a little bit hesitant regarding this patch. The effect is correct, and I indeed realized a few weeks ago that something were wrong as we couldn't rmmod/modprobe i2c-hid. But I still have the feeling that the problem is not solved at the right place. In i2c_new_device() we are storing parts of the fields of struct i2c_board_info, and when resetting the irq we are losing information. This patch solves that, but I wonder if the IRQ should not be 'simply' set in i2c_device_probe(). This means we also need to store the .resources of info, but I have a feeling this will be less error prone in the future. But this is just my guts telling me something is not right. I would perfectly understand if we want to get this merged ASAP. So given that the code is correct, this is my: Reviewed-by: Benjamin Tissoires But at least I have expressed my feelings :) Cheers, Benjamin > > > --- > > drivers/i2c/i2c-core-base.c | 9 +++++---- > > include/linux/i2c.h | 1 + > > 2 files changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > > index 28460f6a60cc..af87a16ac3a5 100644 > > --- a/drivers/i2c/i2c-core-base.c > > +++ b/drivers/i2c/i2c-core-base.c > > @@ -430,7 +430,7 @@ static int i2c_device_remove(struct device *dev) > > dev_pm_clear_wake_irq(&client->dev); > > device_init_wakeup(&client->dev, false); > > > > - client->irq = 0; > > + client->irq = client->init_irq; > > > > return status; > > } > > @@ -741,10 +741,11 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) > > client->flags = info->flags; > > client->addr = info->addr; > > > > - client->irq = info->irq; > > - if (!client->irq) > > - client->irq = i2c_dev_irq_from_resources(info->resources, > > + client->init_irq = info->irq; > > + if (!client->init_irq) > > + client->init_irq = i2c_dev_irq_from_resources(info->resources, > > info->num_resources); > > + client->irq = client->init_irq; > > > > strlcpy(client->name, info->type, sizeof(client->name)); > > > > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > > index 65b4eaed1d96..7e748648c7d3 100644 > > --- a/include/linux/i2c.h > > +++ b/include/linux/i2c.h > > @@ -333,6 +333,7 @@ struct i2c_client { > > char name[I2C_NAME_SIZE]; > > struct i2c_adapter *adapter; /* the adapter we sit on */ > > struct device dev; /* the device structure */ > > + int init_irq; /* irq set at initialization */ > > int irq; /* irq issued by device */ > > struct list_head detected; > > #if IS_ENABLED(CONFIG_I2C_SLAVE) > > -- > > 2.20.1 > >