linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aniroop Mathur <aniroop.mathur@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Aniroop Mathur <a.mathur@samsung.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [v8]Input: evdev: fix bug of dropping valid packet after syn_dropped event
Date: Sat, 23 Jan 2016 23:29:29 +0530	[thread overview]
Message-ID: <CADYu30_xbT5sA1J04-JRxcC_Ky9N_iNoqknQXX-CUooBdF1gbw@mail.gmail.com> (raw)
In-Reply-To: <20160121191725.GA39970@dtor-ws>

Hi Mr. Torokhov,

On Fri, Jan 22, 2016 at 12:47 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Anoroop,
>
> On Thu, Jan 21, 2016 at 11:07:19PM +0530, Aniroop Mathur wrote:
>> If last event dropped in the old queue was EVi_SYN/SYN_REPORT, then lets
>> generate EV_SYN/SYN_REPORT immediately after queing EV_SYN/SYN_DROPPED
>> so that clients would not ignore next valid full packet events.
>>
>> Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
>> ---
>>  drivers/input/evdev.c | 46 ++++++++++++++++++++++++++++++++++------------
>>  1 file changed, 34 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
>> index e9ae3d5..821b68a 100644
>> --- a/drivers/input/evdev.c
>> +++ b/drivers/input/evdev.c
>> @@ -156,7 +156,12 @@ static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
>>  static void __evdev_queue_syn_dropped(struct evdev_client *client)
>>  {
>>       struct input_event ev;
>> +     struct input_event *last_ev;
>>       ktime_t time;
>> +     unsigned int mask = client->bufsize - 1;
>> +
>> +     /* capture last event stored in the buffer */
>> +     last_ev = &client->buffer[(client->head - 1) & mask];
>
> I have still the same comment. How do you know that event at last_ev
> position is in fact valid and unconsumed yet event. Also, you need to
> figure out not only if queue contains last SYN event, but also to handle
> the case where the queue is empty and client has consumed either full or
> partial packet at the time you are queueing the drop.
>

Could you please explain what you mean exactly so that I could answer it
properly?

>From what I understood, it seems to me that there is no problem related to
validity, unconsumption, empty queue, full/partial packet.
I would like to explain for clock change request case so that you can know
my understanding for your question.

Clock change request case:

1.1 About last event being valid and unconsumed:
We flush buffer and queue syn_dropped only when buffer is not empty. So there
will be always be atleast one event in buffer that is not consumed and is
ofcourse valid.

1.2 About queue is empty
If not empty, we do not flush or add syn_dropped at all.

1.3 About consumption of full or partial packet
If client has consumed full packet, then buffer will look like,
... X Y S(consumed) ... X Y S
As we always store packets keeping buffer lock and not single events, so there
will always be syn_report in the end.
If syn_dropped is queued here, then queing syn_report is fine.
If client has consumed partial packet,  then buffer will look like,
... X(consumed) Y S ... S
If syn_dropped is queued here, then it is fine to queue syn_report because
now new X Y will be reported by driver, and so client will consume new X and Y
and that old X will be replaced with new X and this new packet will be sent by
client to application. Obviously, client never sends partial events to
application and send data packet by packet.
So I do not see any trouble here related to partial or full packet.

> Also please enumerate what changes you done between version n and n+1 so
> I do not have to compare them line by line trying to figure it out
> myself.
>

Difference from v5:
Made a mistake about head index in v5.
Corrected in v8.

evdev_set_clk_type:
- client->packet_head = client->head = client->tail;
+ client->packet_head = client->tail = client->head;

__pass_event:
- client->tail = (client->head - 2) & (client->bufsize - 1);
+ client->head = (client->head - 1) & mask;
+ client->packet_head = client->tail = client->head;
+ __evdev_queue_syn_dropped(client);

v6:
Made change only for clock change and pass event function.
Do not included change for evdev_flush_queue as I was not sure.
But now I think it is okay for evdev_flush_queue also.
As I am not 100% sure, so sent v6 for that.

v7:
please ignore it.

Thanks,
Aniroop Mathur

> Thanks.
>
> --
> Dmitry

  reply	other threads:[~2016-01-23 17:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 17:37 [PATCH] [v8]Input: evdev: fix bug of dropping valid packet after syn_dropped event Aniroop Mathur
2016-01-21 19:17 ` Dmitry Torokhov
2016-01-23 17:59   ` Aniroop Mathur [this message]
2016-01-23 18:39     ` Dmitry Torokhov
2016-01-23 20:05       ` Aniroop Mathur
2016-01-25 18:01         ` Aniroop Mathur
2016-02-11 18:01           ` Aniroop Mathur
2016-10-04 18:38         ` Aniroop Mathur

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=CADYu30_xbT5sA1J04-JRxcC_Ky9N_iNoqknQXX-CUooBdF1gbw@mail.gmail.com \
    --to=aniroop.mathur@gmail.com \
    --cc=a.mathur@samsung.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).