Received: by 10.192.165.148 with SMTP id m20csp4700830imm; Tue, 8 May 2018 12:48:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpaJ4qAqjwRgj3gkAkMtZ4Lr6CU5rPZOMSgnYyTsQbIF53vWrzNxco5w4vrg1OxCfI9dUw0 X-Received: by 2002:a17:902:8a82:: with SMTP id p2-v6mr8254066plo.244.1525808892905; Tue, 08 May 2018 12:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525808892; cv=none; d=google.com; s=arc-20160816; b=u3iet3pxrpggaHVh1iZwt98xFnqXwbz7vAVkvdTKU/DvyRUg0sXrpJ9lPGsQob5avc kxm89smkuhC1x9pQadTUy6TQDA6zl6FGrQKeUPm2hPjPTVE1vaeYn1F9JnuZzkJVFOd3 8h/u6fhc+f2kaAqkQUh6sU/1JwwldrovwVxOFO2Oy3nG8iG3oyIv/MvJw6xcq+mxwbZB 8ZUhZ7uImqd9LTsz9EBmfwErLykwlPm7vtAZUaBuSgeZcP1jPBctYzlBd/cXJ/O/AbBi lDyu0aIxEaLtCI/0zBe3CteBr0EsgXr6rULrtjwI31LwhZJtV+PtQG5kFQ3zegfj6LGo 6p2Q== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=Nvf2Is3ahefbeupVLVJMETdJ7UYxJjYJKOrINF8OYIg=; b=0RWMQlYN4JPM1SEwO4sk73+BIPh7OlER+zPbyEVE7QkIioocYQM6wPW3/Sw0pjS/1l hJauO3lDHn0T2XYVCXuvtihyxcdo6fpNwEz/W3y0zUJS8idKw4FMQfyY+vE779sCM7K/ 8HOLoKVcDulaWRuXmjPdvNnX/HQnCzATJebT/8aXN4hnORZY1iTC4YgM8F2B9hFl1Rzz jQJ5XsbvZY3Muz3Do4ew+MQtLj8DIj5+uJ2RxjE4oFcHC3aOEdgAvdJX5YrY5LMRr3xe yFSz1lku4UY0+ZG7MJQ1a+XTkW7QVkx+oGPGc97uG/fiMDfr0EAcCdG/O2LHbbQ0047p 6IJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=LT4XRsPy; dkim=fail header.i=@chromium.org header.s=google header.b=L+hn/1YW; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f88si25284594pfk.107.2018.05.08.12.47.57; Tue, 08 May 2018 12:48:12 -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; dkim=fail header.i=@google.com header.s=20161025 header.b=LT4XRsPy; dkim=fail header.i=@chromium.org header.s=google header.b=L+hn/1YW; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755631AbeEHTqb (ORCPT + 99 others); Tue, 8 May 2018 15:46:31 -0400 Received: from mail-ua0-f180.google.com ([209.85.217.180]:43086 "EHLO mail-ua0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755446AbeEHTq2 (ORCPT ); Tue, 8 May 2018 15:46:28 -0400 Received: by mail-ua0-f180.google.com with SMTP id d4so13100312ual.10 for ; Tue, 08 May 2018 12:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Nvf2Is3ahefbeupVLVJMETdJ7UYxJjYJKOrINF8OYIg=; b=LT4XRsPy4qgUgX+GpsqIAZ0sUUGpeTD+NPCUDgfRev9TkfkGkAHBw6ps0PdBWYybCG Kw0wLPC0A7X24pxHyjUcCL9S66sY7eTxi4w08plOomLxCd/lZEHdRtLxyWhQIypvlS42 rosJDdnHrSv2yKI5ya7o6/rHs6M8EnkYOcozKwUUx27WxcVzqETFsLH4akKCS40eU+S+ 0+221WDR2MP9VwVXx1Z7WvSYCrH0nJTwx8ZGQ6e+sJHY6Vi63PqQD2GI4IzLrTjaawbC T61fmk2NdKbw9c6gaC6wc71O+xl7rY54ipK8ovv8Mm9SvxMyxwecXhaRc8yYJ1ol8fCt pxKw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Nvf2Is3ahefbeupVLVJMETdJ7UYxJjYJKOrINF8OYIg=; b=L+hn/1YWxlYSk29y06Jrj/EvC5hAIr40kpDI5YcwX+f8eTs6NhjRaDJOd+3clukBor 8fjbTpvBOLxvwLMW6D1iVNjxtUbmwovzmyBv3HQl9vxuzfiPRE28t5wZkiZ+S56cRbTj qXEQBVpXpDmNcVJm47nmeJ1Bj2TI7+bquH8eo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Nvf2Is3ahefbeupVLVJMETdJ7UYxJjYJKOrINF8OYIg=; b=NxmJ1BR4zrOh4k0bREyPsU/3nsYbrhTN7g2UcbanU2K/CD4MFpAs2+qH9w4I/Gri6C KJjpZaKcP6KpJ8Wj7m8p7MZe/JWLzjYWKfIUcxENqdOMQGIdKZYUYlRzWWXCkXw8zb6d ei24aDygFx9t9O3Shl2WRiOU0nUdu6CDBTcqxVadKGH4pofwFjNfIGhL0jB50Dr5WAe0 dKEajt2Q7TxfbmctNfc8qA+flnRi2iz8qhMoHVs8UPnoT2ap9fUxsK7XJoqY/Rza0s6S AH3ycJsrr29lECJkVdon9BcY9JbhUeU/6X0a3iE7Chh1+v3dPnAhAzSBooUIlcUZJbt0 5Unw== X-Gm-Message-State: ALQs6tCJUB+c8uGiA9XPwaKqpWfXwsUQvJlFYhNfdvKea6+/6RBndlp0 dv9t/bFygxgiC3F7M2oj3pWysj/baeamCWz+YLpG2AkPoW4= X-Received: by 10.176.5.4 with SMTP id 4mr35803096uax.135.1525808787216; Tue, 08 May 2018 12:46:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.48.82 with HTTP; Tue, 8 May 2018 12:46:25 -0700 (PDT) In-Reply-To: <20180508015623.GA61455@rodete-desktop-imager.corp.google.com> References: <20180503065553.7762-1-jeffy.chen@rock-chips.com> <20180507221511.GA6448@rodete-desktop-imager.corp.google.com> <5AF0FF18.1050905@rock-chips.com> <20180508015623.GA61455@rodete-desktop-imager.corp.google.com> From: Doug Anderson Date: Tue, 8 May 2018 12:46:25 -0700 X-Google-Sender-Auth: dXY3dKqDkn_n4f_cpvNQzaXGhS4 Message-ID: Subject: Re: [RESEND PATCH] pinctrl: rockchip: Disable interrupt when changing it's capability To: Brian Norris Cc: JeffyChen , LKML , =?UTF-8?Q?Heiko_St=C3=BCbner?= , "open list:ARM/Rockchip SoC..." , Linus Walleij , linux-gpio@vger.kernel.org, Linux ARM 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 Hi, On Mon, May 7, 2018 at 6:56 PM, Brian Norris wrote: > On Tue, May 08, 2018 at 09:36:24AM +0800, Jeffy Chen wrote: >> On 05/08/2018 06:15 AM, Brian Norris wrote: >> > On the other hand...this also implies there may be a race condition >> > there, where we might lose an interrupt if there is an edge between the >> > re-configuration of the polarity in rockchip_irq_demux() and the >> > clearing/handling of the interrupt (handle_edge_irq() -> >> > chip->irq_ack()). If we have an edge between there, then we might ack >> > it, but leave the polarity such that we aren't ready for the next >> > (inverted) edge. >> >> if let me guess, the unexpected irq we saw is the hardware trying to avoid >> losing irq? for example, we set a EDGE_RISING, and the hardware saw the gpio >> is already high, then though it might lost an irq, so fake one for safe? > > I won't pretend to know what the IC designers were doing, but I don't > think that would resolve the problem I'm talking about. The sequence is > something like: > 1. EDGE_BOTH IRQ occurs (e.g., low to high) > 2. reconfigure polarity in rockchip_irq_demux() (polarity=low) > 3. continue to handle_edge_irq() > 4. another HW edge occurs (e.g., high to low) > 5. handle_edge_irq() (from 3) acks (clears) IRQ (before a subsequent > rockchip_irq_demux() gets a chance to run and flip the polarity) > ... > > Now the polarity is still low, but the next trigger should be a > low-to-high edge. > >> i'll try to confirm it with IC guys. One note is that in the case Brian points at (where we need to simulate EDGE_BOTH by swapping edges) we purposely ignored the TRM and we needed to do that to avoid losing interrupts. For details, see commit 53b1bfc76df2 ("pinctrl: rockchip: Avoid losing interrupts when supporting both edges"). We did this because: 1. We believed that the IP block in Rockchip SoCs has nearly the same logic as "gpio-dwapb.c" and that's what "gpio-dwapb.c" did. 2. We were actually losing real interrupts and this was the only way we could figure out how to fix it. When I tested that back in the day I was fairly convinced that we weren't losing any interrupts in the EDGE_BOTH case after my fix, but I certainly could have messed up. For the EDGE_BOTH case it was important not to lose an interrupt because, as you guys are talking about, we could end up configured the wrong way. I think in your case where you're just picking one polarity losing an interrupt shouldn't matter since it's undefined exactly if an edge happens while you're in the middle of executing rockchip_irq_set_type(). Is that right? -Doug