Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2431363ybi; Mon, 17 Jun 2019 04:51:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5OznAbWdruJk2jA221+0SZ8xz1FOhlWu2fQgP6OvkBphMcr4JItnvkTUf8u4vh2HAyVMw X-Received: by 2002:a17:90a:9281:: with SMTP id n1mr24954064pjo.25.1560772266646; Mon, 17 Jun 2019 04:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560772266; cv=none; d=google.com; s=arc-20160816; b=sd1NldnV6DTkfd4VFFflfWx6Y1+cAGqZxDa7NA+9Rx0R4NTv2OKQPK71KawUQgZFrP fop0iyzzaa/h72fbE/f2y6aPCs5h6REyfeBG5zPbR2a3uqU8VxvOKCcdGOJjQ1c5dnY4 P4Oa1YD7i0LR+p1INN67q2vBw9gA2sHOrtkeWe3F1mzB2YefvADcejXDUfb7Wt/jW1zJ CoymKQdCFkbQ01zZvwRuPv/nqIPuWta1v5Hg5Ifkvo5o4oppt3ZXcXHQH81q8jc0eB35 Im0ebuLimg7KuvPxk/QAQBqLjYHwb/FfXSEEARVtbCeEIcSOsT2gSvsqzCl24KyQUybf QZ9Q== 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:dkim-signature; bh=jUC3oAv954DDdM3Qoub7t5o8CIOFNWz/tUxECd+JQ9s=; b=HNPV5sg/NfodKg/gG9XxWHKoCHE0D6tQtaTCESlZ4QkgWgkCheJAT1XSg4UyQNzqGb rje2XCacffeyyM4mDF3NFKrhxr57PgnqPKrjAdeY7r1xonJAt4qhP2NaT26/daFlFVkp +DdG98c9AgjVe9U+v3vmo0ZM4fWk9QxNZnFd5G35eaDymRK3B+iMArBKrnYIxMLqZ9NA 17BGloUbs9L2/7I6qsQR7g4wfpKNQ0YMa9JHO1pLs6zManGwUtIAnsZViAoXgCUQY/lo WJYKR1PpQEdfnGqXNOwUhCRMgj6Tcynsb5isbFKidXXoQr/fiSoApB2gz/HAa9pNgpph +iTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BuTo/QN7"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si10312851pgp.245.2019.06.17.04.50.51; Mon, 17 Jun 2019 04:51:06 -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=pass header.i=@linaro.org header.s=google header.b="BuTo/QN7"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726225AbfFQLuX (ORCPT + 99 others); Mon, 17 Jun 2019 07:50:23 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:37513 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725810AbfFQLuW (ORCPT ); Mon, 17 Jun 2019 07:50:22 -0400 Received: by mail-lj1-f196.google.com with SMTP id 131so9002524ljf.4 for ; Mon, 17 Jun 2019 04:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jUC3oAv954DDdM3Qoub7t5o8CIOFNWz/tUxECd+JQ9s=; b=BuTo/QN7Xsk7pkbu1e9KTEhJat0l1vZhloCRxm0xW7p0PHAtECvTmN4DyRUvWnjY7F 425/HzaReo/WGxA2vRP+9whOnA8l5R7G/hCUShepGlHEpyWlnF0+klfqxV0Zkhi8Bz+0 jV4gq1J37BAZ3kW71udx4PVHTSDbvB43bURTwX7+6ZvcQpXKeN2toNqRAhr7RformkLw 6pgUeq7MQcctyJamYjgMyuyaJSaXDbS9aSDe2bU6HRcHWNpFKZb1PUVZ5EBagKifKxOf +jrOWqbqJ4KyIlrZlv7VHhbJJqtfvDqgRIULjvBBernbELvj0uJYjzQabAfqGTX916DY uIWA== 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=jUC3oAv954DDdM3Qoub7t5o8CIOFNWz/tUxECd+JQ9s=; b=mF09FHh4ut++NuQRTj8Nc5N0pk5deKn/eFU/tfJdeetSqVmV717TcHE4amtq9FkyGs 0QA/RY43yhuHhxhcjI/Smd1Aea75fv+J5V+9U5A7Bqzz+l8RwF4dSO5sc5NEAAP+aPA5 bPQY16jVksrSgbSbUfskzobUZlbAAylb6HRF+7bYl2wC2gfHg6WUdvs7l+RAre+6STur O/iKsI61RLeaB3jKykWLFhh1yvddBI/PgUaYRp8hPgWHqY7q1cQWrH1i6K6b/+l3iWd9 gUMz0QWcbpshCqTr7w5JfZvZBvkCo6PQ/Y90oIvyIw3V+/lVfPxN7J7N1P6fz4tMBOxz ezjg== X-Gm-Message-State: APjAAAW6P3UrekzqmdnJHpd18t+0DVsIgAGjOVIKQmR0eRg7py3nFdQI CX0EYysAL1k7lxgmTgx+bq57g9HhUIeI4+d5lfoqLQ== X-Received: by 2002:a2e:a0cf:: with SMTP id f15mr29112501ljm.180.1560772220963; Mon, 17 Jun 2019 04:50:20 -0700 (PDT) MIME-Version: 1.0 References: <20190611185102.368ED21744@mail.kernel.org> <671f87d6-f4a4-6d2c-967b-e1aa0677d83e@codeaurora.org> In-Reply-To: From: Linus Walleij Date: Mon, 17 Jun 2019 13:50:09 +0200 Message-ID: Subject: Re: Fwd: Re: [PATCH] pinctrl: qcom: Clear status bit on irq_unmask To: Neeraj Upadhyay , Hans Verkuil Cc: Stephen Boyd , Tengfei Fan , Bjorn Andersson , LKML , "open list:GPIO SUBSYSTEM" , MSM , sramana@codeaurora.org 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 Mon, Jun 17, 2019 at 12:35 PM Neeraj Upadhyay wrote: > Hi Stephen, there is one use case with is not covered by commit > b55326dc969e ( > > "pinctrl: msm: Really mask level interrupts to prevent latching"). That > happens when > > gpio line is toggled between i/o mode and interrupt mode : > > 1. GPIO is configured as irq line. Peripheral raises interrupt. > > 2. IRQ handler runs and disables the irq line (through wq work). > > 3. GPIO is configured for input and and data is received from the > peripheral. There is no distinction between using a GPIO line as input and using it for IRQ. All input GPIOs can be used for IRQs, if the hardware supports it (has an irqchip). > 4. Now, when GPIO is re-enabled as irq, we see spurious irq, and there > isn't > > any data received on the gpio line, when it is read back after > configuring as input. That's an interesting usecase. Hans Verkuil reworked the GPIO irq support very elegantly exactly to support this type of usecase (irq switch on and off dynamically), where he was even switching the line into output mode between the IRQ trains. (one-wire transcactions for CEC). > Patch https://lkml.org/lkml/2019/6/17/226 tries to cover this use case. > Can you please provide your comments? What this patch does is clear all pending IRQs at irq unmask. This is usually safe, unless there may be cases where you *want* to catch any pending IRQs. I guess normally you don't so it should be safe? The corner case is when you start some transaction or whatever that gets ACKed by an IRQ and you actually get the IRQ back before you had time to execute the code enabling the IRQ. That would be racy and bad code, as you should clearly enable the IRQ first, then start the transaction. So I think this patch is safe. But let's see what Bjorn says. Yours, Linus Walleij