Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3486654pxk; Mon, 5 Oct 2020 10:52:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVikEXVivzj/D8dZVJqN81beBNEOqiBIAjS5cafpEzc+GIcUWSkfX9XrL8FIS6pq77wKph X-Received: by 2002:a17:906:4d57:: with SMTP id b23mr920012ejv.496.1601920375416; Mon, 05 Oct 2020 10:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601920375; cv=none; d=google.com; s=arc-20160816; b=TNwyJiqff2Cck1NJES3bpSq6x6VH45Ek47oR0YUETH7y7BBcoBO9zR77WkTjBU6bRf ON2HghoGvBXaJKBfVo6qpZEK7s8jSfl8hqjOk12qk49i9yZR6BeqA2EgW1rLmLp6trjJ IGcoPbu7Id7gbw8J+KI19Zc9az77Fzrj0EosSGe1aZS4QdoWJOyA5S56yKg/6Z47yj8m QZSrzc8RSNh9bI/h+4zmPaw3dC26oGADdkDOhsajpQdohUC4FcTRRrX0AaVLZHKUEdVE sZXgSDUU9ZXllBpMkJUzo3cfVVORkMRo6QSStyRMh9/5xxcVp1PMDdwWaahexJtob8tP Ix4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OjfWNGBFsyUCHvU9DA+5k3rGdZwYFPOWFWahX7OdzMs=; b=PWZaSF8wCMszUeakNu6ZpdYCJlTsyYtZ/h/IYRcKN9cXa6Vj2MW4m32entT543Ts9G HYY0Ks/T1ACEU1LFOYbH3UIeJe6gmalynFavk4K6e4ct6ZsUoaau6LwhXA1xiBeAszBr HHQbrzELsKMZbHg7pCY1DBrA+Sn96MiwhH2/KYLY7s/mLGDzw0Z75WxbwlXG6QnCka96 N0f2/YD3oz72s9mksHXeM3qAtMriM9gu9Vqfu8zbbG8ZHkXUoG+TTVdwde5015+7hIAl qSwkn3D869rkeJyzxdAUIAu4aa4uyxJ/zGbucw0RtjJYhEBmXnGI3CFP9l4lVIr6cDqO QICQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qOh1CpVf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 94si502992edp.211.2020.10.05.10.52.31; Mon, 05 Oct 2020 10:52:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qOh1CpVf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728439AbgJEPgY (ORCPT + 99 others); Mon, 5 Oct 2020 11:36:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:60534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727375AbgJEPcs (ORCPT ); Mon, 5 Oct 2020 11:32:48 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C64F207BC; Mon, 5 Oct 2020 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601911967; bh=T/R0tIidZY84WWFveEGhxfzHZ8KfK/SjINpJJbe+YBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qOh1CpVfYL/MpAaUqbo2uxl9+M/L391L8kbglaxp1GFEJv8nyrp2JCoULDzMN1Mu3 x3Wa9bALdyoQEWLYbugT9cOifqv2h7StMfgO6BbZU4SUPSCVlhMPI76m8W95jFKbsk 7PRGaRdywyCDMyH3Zvw1a02zFQbzQQ28vqDnWJqI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taiping Lai , Chunyan Zhang , Baolin Wang , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.8 50/85] gpio: sprd: Clear interrupt when setting the type as edge Date: Mon, 5 Oct 2020 17:26:46 +0200 Message-Id: <20201005142117.140866477@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005142114.732094228@linuxfoundation.org> References: <20201005142114.732094228@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Taiping Lai [ Upstream commit 5fcface659aab7eac4bd65dd116d98b8f7bb88d5 ] The raw interrupt status of GPIO maybe set before the interrupt is enabled, which would trigger the interrupt event once enabled it from user side. This is the case for edge interrupts only. Adding a clear operation when setting interrupt type can avoid that. There're a few considerations for the solution: 1) This issue is for edge interrupt only; The interrupts requested by users are IRQ_TYPE_LEVEL_HIGH as default, so clearing interrupt when request is useless. 2) The interrupt type can be set to edge when request and following up with clearing it though, but the problem is still there once users set the interrupt type to level trggier. 3) We can add a clear operation after each time of setting interrupt enable bit, but it is redundant for level trigger interrupt. Therefore, the solution is this patch seems the best for now. Fixes: 9a3821c2bb47 ("gpio: Add GPIO driver for Spreadtrum SC9860 platform") Signed-off-by: Taiping Lai Signed-off-by: Chunyan Zhang Reviewed-by: Baolin Wang Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-sprd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpio-sprd.c b/drivers/gpio/gpio-sprd.c index d7314d39ab65b..36ea8a3bd4510 100644 --- a/drivers/gpio/gpio-sprd.c +++ b/drivers/gpio/gpio-sprd.c @@ -149,17 +149,20 @@ static int sprd_gpio_irq_set_type(struct irq_data *data, sprd_gpio_update(chip, offset, SPRD_GPIO_IS, 0); sprd_gpio_update(chip, offset, SPRD_GPIO_IBE, 0); sprd_gpio_update(chip, offset, SPRD_GPIO_IEV, 1); + sprd_gpio_update(chip, offset, SPRD_GPIO_IC, 1); irq_set_handler_locked(data, handle_edge_irq); break; case IRQ_TYPE_EDGE_FALLING: sprd_gpio_update(chip, offset, SPRD_GPIO_IS, 0); sprd_gpio_update(chip, offset, SPRD_GPIO_IBE, 0); sprd_gpio_update(chip, offset, SPRD_GPIO_IEV, 0); + sprd_gpio_update(chip, offset, SPRD_GPIO_IC, 1); irq_set_handler_locked(data, handle_edge_irq); break; case IRQ_TYPE_EDGE_BOTH: sprd_gpio_update(chip, offset, SPRD_GPIO_IS, 0); sprd_gpio_update(chip, offset, SPRD_GPIO_IBE, 1); + sprd_gpio_update(chip, offset, SPRD_GPIO_IC, 1); irq_set_handler_locked(data, handle_edge_irq); break; case IRQ_TYPE_LEVEL_HIGH: -- 2.25.1