Received: by 10.223.176.46 with SMTP id f43csp1346479wra; Fri, 19 Jan 2018 10:09:41 -0800 (PST) X-Google-Smtp-Source: ACJfBotpKxbZ0Ca3IPKoxoxHnEO5jSTnTKUAkRvqFtoh+Nz6aO3SdAQcNlFyVKocD/Nvq4LSqA98 X-Received: by 10.99.190.15 with SMTP id l15mr5937358pgf.197.1516385380969; Fri, 19 Jan 2018 10:09:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516385380; cv=none; d=google.com; s=arc-20160816; b=FXc4OO6JBRf3W5IpaFYumJBmZR6PFVlhfKAaOrPga6Qln2/wh7MSxolyd2Ft4ySlZ5 cEzPVnQqgS4X9/AsHGHQOk3l8eut+ExYKuBLor6evkBmlfo047X2Pe75wiGo7J70lbcB 5uWlHUc9dSWfNUDNieF+fGMSbNZ9cC9QvGXhRt2tjfnA+HjzvJe4w3QYlWTqOmW/3Jb9 L/hvkhSEviQYeFwPTTiwOov83HfNljBaUSn9o791Hg+WQSI2XFncPRfKkfjzuCWwAjMr cjqhrVEH8Hj+uTPgHximfCNaUT50dNzeGVmz8YnpzQMquIdOXinw2XzbqyVoUhY0WrlK DPsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=fe9/Swp0m1+Wxh/abBr2DUhz8Eza8AnF4jxU52BO1tI=; b=hWTdlWvVBXozgOseune/juhWzkCL41FxLyKrD3KKiAPArjl8Xkk5+MZUUlmYCvFs4X Cnl06aD+HvHZBttIMDRzhE90Nj7Eo8S0W+DRGKb8iPVvfSkHDjHzyy3IUNFlGjh24vEC slQ0lbQXROi9JybgDWtlWeNJh7WuI1pzRK/B+PqnQHnTB3Wt8ElyTSLKfuyZtoZW3Dxv l/4CR8pKvRQ+XR6prNBX+owjaqZ4Vh1bFnICoQdRgqnqVRYmXsa7aict1z0H03blcgFU Kfy43QAgj3OdXNCk7sx0U0B031f5QyACpPOk72KeRooxT6h0m5DCLaXRhdblSBgSAhXJ VVfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lj9YtTLj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si9993782pfd.57.2018.01.19.10.09.26; Fri, 19 Jan 2018 10:09:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lj9YtTLj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932166AbeASSI4 (ORCPT + 99 others); Fri, 19 Jan 2018 13:08:56 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:41733 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755899AbeASSIu (ORCPT ); Fri, 19 Jan 2018 13:08:50 -0500 Received: by mail-qt0-f195.google.com with SMTP id i1so5907936qtj.8; Fri, 19 Jan 2018 10:08:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=fe9/Swp0m1+Wxh/abBr2DUhz8Eza8AnF4jxU52BO1tI=; b=lj9YtTLjQFxwjk7RwACwhA90AmIKeegWvuoQWrzDpEt9u9NcJ1xJmTxCBZ4gAID8Tl 7dJSxef67g0eBQakt9wKJ7I3RPhBKp2ch+Hg7lQFLMBhMxmnUh9mEO6q0UUv/avUyiI5 6ccwfXON0k9hyn2h1tvsWL5AqBcIcE9nKVAk3h64EXcgOMIpc8JZpijwl5Y46beJ/+tr DbC6KQev8taeD6hxEgKjAt2OCvi33rF77FryX+fPBv4J1Bh6L7qrg2iKdOYEZ3XXKnNc KSzXhSShasLNfl7x1COukQFViT1b21EmzrELm4awOqH1Vd/8AMU18jrA+txfJtXIemhS bKyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=fe9/Swp0m1+Wxh/abBr2DUhz8Eza8AnF4jxU52BO1tI=; b=A9AFF2WzZt4TNhP7UT0lDBINgA+H793Dvi26SPcBOXAK98uzxdrxMBK5M1JOT/xeFD mjnRWX2kofrFQpOz66EM4+rCuw+dHWJbpGjfWbUkxUy/Jx1MOkOOQisD+nhUkuQc6xVA 0hzp1Z7/4eJGNdJlY0yZBXZPKX8y8Z/RsXJkDUSFIp7/6NJl6O1h4pEuFMxt6fZ3lYRE JC4iWS4gv1XW4waiS++qGb56zz5p3YS0Lc21B6s7ZLJtcSAhNHTva/t5gKKVnMXo5bpP qq0RATug+bDExSL8mizp1g2ysqyyEeATtrR10oCkHl1860DFgEkoj5ovFRE/Ja28vE3z a4xQ== X-Gm-Message-State: AKwxytfmdIpuATceuOeiYeRGqeZfTPiAC6y4ttvwQoGb/fBbcscae2CW 74Gyc3Ek22pWYpfQUWeoFxY= X-Received: by 10.200.63.197 with SMTP id v5mr48625899qtk.200.1516385329320; Fri, 19 Jan 2018 10:08:49 -0800 (PST) Received: from dhcp-10-20-1-30.bss.redhat.com ([144.121.20.162]) by smtp.gmail.com with ESMTPSA id k7sm7679038qkk.70.2018.01.19.10.08.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jan 2018 10:08:48 -0800 (PST) Message-ID: <1516385327.2814.4.camel@gmail.com> Subject: Re: [PATCH 2/3] Input: synaptics_rmi4 - unmask F03 interrupts when port is opened From: thatslyude@gmail.com To: Dmitry Torokhov , Benjamin Tissoires , Damjan Georgievski Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Duggan , stable@vger.kernel.org Date: Fri, 19 Jan 2018 13:08:47 -0500 In-Reply-To: <20180119004955.247190-3-dmitry.torokhov@gmail.com> References: <20180119004955.247190-1-dmitry.torokhov@gmail.com> <20180119004955.247190-3-dmitry.torokhov@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.4 (3.26.4-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Looks good to me. Reviewed-by: Lyude Paul On Thu, 2018-01-18 at 16:49 -0800, Dmitry Torokhov wrote: > Currently we register the pass-through serio port when we probe the F03 RMI > function, and then, in sensor configure phase, we unmask interrupts. > Unfortunately this is too late, as other drivers are free probe devices > attached to the serio port as soon as it is probed. Because interrupts are > masked, the IO times out, which may result in not being able to detect > trackpoints on the pass-through port. > > To fix the issue we implement open() and close() methods for the > pass-through serio port and unmask interrupts from there. We also move > creation of the pass-through port form probe to configure stage, as RMI > driver does not enable transport interrupt until all functions are probed > (we should change this, but this is a separate topic). > > We also try to clear the pending data before unmasking interrupts, because > some devices like to spam the system with multiple 0xaa 0x00 announcements, > which may interfere with us trying to query ID of the device. > > Fixes: c5e8848fc98e ("Input: synaptics-rmi4 - add support for F03") > Cc: stable@vger.kernel.org > Signed-off-by: Dmitry Torokhov > --- > drivers/input/rmi4/rmi_f03.c | 64 +++++++++++++++++++++++++++++++++++++-- > ----- > 1 file changed, 54 insertions(+), 10 deletions(-) > > diff --git a/drivers/input/rmi4/rmi_f03.c b/drivers/input/rmi4/rmi_f03.c > index ad71a5e768dc4..7ccbb370a9a81 100644 > --- a/drivers/input/rmi4/rmi_f03.c > +++ b/drivers/input/rmi4/rmi_f03.c > @@ -32,6 +32,7 @@ struct f03_data { > struct rmi_function *fn; > > struct serio *serio; > + bool serio_registered; > > unsigned int overwrite_buttons; > > @@ -138,6 +139,37 @@ static int rmi_f03_initialize(struct f03_data *f03) > return 0; > } > > +static int rmi_f03_pt_open(struct serio *serio) > +{ > + struct f03_data *f03 = serio->port_data; > + struct rmi_function *fn = f03->fn; > + const u8 ob_len = f03->rx_queue_length * RMI_F03_OB_SIZE; > + const u16 data_addr = fn->fd.data_base_addr + RMI_F03_OB_OFFSET; > + u8 obs[RMI_F03_QUEUE_LENGTH * RMI_F03_OB_SIZE]; > + int error; > + > + /* > + * Consume any pending data. Some devices like to spam with > + * 0xaa 0x00 announcements which may confuse us as we try to > + * probe the device. > + */ > + error = rmi_read_block(fn->rmi_dev, data_addr, &obs, ob_len); > + if (!error) > + rmi_dbg(RMI_DEBUG_FN, &fn->dev, > + "%s: Consumed %*ph (%d) from PS2 guest\n", > + __func__, ob_len, obs, ob_len); > + > + return fn->rmi_dev->driver->set_irq_bits(fn->rmi_dev, fn- > >irq_mask); > +} > + > +static void rmi_f03_pt_close(struct serio *serio) > +{ > + struct f03_data *f03 = serio->port_data; > + struct rmi_function *fn = f03->fn; > + > + fn->rmi_dev->driver->clear_irq_bits(fn->rmi_dev, fn->irq_mask); > +} > + > static int rmi_f03_register_pt(struct f03_data *f03) > { > struct serio *serio; > @@ -148,6 +180,8 @@ static int rmi_f03_register_pt(struct f03_data *f03) > > serio->id.type = SERIO_PS_PSTHRU; > serio->write = rmi_f03_pt_write; > + serio->open = rmi_f03_pt_open; > + serio->close = rmi_f03_pt_close; > serio->port_data = f03; > > strlcpy(serio->name, "Synaptics RMI4 PS/2 pass-through", > @@ -184,17 +218,27 @@ static int rmi_f03_probe(struct rmi_function *fn) > f03->device_count); > > dev_set_drvdata(dev, f03); > - > - error = rmi_f03_register_pt(f03); > - if (error) > - return error; > - > return 0; > } > > static int rmi_f03_config(struct rmi_function *fn) > { > - fn->rmi_dev->driver->set_irq_bits(fn->rmi_dev, fn->irq_mask); > + struct f03_data *f03 = dev_get_drvdata(&fn->dev); > + int error; > + > + if (!f03->serio_registered) { > + error = rmi_f03_register_pt(f03); > + if (error) > + return error; > + > + f03->serio_registered = true; > + } else { > + /* > + * We must be re-configuring the sensor, just enable > + * interrupts for this function. > + */ > + fn->rmi_dev->driver->set_irq_bits(fn->rmi_dev, fn- > >irq_mask); > + } > > return 0; > } > @@ -204,7 +248,7 @@ static int rmi_f03_attention(struct rmi_function *fn, > unsigned long *irq_bits) > struct rmi_device *rmi_dev = fn->rmi_dev; > struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); > struct f03_data *f03 = dev_get_drvdata(&fn->dev); > - u16 data_addr = fn->fd.data_base_addr; > + const u16 data_addr = fn->fd.data_base_addr + RMI_F03_OB_OFFSET; > const u8 ob_len = f03->rx_queue_length * RMI_F03_OB_SIZE; > u8 obs[RMI_F03_QUEUE_LENGTH * RMI_F03_OB_SIZE]; > u8 ob_status; > @@ -226,8 +270,7 @@ static int rmi_f03_attention(struct rmi_function *fn, > unsigned long *irq_bits) > drvdata->attn_data.size -= ob_len; > } else { > /* Grab all of the data registers, and check them for data > */ > - error = rmi_read_block(fn->rmi_dev, data_addr + > RMI_F03_OB_OFFSET, > - &obs, ob_len); > + error = rmi_read_block(fn->rmi_dev, data_addr, &obs, > ob_len); > if (error) { > dev_err(&fn->dev, > "%s: Failed to read F03 output buffers: > %d\n", > @@ -266,7 +309,8 @@ static void rmi_f03_remove(struct rmi_function *fn) > { > struct f03_data *f03 = dev_get_drvdata(&fn->dev); > > - serio_unregister_port(f03->serio); > + if (f03->serio_registered) > + serio_unregister_port(f03->serio); > } > > struct rmi_function_handler rmi_f03_handler = {