From nobody Sat Nov 23 15:03:36 2024 Received: from fallback3.i.mail.ru (fallback3.i.mail.ru [79.137.243.69]) (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 D50AEE571 for ; Tue, 19 Nov 2024 06:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.137.243.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731996072; cv=none; b=Q1vZClb++Ye9jRVryPFSwBzuq/KmbK20QX4AFP3v2SKfnuNMDMr7EOVACDEWThBQXiXBlZpbSoeX0gbvPYGTBS+QPJCM1Gv++XZxgNf2TeTlamsgXt7z/uv7V+PpaIkz1CzzwqXGpwIbwZcKDhtV9uAptUd2U9xMd58kdbwsdug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731996072; c=relaxed/simple; bh=Wd/o3Eg8v6Lf0ZY/iNBPYwroe2Z7LT7/DxVhswkRojc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cweKcaiDwJGSL6I0cjRXrpQ0SmYfaEAe9mN6vmhGfnG8QJaww0aKFa0X2DeZlKRJV+RUOK3tPwNCyGm6B9/YR4eYaST+07UIW/4tfoo3ODKU3o3bPR1M4Luzk3YVf/M/NL5OG6/uLvVQIim8tTaWrcedYMWfXP0BCNZK5K+ktek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=inbox.ru; spf=pass smtp.mailfrom=inbox.ru; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b=TT4Au4De; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b=oPSW/1uZ; arc=none smtp.client-ip=79.137.243.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=inbox.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inbox.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b="TT4Au4De"; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b="oPSW/1uZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=inbox.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=rjcP5sJke5Bx8/jRJViVnXrJKZoYgTkbBFdx99efjns=; t=1731996069;x=1732086069; b=TT4Au4De1Iw8S7ZkMqbP6oB8+MArIHFf55NBwg57BfTNGy1DxnxYf+Z2xrXAjmXHZUp8P0aX8kCEmB+6HznynEaQKz4xwL6ETrdHdDSJTyO4zk2JOFf+jLdQit5xjIMMsE2vAneZQEYnheOhhgE3kxYNFsi3SuyZR2xlkLZchFzh6DjG7j8jCGWJL4CSdxhnlASBtb+pbAZ0U4SGjyYdEH3mx/lzEezYrpRvXNdQ7q10j+A46gTz+T0zCmwH8dnipKkG7ef6/aZ3R/osq32++GMVieWdaX8DL1CeYGGZnDqWpkOC0ZVsoxivDI4SqzPVM/iAwwzxZD9IVeh+hTJ4Mg==; Received: from [10.113.163.34] (port=41098 helo=smtp33.i.mail.ru) by fallback3.i.mail.ru with esmtp (envelope-from ) id 1tDHIM-008D6N-71 for linux-kernel@vger.kernel.org; Tue, 19 Nov 2024 09:01:02 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=inbox.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:From:Sender:Reply-To:To:Cc:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive: X-Cloud-Ids:Disposition-Notification-To; bh=rjcP5sJke5Bx8/jRJViVnXrJKZoYgTkbBFdx99efjns=; t=1731996062; x=1732086062; b=oPSW/1uZjkGhGIOotUiURu+wbQSds9r3NBNDA+y0kZZD/ZSjVIGDWcP0GzEUGbP1vSTc7471THv P+36ed1bD7n/FCDGGjc34api+adTD6QzHX+Uf4tpdt1T6Hjqt71hzs6QGB/+pah+AB3Z9+8TwR8lq 4dZS/XuOIui56eQdZ370WNXNP9kAIfvx1+jsZPjLrIpsPnkVJoT3FvFTw8Rp17gLivSkmFdgV8piI CBKeNWRVmwgUNf4O9ySKCfhxPauKyd0ngaaGiZwvNIWzkzb7gLhgnsiS7GM1Wn1KhJBtuAftBjdcv 80NUv2SdjVbxwtwMXT/o3qB3HwNpzKhbDnSA==; Received: by exim-smtp-5b7bfccf9f-rgnt4 with esmtpa (envelope-from ) id 1tDHI7-00000000JMW-429F; Tue, 19 Nov 2024 09:00:48 +0300 From: Maxim Kochetkov To: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Cc: Maxim Kochetkov Subject: [PATCH 1/2] regmap-irq: Introduce regmap_irq_ack() helper Date: Tue, 19 Nov 2024 08:59:38 +0300 Message-ID: <20241119055944.363498-2-fido_max@inbox.ru> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241119055944.363498-1-fido_max@inbox.ru> References: <20241119055944.363498-1-fido_max@inbox.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95367647A2C12583F2C8F5ECE26118F812B5164FFEEF29B9C182A05F538085040C3BECA2E62DB8D6C3DE06ABAFEAF670597F0BB7027BAB7F2041C3D1E536A63B8B242013FB95F71DC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE782A779A89F7D69B2C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE75CCA5FD4E6ACD987EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BC08E230531AC9C90DC8285596FAF18CBF9B4888072D33C4E62A5583CAADFA6AB1DF9E95F17B0083B26EA987F6312C9EC33AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583C09775C1D3CA48CFF7ED4D6813B5CA04117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE729FBA39629FC1B7C9FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F7900637F9425D8FA97DB4396D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AD0424077D726551EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5F89C270203F026835002B1117B3ED6961852474EDB0F8EA3ED71F038FC046993823CB91A9FED034534781492E4B8EEADF12279BA039A6965C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF151B457848D89130C4327175A013C49FA4C771D07D42070DC4505476F26ACC28B469278E65BD125A0C86AA3C630759CE1BD3C7B64CC616FC9ED4AC555409C695E0C3823DA75A7CD49F49EEF1215E7BEC913E6812662D5F2A17D6C1CDD2003EB8E03787203701020945C72C348FB7EED3 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojeF9RWNEuWy9RVtTuDDWa8w== X-Mailru-Sender: 689FA8AB762F739381B31377CF4CA2191638FFDBE392D4E30F923AB1F912189395F16D66E40174C790DE4A6105A3658D481B2AED7BCCC0A49AE3A01A4DD0D55C6C99E19F044156F45FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok X-7564579A: 646B95376F6C166E X-77F55803: 6242723A09DB00B454E1DAF28AA7D56D7BEFEAADD8CAC7ACF3140A44FEE55A3C049FFFDB7839CE9EBEC99E045F597705D777186230FAA12E73E8F311200A813C9939EE44C735EA39 X-7FA49CB5: 0D63561A33F958A5B00FA66E97D01679A2A51FEB30ABE44C475967446E671DAECACD7DF95DA8FC8BD5E8D9A59859A8B64A2C4B6BA9DFC510CC7F00164DA146DAFE8445B8C89999728AA50765F7900637093CFC3DF75F24619FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3145EAEB5DAD25052CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA522CA9DD8327EE4930A3850AC1BE2E735B58781B77DE60D36C4224003CC83647689D4C264860C145E X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojeF9RWNEuWy+Y6l25xiwYOg== X-Mailru-MI: 8000000000000800 X-Mras: Ok Content-Type: text/plain; charset="utf-8" We have a lot of places where we do interrupt acknowledgment in regmap-irq. This code is just copy-pasted at least 3 times. So let's move it to the regmap_irq_ack() helper. Signed-off-by: Maxim Kochetkov --- drivers/base/regmap/regmap-irq.c | 88 ++++++++++++-------------------- 1 file changed, 32 insertions(+), 56 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-= irq.c index 0bcd81389a29..c097f8ca17b7 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -76,6 +76,32 @@ static void regmap_irq_lock(struct irq_data *data) mutex_lock(&d->lock); } =20 +static int regmap_irq_ack(struct regmap_irq_chip_data *d, unsigned int ack= , int bank) +{ + int ret =3D 0; + u32 reg; + + if (d->chip->ack_base || d->chip->use_ack) { + reg =3D d->get_irq_reg(d, d->chip->ack_base, bank); + + /* some chips ack by write 0 */ + if (d->chip->ack_invert) + ret =3D regmap_write(d->map, reg, ~ack); + else + ret =3D regmap_write(d->map, reg, ack); + if (d->chip->clear_ack) { + if (d->chip->ack_invert && !ret) + ret =3D regmap_write(d->map, reg, UINT_MAX); + else if (!ret) + ret =3D regmap_write(d->map, reg, 0); + } + if (ret !=3D 0) + dev_err(d->map->dev, "Failed to ack 0x%x: %d\n", + reg, ret); + } + return ret; +} + static void regmap_irq_sync_unlock(struct irq_data *data) { struct regmap_irq_chip_data *d =3D irq_data_get_irq_chip_data(data); @@ -156,24 +182,8 @@ static void regmap_irq_sync_unlock(struct irq_data *da= ta) * OR if there is masked interrupt which hasn't been Acked, * it'll be ignored in irq handler, then may introduce irq storm */ - if (d->mask_buf[i] && (d->chip->ack_base || d->chip->use_ack)) { - reg =3D d->get_irq_reg(d, d->chip->ack_base, i); - - /* some chips ack by write 0 */ - if (d->chip->ack_invert) - ret =3D regmap_write(map, reg, ~d->mask_buf[i]); - else - ret =3D regmap_write(map, reg, d->mask_buf[i]); - if (d->chip->clear_ack) { - if (d->chip->ack_invert && !ret) - ret =3D regmap_write(map, reg, UINT_MAX); - else if (!ret) - ret =3D regmap_write(map, reg, 0); - } - if (ret !=3D 0) - dev_err(d->map->dev, "Failed to ack 0x%x: %d\n", - reg, ret); - } + if (d->mask_buf[i]) + regmap_irq_ack(d, d->mask_buf[i], i); } =20 for (i =3D 0; i < d->chip->num_config_bases; i++) { @@ -469,25 +479,8 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) for (i =3D 0; i < data->chip->num_regs; i++) { data->status_buf[i] &=3D ~data->mask_buf[i]; =20 - if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) { - reg =3D data->get_irq_reg(data, data->chip->ack_base, i); - - if (chip->ack_invert) - ret =3D regmap_write(map, reg, - ~data->status_buf[i]); - else - ret =3D regmap_write(map, reg, - data->status_buf[i]); - if (chip->clear_ack) { - if (chip->ack_invert && !ret) - ret =3D regmap_write(map, reg, UINT_MAX); - else if (!ret) - ret =3D regmap_write(map, reg, 0); - } - if (ret !=3D 0) - dev_err(map->dev, "Failed to ack 0x%x: %d\n", - reg, ret); - } + if (data->status_buf[i]) + regmap_irq_ack(data, data->status_buf[i], i); } =20 for (i =3D 0; i < chip->num_irqs; i++) { @@ -837,26 +830,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *f= wnode, if (chip->status_invert) d->status_buf[i] =3D ~d->status_buf[i]; =20 - if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) { - reg =3D d->get_irq_reg(d, d->chip->ack_base, i); - if (chip->ack_invert) - ret =3D regmap_write(map, reg, - ~(d->status_buf[i] & d->mask_buf[i])); - else - ret =3D regmap_write(map, reg, - d->status_buf[i] & d->mask_buf[i]); - if (chip->clear_ack) { - if (chip->ack_invert && !ret) - ret =3D regmap_write(map, reg, UINT_MAX); - else if (!ret) - ret =3D regmap_write(map, reg, 0); - } - if (ret !=3D 0) { - dev_err(map->dev, "Failed to ack 0x%x: %d\n", - reg, ret); + if (d->status_buf[i]) + if (regmap_irq_ack(d, d->status_buf[i] & d->mask_buf[i], i)) goto err_alloc; - } - } } =20 /* Wake is disabled by default */ --=20 2.45.2 From nobody Sat Nov 23 15:03:36 2024 Received: from fallback22.i.mail.ru (fallback22.i.mail.ru [79.137.243.74]) (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 4FBB62A1B2 for ; Tue, 19 Nov 2024 06:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.137.243.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731996074; cv=none; b=GHEivPQOmSZurZCrAIPD28rHr4wSep/b0UCRSRuhutBF1XEHw6NDifSHaOOzSk1fF5MUUzcFmiaDYHY0iS2KdvKHrfaMel77CPqNuZ+Ydu52vjyWJPFpUa6EFK04DkdxlfulgrtylR/Nvs6eSvY8xtuvWOpdUMuRYZj3iQiz2Ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731996074; c=relaxed/simple; bh=apHKcHLqJmogJMFjudimgNMs4nVygEUyT5DslF4yG0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oJ47k9Jgje1LTWCsvYcyrBO3yIhMa/kUHKOs4D4OSbn9GsYM4fWDdkJahK+8CgsaXXs8Nb8m8krWcZeWJoK0EHYUHwMO+hdZUyxcF4hRfC0+X04iofOUPaoHtqGakAD7hyPGS0P9/VqMzNhOhH4jEup6LhWvxsyYS9rdDBSdSks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=inbox.ru; spf=pass smtp.mailfrom=inbox.ru; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b=nSOP4PA+; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b=jCPwslte; arc=none smtp.client-ip=79.137.243.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=inbox.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inbox.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b="nSOP4PA+"; dkim=pass (2048-bit key) header.d=inbox.ru header.i=@inbox.ru header.b="jCPwslte" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=inbox.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=8GFBmCRcLXvy29RCAcJD3cZiaenC8Oz8zUDcl1SnLWc=; t=1731996072;x=1732086072; b=nSOP4PA+qhQsiFVe7WfKc9uVb5VfQMIRASs1+ejKpYND08VDiGuZlrMQx3yY/tO9+1/qNPpPFFskSeC/ZnMmwX3ZiOljza7AG2+je+neEy/jhKlHz6u0t5HWxl5DMD8sIUS00kASmWjIlg7X1Bfg4u+cDYqwqGESsW+h1DuTH4F4VBnxxMs85rJdOI7Smp7dFLra6Wm3oYN17kfXXYKfyJADNjI97NM7Zk075IKa/ZwkApKnGto3ipYGBdDRFWwQOoXrxfH7QezYw0GLg/rHPlieXDafy6JDUpeer8m8BTVZHoPLMPtWPpdX/ujHtTHCydG7XThUUahPberVvblckA==; Received: from [10.113.232.98] (port=53430 helo=smtp50.i.mail.ru) by fallback22.i.mail.ru with esmtp (envelope-from ) id 1tDHIO-00444f-4c for linux-kernel@vger.kernel.org; Tue, 19 Nov 2024 09:01:04 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=inbox.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:From:Sender:Reply-To:To:Cc:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive: X-Cloud-Ids:Disposition-Notification-To; bh=8GFBmCRcLXvy29RCAcJD3cZiaenC8Oz8zUDcl1SnLWc=; t=1731996064; x=1732086064; b=jCPwslteYor3Ge8Tp75b9Ff1G0UVAFiV7buuRyzYzgsIOWFe6WWHYJbygE74hYd4UfnYFNWkU5Y jRe4hT53h9dqVYMYdBljpMfINYQ5XTGGIYl/YzHzWM2SSEpcCxmVXy7VMxNgEVf/ueqSvfNrQbdt+ Z/jmpDyqtO6iHZX/r29NgU0xWeUMD9RzzKqINqRjnegEMB8Tk+wDjGIrMWGwPg9isuUkazsy1/ue3 lpwBoTB4ski1unPSM7DRuDNVcRMe1eecigod7SZWltvL/Ql/X9V8WIfGagchDYRoUp7LbtpywDhph L4Z8Z5p1heBaZau2sBmGXsdKWpuWCN0VNs3w==; Received: by exim-smtp-5b7bfccf9f-rgnt4 with esmtpa (envelope-from ) id 1tDHI8-00000000JMW-2WB5; Tue, 19 Nov 2024 09:00:49 +0300 From: Maxim Kochetkov To: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Cc: Maxim Kochetkov Subject: [PATCH 2/2] regmap-irq: Introduce ack_after_handle option Date: Tue, 19 Nov 2024 08:59:39 +0300 Message-ID: <20241119055944.363498-3-fido_max@inbox.ru> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241119055944.363498-1-fido_max@inbox.ru> References: <20241119055944.363498-1-fido_max@inbox.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95367647A2C12583FC84D6A7BCBB95E87B061537DBE0350A1182A05F53808504001BDAB3D342F957C3DE06ABAFEAF67057FF8EBAF34905F90041C3D1E536A63B80C8629FDE0E8EB2A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76C0A440987CA342DC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7C4A7E4C0BFE8628DEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BC08E230531AC9C905F0383CB38F85E33F9B4888072D33C4E2FD8A3412BDB16DE1DF9E95F17B0083B26EA987F6312C9EC9ECD01F8117BC8BEA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE786A06C54C89EF27D9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C309F854029C6BD0DA117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AD0424077D726551EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5CED44A98B12954F45002B1117B3ED6961718D8BD22F31902FB820E9FE7BD014C823CB91A9FED034534781492E4B8EEAD6A17C1D737525568C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFBCC6794485A61604B4FFD266A4A2F56480BE3F46EC6EEC2A1DC63FBA5A6EA287BC84317DE62561530C86AA3C630759CE19B7BBB39BAD0A049ED4AC555409C695C326C42D854A91EC9F49EEF1215E7BEC913E6812662D5F2A17D6C1CDD2003EB8E03787203701020945C72C348FB7EED3 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojeF9RWNEuWy8pOZdwT8l+uw== X-Mailru-Sender: 689FA8AB762F739381B31377CF4CA219A821A83ADB0E90270F923AB1F9121893B9D65CFEDD0211D490DE4A6105A3658D481B2AED7BCCC0A49AE3A01A4DD0D55C6C99E19F044156F45FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok X-7564579A: 646B95376F6C166E X-77F55803: 6242723A09DB00B454E1DAF28AA7D56D7BEFEAADD8CAC7AC47343892CD1EF229049FFFDB7839CE9EBEC99E045F5977055A40751BE1FB3B6EF1B73C6108DC0E2FD34AB8955D39148F X-7FA49CB5: 0D63561A33F958A59C7989A328CFE985A52536C415C2E329ADD7CDBF86DB1811CACD7DF95DA8FC8BD5E8D9A59859A8B6836F5ADB0B4F9314CC7F00164DA146DAFE8445B8C89999728AA50765F7900637F8E7BBE36542B4C0389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC802A3942546F0CC5EF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA775ECD9A6C639B01B78DA827A17800CE7D699F3A2029486C7731C566533BA786AA5CC5B56E945C8DA X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojeF9RWNEuWy+mBaJ0AL64rw== X-Mailru-MI: 8000000000000800 X-Mras: Ok Content-Type: text/plain; charset="utf-8" Some interrupt controllers may have simple level interrupt detection without enable/disable functionality. Mask/unmask simply disables interrupt signaling to the upstream chip. If we try to ack these interrupts before handling, we will get a false interrupt with empty status. So the only one possible way to handle this interrupts is to ack them after handling. Signed-off-by: Maxim Kochetkov --- drivers/base/regmap/regmap-irq.c | 8 +++++++- include/linux/regmap.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-= irq.c index c097f8ca17b7..2400d2efb1e9 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -479,7 +479,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) for (i =3D 0; i < data->chip->num_regs; i++) { data->status_buf[i] &=3D ~data->mask_buf[i]; =20 - if (data->status_buf[i]) + if (!chip->ack_after_handle && data->status_buf[i]) regmap_irq_ack(data, data->status_buf[i], i); } =20 @@ -491,6 +491,12 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) } } =20 + if (chip->ack_after_handle) + for (i =3D 0; i < data->chip->num_regs; i++) { + if (data->status_buf[i]) + regmap_irq_ack(data, data->status_buf[i], i); + } + exit: if (chip->handle_post_irq) chip->handle_post_irq(chip->irq_drv_data); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index fd41baccbf3e..1d31e066ae59 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1581,6 +1581,7 @@ struct regmap_irq_chip_data; * @use_ack: Use @ack register even if it is zero. * @ack_invert: Inverted ack register: cleared bits for ack. * @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts. + * @ack_after_handle: Use this to ack interrupts after handling. * @status_invert: Inverted status register: cleared bits are active inter= rupts. * @wake_invert: Inverted wake register: cleared bits are wake enabled. * @type_in_mask: Use the mask registers for controlling irq type. Use thi= s if @@ -1644,6 +1645,7 @@ struct regmap_irq_chip { unsigned int use_ack:1; unsigned int ack_invert:1; unsigned int clear_ack:1; + unsigned int ack_after_handle:1; unsigned int status_invert:1; unsigned int wake_invert:1; unsigned int type_in_mask:1; --=20 2.45.2