linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Zhang Bo" <zbsdta@126.com>
To: Marcus Folkesson <marcus.folkesson@gmail.com>
Cc: dmitry.torokhov@gmail.com, DRivshin@allworx.com, robh@kernel.org,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	zhang.bo19@zte.com.cn
Subject: Re:Re: [PATCH] Input: matrix_keypad - fix keypad does not response
Date: Sun, 4 Feb 2018 00:24:25 +0800 (CST)	[thread overview]
Message-ID: <718216bd.37a7.1615c7bb222.Coremail.zbsdta@126.com> (raw)
In-Reply-To: <20180203134450.GC707@gmail.com>

At 2018-02-03 21:44:50, "Marcus Folkesson" <marcus.folkesson@gmail.com> wrote:
>> diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
>> index 1f316d66e6f7..13fe51824637 100644
>> --- a/drivers/input/keyboard/matrix_keypad.c
>> +++ b/drivers/input/keyboard/matrix_keypad.c
>> @@ -169,7 +169,8 @@ static void matrix_keypad_scan(struct work_struct *work)
>>  	/* Enable IRQs again */
>>  	spin_lock_irq(&keypad->lock);
>>  	keypad->scan_pending = false;
>> -	enable_row_irqs(keypad);
>> +	if (keypad->stopped == false)
>> +		enable_row_irqs(keypad);
>>  	spin_unlock_irq(&keypad->lock);
>>  }
>>  
>> @@ -202,14 +203,16 @@ static int matrix_keypad_start(struct input_dev *dev)
>>  {
>>  	struct matrix_keypad *keypad = input_get_drvdata(dev);
>>  
>> +	spin_lock_irq(&keypad->lock);
>>  	keypad->stopped = false;
>> -	mb();
>>  
>>  	/*
>>  	 * Schedule an immediate key scan to capture current key state;
>>  	 * columns will be activated and IRQs be enabled after the scan.
>>  	 */
>> -	schedule_delayed_work(&keypad->work, 0);
>> +	if (keypad->scan_pending == false)
>> +		schedule_delayed_work(&keypad->work, 0);
>> +	spin_unlock_irq(&keypad->lock);
>>  
>>  	return 0;
>>  }
>> @@ -218,14 +221,17 @@ static void matrix_keypad_stop(struct input_dev *dev)
>>  {
>>  	struct matrix_keypad *keypad = input_get_drvdata(dev);
>>  
>> +	spin_lock_irq(&keypad->lock);
>>  	keypad->stopped = true;
>> -	mb();
>> -	flush_work(&keypad->work.work);
>>  	/*
>>  	 * matrix_keypad_scan() will leave IRQs enabled;
>>  	 * we should disable them now.
>>  	 */
>> -	disable_row_irqs(keypad);
>> +	if (keypad->scan_pending == false)
>> +		disable_row_irqs(keypad);
>> +	spin_unlock_irq(&keypad->lock);
>> +
>> +	flush_work(&keypad->work.work);
>>  }
>
>
>Hum, I think we should use spin_lock_irqsave/spin_lock_irqrestore
>instead to be on the safe side. 
>I don't see how we could guarantee that irqs is allways enabled when
>calling spin_lock_irq().

spin_lock_irq and  spin_unlock_irq are called in matrix_keypad_stop and matrix_keypad_start
which are in suspend and resume,  they run in process context, matrix_keypad_scan runs in
worker which is in process context also.

  reply	other threads:[~2018-02-03 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-03 12:00 [PATCH] Input: matrix_keypad - fix keypad does not response Zhang Bo
2018-02-03 13:44 ` Marcus Folkesson
2018-02-03 16:24   ` Zhang Bo [this message]
2018-02-03 16:31   ` Zhang Bo

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=718216bd.37a7.1615c7bb222.Coremail.zbsdta@126.com \
    --to=zbsdta@126.com \
    --cc=DRivshin@allworx.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcus.folkesson@gmail.com \
    --cc=robh@kernel.org \
    --cc=zhang.bo19@zte.com.cn \
    /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;
as well as URLs for NNTP newsgroup(s).