From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEB3326B0B5; Thu, 13 Feb 2025 15:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739458967; cv=none; b=RvGNoxzs3xlHlD3wAFs4y/BcShBZNfDEzCHCWG0pbIkSZ0UGsFh7SnFrZVA9ZnGT2vwtQSd4cqexU8cwEuevVj4Wiyj4ZS5lyTPwTlAYfo3ODZQcQk2J/yJG+tiO0zHoVaJfsKQ3hR8j0uglNaZL51srpuCtj3GvSf4zUQM5oa8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739458967; c=relaxed/simple; bh=cg4QoOPNY5GkD6iebHvaw5izqAzkbzGwngdnPNG1WTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RlQsGR1z7SkBRwMTVHA8WHaCGvuFwIIS9gXoXmZsdjFwsJ4hZmgEXAsnxnllB1rA4/fgzry8p9P6itzp8rk3UtnomkdxXauPtQh+Pl480yOGnQl+NqN4JDf01hSdSiiY2O7ONw4no3dfOfTMeRTyKzun0DybW6xjZWMkUKBz16s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VkaiWU2W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VkaiWU2W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DAD8C4CEE4; Thu, 13 Feb 2025 15:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739458967; bh=cg4QoOPNY5GkD6iebHvaw5izqAzkbzGwngdnPNG1WTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkaiWU2W1CoUU5twRM4coUEBskpI+dAyKVxhsEE6SoDoJNFc3PwvsRJ1tJt1cnP/G y9oWpUpRv9X5b4NJp4AsZvrZOH5UpcIFRdjfsd/o5mAxDUejNir930ZpGA5crX3Jp6 9buwq7yzh351/UyLmWahOfa9qVd/YxZj0o2f477U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mark Tomlinson , Andy Shevchenko , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 6.13 128/443] gpio: pca953x: Improve interrupt support Date: Thu, 13 Feb 2025 15:24:53 +0100 Message-ID: <20250213142445.548577849@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250213142440.609878115@linuxfoundation.org> References: <20250213142440.609878115@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Tomlinson [ Upstream commit d6179f6c6204f9932aed3a7a2100b4a295dfed9d ] The GPIO drivers with latch interrupt support (typically types starting with PCAL) have interrupt status registers to determine which particular inputs have caused an interrupt. Unfortunately there is no atomic operation to read these registers and clear the interrupt. Clearing the interrupt is done by reading the input registers. The code was reading the interrupt status registers, and then reading the input registers. If an input changed between these two events it was lost. The solution in this patch is to revert to the non-latch version of code, i.e. remembering the previous input status, and looking for the changes. This system results in no more I2C transfers, so is no slower. The latch property of the device still means interrupts will still be noticed if the input changes back to its initial state. Fixes: 44896beae605 ("gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2") Signed-off-by: Mark Tomlinson Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20240606033102.2271916-1-mark.tomlinson@alliedtelesis.co.nz Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-pca953x.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index be4c9981ebc40..d63c1030e6ac0 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -841,25 +841,6 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendin DECLARE_BITMAP(trigger, MAX_LINE); int ret; - if (chip->driver_data & PCA_PCAL) { - /* Read the current interrupt status from the device */ - ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, trigger); - if (ret) - return false; - - /* Check latched inputs and clear interrupt status */ - ret = pca953x_read_regs(chip, chip->regs->input, cur_stat); - if (ret) - return false; - - /* Apply filter for rising/falling edge selection */ - bitmap_replace(new_stat, chip->irq_trig_fall, chip->irq_trig_raise, cur_stat, gc->ngpio); - - bitmap_and(pending, new_stat, trigger, gc->ngpio); - - return !bitmap_empty(pending, gc->ngpio); - } - ret = pca953x_read_regs(chip, chip->regs->input, cur_stat); if (ret) return false; -- 2.39.5