mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rafael Mendonca <rafaelmendsr@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jia-Ju Bai <baijiaju1990@gmail.com>,
	"Hans J. Koch" <hjk@hansjkoch.de>,
	Damian Hobson-Garcia <dhobsong@igel.co.jp>
Cc: Rafael Mendonca <rafaelmendsr@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] uio: uio_dmem_genirq: Use non-atomic bit operations in irq config and handling
Date: Fri, 30 Sep 2022 19:40:59 -0300	[thread overview]
Message-ID: <20220930224100.816175-4-rafaelmendsr@gmail.com> (raw)
In-Reply-To: <20220930224100.816175-1-rafaelmendsr@gmail.com>

This finishes the port of the irq configuration and handling from
"uio_pdrv_genirq" to "uio_dmem_genirq". It changes the atomic
bit-manipulation routines to their non-atomic counterparts as we are
already guarding the code by spinlock.

Split out from commit 34cb27528398 ("UIO: Fix concurrency issue").

Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
---
 drivers/uio/uio_dmem_genirq.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index 792c3e9c9ce5..5313307c2754 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -41,6 +41,11 @@ struct uio_dmem_genirq_platdata {
 	unsigned int refcnt;
 };
 
+/* Bits in uio_dmem_genirq_platdata.flags */
+enum {
+	UIO_IRQ_DISABLED = 0,
+};
+
 static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
 {
 	struct uio_dmem_genirq_platdata *priv = info->priv;
@@ -111,7 +116,7 @@ static irqreturn_t uio_dmem_genirq_handler(int irq, struct uio_info *dev_info)
 	 */
 
 	spin_lock(&priv->lock);
-	if (!test_and_set_bit(0, &priv->flags))
+	if (!__test_and_set_bit(UIO_IRQ_DISABLED, &priv->flags))
 		disable_irq_nosync(irq);
 	spin_unlock(&priv->lock);
 
@@ -133,10 +138,10 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)
 
 	spin_lock_irqsave(&priv->lock, flags);
 	if (irq_on) {
-		if (test_and_clear_bit(0, &priv->flags))
+		if (__test_and_clear_bit(UIO_IRQ_DISABLED, &priv->flags))
 			enable_irq(dev_info->irq);
 	} else {
-		if (!test_and_set_bit(0, &priv->flags))
+		if (!__test_and_set_bit(UIO_IRQ_DISABLED, &priv->flags))
 			disable_irq_nosync(dev_info->irq);
 	}
 	spin_unlock_irqrestore(&priv->lock, flags);
-- 
2.34.1


      parent reply	other threads:[~2022-09-30 22:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 22:40 [PATCH 0/3] uio: uio_dmem_genirq: Fix locking issues " Rafael Mendonca
2022-09-30 22:40 ` [PATCH 1/3] uio: uio_dmem_genirq: Fix missing unlock in irq configuration Rafael Mendonca
2022-09-30 22:40 ` [PATCH 2/3] uio: uio_dmem_genirq: Fix deadlock between irq config and handling Rafael Mendonca
2022-09-30 22:40 ` Rafael Mendonca [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220930224100.816175-4-rafaelmendsr@gmail.com \
    --to=rafaelmendsr@gmail.com \
    --cc=baijiaju1990@gmail.com \
    --cc=dhobsong@igel.co.jp \
    --cc=gregkh@linuxfoundation.org \
    --cc=hjk@hansjkoch.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®