From: Aviv Levinson <levinson.aviv@gmail.com>
To: gregkh@linuxfoundation.org
Cc: dtwlin@gmail.com, johan@kernel.org, elder@kernel.org,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org,
Aviv Levinson <levinson.aviv@gmail.com>
Subject: [PATCH v2] staging: greybus: uart: convert idr to xarray
Date: Thu, 12 Nov 2026 18:05:46 +0200 [thread overview]
Message-ID: <20261112160546.27094-1-levinson.aviv@gmail.com> (raw)
In-Reply-To: <2026111219-guacamole-quality-2ecf@gregkh>
The legacy IDR API is deprecated in favor of the modern XArray API.
Convert the tty_minors IDR to an XArray.
To prevent locking the entire gb_tty object while loading the minor,
switch IDR to XArray and use the internal XArray's spinlock (xa_lock).
To respect TTY encapsulation, use tty_port_get()
instead of direct kref_get_unless_zero().
Signed-off-by: Aviv Levinson <levinson.aviv@gmail.com>
---
drivers/staging/greybus/uart.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 2b1a5d4671dd..054bdc232942 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -339,24 +339,21 @@ static struct gb_tty *get_gb_by_minor(unsigned int minor)
{
struct gb_tty *gb_tty;
- rcu_read_lock();
+ xa_lock(&tty_minors);
gb_tty = xa_load(&tty_minors, minor);
- if (gb_tty) {
- if (!kref_get_unless_zero(&gb_tty->port.kref))
- gb_tty = NULL;
- }
- rcu_read_unlock();
+ if (gb_tty)
+ tty_port_get(&gb_tty->port);
+ xa_unlock(&tty_minors);
- if (gb_tty) {
- mutex_lock(&gb_tty->mutex);
- if (gb_tty->disconnected) {
- mutex_unlock(&gb_tty->mutex);
- tty_port_put(&gb_tty->port);
- gb_tty = NULL;
- } else {
- mutex_unlock(&gb_tty->mutex);
- }
+ if (!gb_tty)
+ return NULL;
+ mutex_lock(&gb_tty->mutex);
+ if (gb_tty->disconnected) {
+ mutex_unlock(&gb_tty->mutex);
+ tty_port_put(&gb_tty->port);
+ return NULL;
}
+ mutex_unlock(&gb_tty->mutex);
return gb_tty;
}
--
2.53.0
prev parent reply other threads:[~2026-11-12 16:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 18:23 [PATCH] staging: greybus: uart: replace IDR with XArray Aviv Levinson
2026-11-12 12:37 ` Greg KH
2026-11-12 16:05 ` Aviv Levinson
2026-11-12 16:05 ` Aviv Levinson [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=20261112160546.27094-1-levinson.aviv@gmail.com \
--to=levinson.aviv@gmail.com \
--cc=dtwlin@gmail.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/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®