Message ID | 20240212133645.1836-1-mo.c.weber@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-61709-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2453001dyd; Mon, 12 Feb 2024 06:14:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOfAGsLhWFL+l8LTmJrVFg8c2yW+Zg1DYyHon6JdK2AS5qh9wVKUF82LqyU+GvKv5nJpeqd6Dq+GFztaKBzHQDkPtziw== X-Google-Smtp-Source: AGHT+IEsozvY71fVxun7uzWfcWPkEXHa+XI14Vg1XqfimtkTjI4SO95Rf8y7gxFSUn74J72Pg3L3 X-Received: by 2002:a05:6358:5929:b0:178:8a0c:b466 with SMTP id g41-20020a056358592900b001788a0cb466mr6461196rwf.29.1707747255384; Mon, 12 Feb 2024 06:14:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707747255; cv=pass; d=google.com; s=arc-20160816; b=JdVCXJtCWY3v+34Pso2wMrSSZg5LMFMB47Z75p8C2PygfDMVqp1SYZG8wqu7c9PqL7 s0i4PJXSEv29sSf/unDLGczX9Hv4wTvcPdNUy4pfPSIbOtbbSqx6NHH4BR5zZ1teSRuY CF4fndvF0RdCYuyHIpcVtQkIGG59fOsL7HsSkepOgZddcS14LEXnVRRP4szHRFaD3bGZ rRvxXAP+Dc+f6NHep6qaVrYMrCofhfVGcfWiivydX6Se48CTKFaeAzOhe8nympav4hGO kJE26RHpyc2hJ0sl3aXmiOFPlUpUuw0WNMDLiue2RQ1M477XP7XVC2NM/brWfAXpyte9 mA8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=laRfN/HWi9oFcahbxDTMU1nfn0SEB7plYdxrJOODhts=; fh=y39p6xhQVTmQK5V6LE0RbkNtUiuaNLomxWoV7FtWCYs=; b=qv5oQ0j0uSmXDaAf8p4z8mXxs6tP0/rqQ0mcRP/nncby5mIy9elSH0C7bzCh24v0MB XKcGr/BGcLrcLwndsgy6bj8BGEo9dCTokovVB3iYWb5tZutjoRh3VV8kByysuAiQBGNP teYTswoxxmYuFsKz6emNyVd0hUhCNha9N9vuIZWHxExG9EQnzMAwp3BT5M2LkrcMcVvy O2W2dz6iQcoIJtm4qjznHN8xjDwp2Tpi/V4W3SL9uvDUd3kwPRCGN9jM0OoRhi+fgYmY PQU1X9zg8Hwr/6eZ25OR39IVZ20+iTqt8GkxnC3A2Y6elzMWD9SJ/psehINvrVidgc8K LIoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VN8S596l; 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-61709-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61709-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWoWbo8MaSvDtywypdC2iPzxyD6qlGmIiHo5oRijvM7ANaeBhoGOXiQ5Vp2GppbTQJQw/mjmSPKil2Ni6UbRLThPRlo5A== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ca8-20020a056a02068800b005cd816aaf02si311817pgb.3.2024.02.12.06.14.14 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 06:14:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61709-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VN8S596l; 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-61709-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61709-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8000EB20EF4 for <ouuuleilei@gmail.com>; Mon, 12 Feb 2024 13:44:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7D073F9C1; Mon, 12 Feb 2024 13:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VN8S596l" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 946513EA98; Mon, 12 Feb 2024 13:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707745038; cv=none; b=HdxMnXSCEFsOYopW8rjH+UopR/ZX50j1RvgRroEdtk4tStFvKY2ecdnOPy7Smo3gJGA51vyJ78A322lZe8RqXWi6P1fFsY/NX0ud6WRCubgUEz+2dvLrjYsazn++gT5eTYv5NZ+lT/fc0XFfGNonDOGOIPkCcWhEWQLqEKKMJgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707745038; c=relaxed/simple; bh=F//opeBQLHL9vnvCVwkl/A7cs5ydPs9MIEctpGlDv58=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Fuke3xvykRigOMj7bxEwqvOpWjDZqJBp1wJxk62pZ0/0VFw+9fxeBR2wDd+BfRMLjGVQ4Owlrhe/BNmLYFfmjw3ZCqyLzoP5Wi58Wrv5HpainIG/7QtocWcgNq3l7U5XzOFrmVfcdaDdFt/tdHCUEq+hNlv60db93t8zXK6P+o0= 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=VN8S596l; arc=none smtp.client-ip=209.85.208.49 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-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-55f0b2c79cdso4422715a12.3; Mon, 12 Feb 2024 05:37:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707745034; x=1708349834; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=laRfN/HWi9oFcahbxDTMU1nfn0SEB7plYdxrJOODhts=; b=VN8S596l9tykyZDuGE4KuoerZESQZP16PLr0jGr+uu0MONZMFXhgVJMGiU0Rxszfeo Al1n8enrilZ1+MocpvfJRCZqevhxTeq5XBjmyzJt4t+1t2NM7e+xMD66GMYtoILlGMAO nLknkuN+GoyXctrAobQA7uBD6UwV/IBkR/zehGknt8rt8y+CWtdrtx6IvUfOR4mwRSDS ZpHDDqGH2pF7Do3926meSLSWvF73sgQvJnbMup9xxe2tYHuj4lS+KA6ShMCV0uC8n33h TZBFI9oUGw3VP2ETMmou/nnb7NNbImDkYwJR3irp66HwlCQph8NnMlqQ61cy9QcgeDm9 A+Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707745034; x=1708349834; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=laRfN/HWi9oFcahbxDTMU1nfn0SEB7plYdxrJOODhts=; b=nXnMas1al353jIl6fwsTK2L6VSWL2io0/h5Xzq+HaJ6dRTzEVVNr3jMKFPtbxh4svx NBGPNybZmGB8pRxx3CWgs9syuY7ryXWI9HtqOGyKLJZymrYqK0Vj3mg/SfFXW1GwbVLF zkozd7G/VEEnusfr97oUQK/+0NIUmwKAvS11vmRuwNCkK5A3LysjeFyFrFaWruUQ33mc zQ7D9dzcc/ut6l+8FkiU9EVPdOr/01/44hrgXyvXMGGn8ubQ+wiuy0ge7zHOxfMS+2ma MiSCB/TCR9zDIhkkNm1UwXmV8jqko56DHnbHs2pr1JKXLJEjZ3vfvvNimSgWw2VHrTYq xf4g== X-Forwarded-Encrypted: i=1; AJvYcCUj7j9I5KOrdAkrWVXMainLYgWXdx3qmYHh3PEZPwgRn/v28/lyIU9W3WDxl1L3NEwcbHtuLEnqC8TpQCR9uDc7ZHh3+j2qQTBZBD3bc2zpDZwj3ZPIi6oqw3yxCTnCE++PPaHGXcQ4jBE= X-Gm-Message-State: AOJu0Ywgacedp7g49kKR8FsV8dCfesYhCJ1cQmVL3lpSbeutBXPVZ0Aq JCTsnlOVS7ZM1Gp3sdG6BYsXzkljARMxjwohI9vAHxEnPD0Kj8vDlHyrTJgEHQE= X-Received: by 2002:a17:906:af94:b0:a2d:a6a7:b3bc with SMTP id mj20-20020a170906af9400b00a2da6a7b3bcmr4914263ejb.4.1707745033563; Mon, 12 Feb 2024 05:37:13 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXe432sCq8gKTTI0yG5pfLkQIYtqJ861AS8PZqUqhhYamDxyw7VdxiA2uix2eU872LkARzAtoE46oCSfAsRpuqm4Oa7niFQkv0IzqTpadWZ6HfO81nB7lzr4NYa94oJXYGqYev2IFT637FH4p/nM1HNZxXSlKg3qwgfsFA2YRY+l1lPcNqZ+baDql4Xb7RodzRqCAGV1yuVPh14jq+ZMQ== Received: from pinguine.lan (ip-176-198-146-182.um43.pools.vodafone-ip.de. [176.198.146.182]) by smtp.gmail.com with ESMTPSA id v16-20020a17090606d000b00a389838037bsm221777ejb.94.2024.02.12.05.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:37:13 -0800 (PST) From: "Moritz C. Weber" <mo.c.weber@gmail.com> To: marvin24@gmx.de Cc: ac100@lists.launchpad.net, linux-tegra@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, "Moritz C. Weber" <mo.c.weber@gmail.com> Subject: [PATCH] Staging: nvec: nvec: fixed two usleep_range is preferred over udelay warnings Date: Mon, 12 Feb 2024 14:36:45 +0100 Message-Id: <20240212133645.1836-1-mo.c.weber@gmail.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790702201854252382 X-GMAIL-MSGID: 1790702786179242192 |
Series |
Staging: nvec: nvec: fixed two usleep_range is preferred over udelay warnings
|
|
Commit Message
Moritz C. Weber
Feb. 12, 2024, 1:36 p.m. UTC
Fixed a code style issue raised by checkpatch. --- drivers/staging/nvec/nvec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 12/Feb/2024 Moritz C. Weber wrote: > Fixed a code style issue raised by checkpatch. > --- > drivers/staging/nvec/nvec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c > index 2823cacde..18c5471d5 100644 > --- a/drivers/staging/nvec/nvec.c > +++ b/drivers/staging/nvec/nvec.c > @@ -627,7 +627,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) > break; > case 2: /* first byte after command */ > if (status == (I2C_SL_IRQ | RNW | RCVD)) { > - udelay(33); > + usleep_range(32, 33); > if (nvec->rx->data[0] != 0x01) { > dev_err(nvec->dev, > "Read without prior read command\n"); > @@ -714,7 +714,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) > * We experience less incomplete messages with this delay than without > * it, but we don't know why. Help is appreciated. > */ > - udelay(100); > + usleep_range(99, 100); > > return IRQ_HANDLED; > } I have zero knowledge about this driver, but nvec_interrupt() seems to be a hard interrupt handler, and sleeping in an interrupt handler is a big no no. So I think this change breaks the driver. Delaying like the driver is currently doing doesn't break things, but it is not very nice because this is interrupt handler and the processor cannot switch to other tasks, so delaying is wasting processor's cycles here. The better fix would be to figure out how to remove the delay entirely, or switch to threaded interrupt handler and then we can use usleep_range() in there, but you need actual hardware to test such changes. Best regards, Nam
On Mon Feb 12, 2024 at 3:21 PM CET, Nam Cao wrote: > On 12/Feb/2024 Moritz C. Weber wrote: > > Fixed a code style issue raised by checkpatch. > > --- > > drivers/staging/nvec/nvec.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c > > index 2823cacde..18c5471d5 100644 > > --- a/drivers/staging/nvec/nvec.c > > +++ b/drivers/staging/nvec/nvec.c > > @@ -627,7 +627,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) > > break; > > case 2: /* first byte after command */ > > if (status == (I2C_SL_IRQ | RNW | RCVD)) { > > - udelay(33); > > + usleep_range(32, 33); > > if (nvec->rx->data[0] != 0x01) { > > dev_err(nvec->dev, > > "Read without prior read command\n"); > > @@ -714,7 +714,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) > > * We experience less incomplete messages with this delay than without > > * it, but we don't know why. Help is appreciated. > > */ > > - udelay(100); > > + usleep_range(99, 100); > > > > return IRQ_HANDLED; > > } > > I have zero knowledge about this driver, but nvec_interrupt() seems to be > a hard interrupt handler, and sleeping in an interrupt handler is a big no > no. So I think this change breaks the driver. > > Delaying like the driver is currently doing doesn't break things, but it is > not very nice because this is interrupt handler and the processor cannot > switch to other tasks, so delaying is wasting processor's cycles here. The > better fix would be to figure out how to remove the delay entirely, or > switch to threaded interrupt handler and then we can use usleep_range() in > there, but you need actual hardware to test such changes. Also, pay attention to what else is being said in the timers-howto.rst documentation. It specifically mentions that usleep_range() uses a range in order to give the scheduler some leeway in coalescing with other wakeups, so choosing a range of 32-33 us or 99-100 us isn't very useful. Thierry
Hi, On Mon, 12 Feb 2024, Nam Cao wrote: > On 12/Feb/2024 Moritz C. Weber wrote: >> Fixed a code style issue raised by checkpatch. >> --- >> drivers/staging/nvec/nvec.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c >> index 2823cacde..18c5471d5 100644 >> --- a/drivers/staging/nvec/nvec.c >> +++ b/drivers/staging/nvec/nvec.c >> @@ -627,7 +627,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) >> break; >> case 2: /* first byte after command */ >> if (status == (I2C_SL_IRQ | RNW | RCVD)) { >> - udelay(33); >> + usleep_range(32, 33); >> if (nvec->rx->data[0] != 0x01) { >> dev_err(nvec->dev, >> "Read without prior read command\n"); >> @@ -714,7 +714,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) >> * We experience less incomplete messages with this delay than without >> * it, but we don't know why. Help is appreciated. >> */ >> - udelay(100); >> + usleep_range(99, 100); >> >> return IRQ_HANDLED; >> } > > I have zero knowledge about this driver, but nvec_interrupt() seems to be > a hard interrupt handler, and sleeping in an interrupt handler is a big no > no. So I think this change breaks the driver. > > Delaying like the driver is currently doing doesn't break things, but it is > not very nice because this is interrupt handler and the processor cannot > switch to other tasks, so delaying is wasting processor's cycles here. The > better fix would be to figure out how to remove the delay entirely, or > switch to threaded interrupt handler and then we can use usleep_range() in > there, but you need actual hardware to test such changes. the real fix to read back the value we wrote to the controller, similar to what is done for the tegra i2c host, which is a trival fix. Unfortunately, this breaks the touch pad initialisation, which needs to be fixed first. As this topic comes up every year, I'm going to post a patch in order to updated the comment, so this kind of patches should (hopefully) stop in the future. Best regrards, Marc
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 2823cacde..18c5471d5 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -627,7 +627,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) break; case 2: /* first byte after command */ if (status == (I2C_SL_IRQ | RNW | RCVD)) { - udelay(33); + usleep_range(32, 33); if (nvec->rx->data[0] != 0x01) { dev_err(nvec->dev, "Read without prior read command\n"); @@ -714,7 +714,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev) * We experience less incomplete messages with this delay than without * it, but we don't know why. Help is appreciated. */ - udelay(100); + usleep_range(99, 100); return IRQ_HANDLED; }