mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: oe-kbuild@lists.linux.dev,
	"Ronald Tschalär" <ronald@innovation.ch>,
	lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Subject: Re: drivers/input/keyboard/applespi.c:1833 applespi_drain_writes() warn: mixing irqsave and irq
Date: Mon, 1 Jul 2024 10:14:00 -0700	[thread overview]
Message-ID: <ZoLj2LL0NzdS1gZL@google.com> (raw)
In-Reply-To: <3e789ab9-ebfc-40a2-b90d-b8b55e0cfaac@suswa.mountain>

Hi Dan,

On Mon, Jul 01, 2024 at 06:30:38PM +0200, Dan Carpenter wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   6d6444ba82053c716fb5ac83346202659023044e
> commit: 038b1a05eae6666b731920e46f47d8e2332e07ff Input: add Apple SPI keyboard and trackpad driver
> config: x86_64-randconfig-161-20240628 (https://download.01.org/0day-ci/archive/20240628/202406280337.1Av9qm8V-lkp@intel.com/config)
> compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202406280337.1Av9qm8V-lkp@intel.com/
> 
> smatch warnings:
> drivers/input/keyboard/applespi.c:1833 applespi_drain_writes() warn: mixing irqsave and irq
> drivers/input/keyboard/applespi.c:1845 applespi_drain_reads() warn: mixing irqsave and irq
> 
> vim +1833 drivers/input/keyboard/applespi.c
> 
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1826  static void applespi_drain_writes(struct applespi_data *applespi)
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1827  {
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1828  	unsigned long flags;
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1829  
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1830  	spin_lock_irqsave(&applespi->cmd_msg_lock, flags);
> 
> _irqsave() sort of implies that potentially the caller has disabled IRQs,
> otherwise we would use spin_lock_irq() if we knew they hadn't disabled
> IRQs.
> 
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1831  
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1832  	applespi->drain = true;
> 038b1a05eae666 Ronald Tschalär 2019-07-15 @1833  	wait_event_lock_irq(applespi->drain_complete, !applespi->write_active,
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1834  			    applespi->cmd_msg_lock);
> 
> This will renable IRQs briefly and then disable them again.
> 
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1835  
> 038b1a05eae666 Ronald Tschalär 2019-07-15  1836  	spin_unlock_irqrestore(&applespi->cmd_msg_lock, flags);
> 
> This will set them back to how they were at the start of the function.
> 
> The issue is that if the caller really wanted IRQs disabled, then it's
> not necessarilly a good idea to enable them at all in the
> wait_event_lock_irq() macro.  I suspect that in real life no callers
> disable IRQs so it's not an issue.  But anyway, that's what the warning
> is about.

applespi_drain_writes() and applespi_drain_reads() are only called from
the process context with interrupts enabled, so it looks like we should
simply change spin_lock_irqsave() to spin_lock_irq().

I am taking patches ;)

Thanks.

-- 
Dmitry

  reply	other threads:[~2024-07-01 17:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 16:30 Dan Carpenter
2024-07-01 17:14 ` Dmitry Torokhov [this message]
2024-07-01 17:21   ` Dan Carpenter

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=ZoLj2LL0NzdS1gZL@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=ronald@innovation.ch \
    /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®