Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp296923lqb; Tue, 4 Jun 2024 11:35:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEOHI709f7wnw/S6HGLuyr6q/HBn3DrY0+J7Qbgncgo8u/3iYuMSSYo/wamtDPwfHDas8fjM1xkdqznwUkTg5kAXTI+XD72oEwMZATDw== X-Google-Smtp-Source: AGHT+IEgRSiRsK/MmJ8hH9E6AmFp5bo2XXWxnBUVDHI5DDR9HFBMfQIwYmGrlRRgyhFC5EObtYoY X-Received: by 2002:a05:6358:281d:b0:199:29f4:c57b with SMTP id e5c5f4694b2df-19c6c689877mr31045155d.11.1717526111045; Tue, 04 Jun 2024 11:35:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717526111; cv=pass; d=google.com; s=arc-20160816; b=Qav6cBvyV6SFWs2xgR7f22tZ86N/9g9oO4O5y1AZOqXsapHnCSSzbLISOS6hVQqXiU cOZu5e11+48nR/GqWT2ieV0IoZM8+O/RR6ez/kVT4PrU0nh7v3y+fAjvQcquKEzMg/XF PGe6GGEu4U57R3HQ3+yFRE8S3zKsu5mzDqo36lYkfJrGBOLQSVsrmE94ybpkQgSOn32f HdCXXt93jUdhM7sVIhwNP8VA9zbDMcOc6ygSbKkPmwa8VitFBvRyA7tL4UnVqBf1t00+ 6nGXNsvdDIO1GIrG+L42W2HyZt6ulNfW4XFMJNvf8pWjV2/qvTVYPsc5mK1LHGjrjf0W DHAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yy8ysYSbl02/Pq5QPBuhlejpWviNjy8Nbu+adqMwnQQ=; fh=No23+v98rDdRjztpxKcwzeibHjj2oId3zqJvGDKIl8I=; b=OqPtFtb3mYQi+SW2Mpl/NNnr++5h5zH5VqnX0XRwExQ/Qg+a6PvqRQRXUnxUYoquml mnMjZ+kxtB4xmbnXiBpUIV/tYnTCo7PH7p2ySC+QbOAQ2LYm7ij7VWprByGl3BoMKTR5 wXXOMr/YRh5DqGRbSGBsMZrycGydMm31s7D5pgmIH8lfC9o1Ak4NPZ6HRzKyj7TW0TP5 00zX5uW4wk9PDB1LRMELIBH6PocORKx8XXnRE1CAGVSQxrD9ITgft1gOgAempaHYhF/U pOP5SWLVDzgCe0jMWHu9x9YQJ/qQlERAfR1joXtMNUuhBYvpfkOk17DRAU63jN/Gwlcw mcLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WrhShOOu; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-201245-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b42c155si114571676d6.484.2024.06.04.11.35.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 11:35:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201245-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WrhShOOu; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-201245-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BC76D1C24DC6 for ; Tue, 4 Jun 2024 18:35:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA47014039A; Tue, 4 Jun 2024 18:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WrhShOOu" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86BB3A5F; Tue, 4 Jun 2024 18:35:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717526102; cv=none; b=kZNX8MNzouihJexW6wIoVb018SC8GB/EqZ5hxz8eXRuQt5UxUGitcdOOHxDfhh0JFRFfblSDdrvP/V490v/VjtPyULK5Y/suI+Kah/rwiXwjv7XnS1RfKdXbRUYRY0WXLAcPWgT11weRFGjbuFI1HENcM/Hqrty+IBng9wQQ8fs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717526102; c=relaxed/simple; bh=Ysw4TuWg//Bb/RUzlLDCHt6EmLws6dbL/fBsW5ZHejg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NUdtm07uQfkVSCOMZt+Gfxo42kxhlbn61EK7bQzAUKF7TS//7Y0Kt661rKLjKuAljh1Km5D4MIFm1bpEd1qb37z5mpNRlMTXjEDCooNtv8hEJCgIDEecbBdq2meL368hS1fuL5uwzo0z2Pp57FCeZmzftpDwjUCDiTSklWQDUno= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WrhShOOu; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1f64ecb1766so12563295ad.1; Tue, 04 Jun 2024 11:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717526101; x=1718130901; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=yy8ysYSbl02/Pq5QPBuhlejpWviNjy8Nbu+adqMwnQQ=; b=WrhShOOu3myIp49Ho2kkR0mLN1KOGp2rAMC72a21ctxe+0MERY3BxcCKPi7gR6ibwH pf5quG0KHfm8BXY9fIIrmuyLtjoKlmbO4iRo2qsJ5HjRAaRA+EhxsjtnLnk5UAkxYCDj arAEDa8WUHM4OSHaPP4QaEW0ZhpKb5k0qkuAyECriAEKRsIB0oLW0r03DdtlpCzuqrUX PaM6tBBMkEQghc6s8aJqncozm4/2RLeEAZVbiq7ChpknWgwII3Kif4/5qHSYIz9o+jUi VBuRhtbk+I8w1sP+6Zkp3m6yuvQMRJ6gCMjaG4DO9ZwXKKno9FRqV9rGQhXdCwY2T8AW 9q7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717526101; x=1718130901; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yy8ysYSbl02/Pq5QPBuhlejpWviNjy8Nbu+adqMwnQQ=; b=M6eZ7t6SJX9eyWjqU/kZbdxMNvF5YKnT87ph2/zvQEdgPRFdVSDLvH/MOuZKZfqU+n h1cg/6G0VAXvOghrkZVgH8YWKOOBi5HEmfKz6Whz55A81w5M3+NWHGxu43eq6OW1sfVT SH+pLEonRjXC+eMu49e5Zt7YT9dUF7x1exb3vt/JOWtE2ss8QbGuYSuoLvEE+Yt+SKyf sGk0GGF+/SnaJM9aNfkso/KuD8nqhhdyZQK+LbuqHkAPwDmUQ981ntX3G9JwT+iRmWSI Vw3R05gQOX+sxk9RGMHmWN1Rag3aEgShlw5mYXUK5iulD1yzxesKuKb0j0DnqkrgA0p2 Vknw== X-Forwarded-Encrypted: i=1; AJvYcCVq5CAFTzvulmOWim7iRdzAC+WK3ZDuDADunqEwJWQZd99QPiP2BRzhzzfcJD4QYc0VQ1qCLdt4Aei3Pd9evxY3kYkthtGNQGr1CoAFxIqBx47wnTUA9OzHYQTF/HviK29gVNjbRleq0Z0= X-Gm-Message-State: AOJu0YzyVtF85Hkg7jninBMGbaJGdqRrWc9ZmNfqfbb+HZQJSu6KHQsS u9Br14qi3TxEgZVyKhHrK54hu3fz8Fw8wtv1YBZ9GyXMg6PjhksG8/1+ug== X-Received: by 2002:a17:903:32cf:b0:1f3:2e5d:902d with SMTP id d9443c01a7336-1f6a5a02fb9mr4274645ad.4.1717526100588; Tue, 04 Jun 2024 11:35:00 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:1327:f82:3fa9:728f]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f63232ddd1sm89040305ad.11.2024.06.04.11.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 11:35:00 -0700 (PDT) Date: Tue, 4 Jun 2024 11:34:57 -0700 From: Dmitry Torokhov To: Charles Wang Cc: jikos@kernel.org, bentiss@kernel.org, hbarnor@chromium.org, dianders@chromium.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] HID: hid-goodix: Add Goodix HID-over-SPI driver Message-ID: References: <20240527042945.57054-1-charles.goodix@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jun 04, 2024 at 07:23:59PM +0800, Charles Wang wrote: > Hi Dmitry, > > On Mon, Jun 03, 2024 at 05:50:23PM -0700, Dmitry Torokhov wrote: > > Hi Charles, > > ... > > > +}; > > > + > > > +static int goodix_spi_read(struct goodix_ts_data *ts, u32 addr, > > > + u8 *data, unsigned int len) > > > +{ > > > + struct spi_device *spi = to_spi_device(&ts->spi->dev); > > > + struct spi_transfer xfers; > > > + struct spi_message spi_msg; > > > + u8 *buf; > > > + int error; > > > + > > > + buf = kzalloc(GOODIX_SPI_READ_PREFIX_LEN + len, GFP_KERNEL); > > > + if (!buf) > > > + return -ENOMEM; > > > > Can you try using ts->xfer_buf without making allocations and copies? > > Maybe have goodix_spi_read() have data as u8 **data, and do > > > > *data = buf + GOODIX_SPI_READ_PREFIX_LEN; > > return 0; > > > > at the end. I.e. callers do not supply buffer but rather are given one. > > Of course you need to make sure there are no concurrent calls to > > goodix_spi_read(), but I do not think you have them anyways. > > > > Unfortunately, there are concurrent calls to goodix_spi_read(). The functions > goodix_hid_get_raw_report() and goodix_hid_irq() may execute concurrently. > > Anyways, I will try to optimize this part and reduce the malloc operations > where possible. I think you will need to serialize this anyway, as (AFAICS) you write to report address, and then perform the read. There is nothing in the upper layers that says that several report requests can not be sent at once, and I think the device may also raise interrupt at the same time. Without serializing/locking you may mix up the data. ... > > > + > > > +/* Empty callbacks with success return code */ > > > > Hmm, I see you are using falling edge interrupt. Don't you have concern > > of having it "stuck" here? I do not think all these should be stubs... > > > Thank you for pointing this out. The trigger method shouldn't be fixed > within the driver. As for "stuck", I believe this issue does not exit. > The firmware won't wait for the host's response. It is not the touch controller that will get stuck. The host interrupt controller will not repeat signalling the interrupt that is configured as edge and it was asserted earlier. Or are you saying that the touch controller will de-assert and re-assert the interrupt line if it is not serviced within given time? Thanks. -- Dmitry