Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1208884imu; Wed, 16 Jan 2019 14:51:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN7pFHavy9LlP+Bid1j++l5/sijE9yr1EhR84PRqr2lR6oCTs7cZ1XvLsG0AXyZlPIceai1j X-Received: by 2002:a17:902:1122:: with SMTP id d31mr12314610pla.246.1547679093831; Wed, 16 Jan 2019 14:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547679093; cv=none; d=google.com; s=arc-20160816; b=F9iHmTDSZrQFRxMo05goi9crIjPTMxUVuY5v4OAJ7J3CUnYGfAr+ZS/rRkOW0mTiRR 4WFMtloqXeBE7K6LSKywZO3m+FCBFPedcy9doie1DowGGCiOfrk4TeS4waVcAzlOFUMl wrxu/PNhx87u1SLm+Yqd5HXGDyWSonX1bsk2O7MW0Gtj+t4efT4D8Bv+mcbXENaZrTsL bphn5ynQJM2xMdwXjNZ1XkIh7Wv93GIh0WUa3lCTMeursvG50KGrTEiyKCSoqr3A5NTQ ENWeGtpFJoh9JT35pGWw9MoKuRv9Yhm8LqNlqTrsrO9GaCApWSCSVLA4z5XlVCrVlaeq IR1g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=6zLLpdXDNbxxW4MvbghkOOmp94mw3IDbzzKNrvQc84w=; b=jRV5bV/nupDxzgJzidCgZ1rHG3KRDZOcfVC2Bl3bxB+qHiiqSBFnPf0yQ11UuTHoMZ IieZP90StYzJmijxMIcyJbFVP+UqSVE/gN1I9CuFwuejKPpBexQ9J58d88gtGkh94mWs 4PemUkYjlgSHSeB4oMac0ODMJ7jTihr3G1X+MJdX2d6q7HGRUiY5Q39bnbP+O5rV73oy SGCzvTYJacZPJjhIuxcNkOdXBLSK/2H54f3c4vwyxAEa8rac5rc8qgknVB8f3vbUnfz2 +U8i3xS2YMj22mpjY0gfE8ax7SjQyuGohsMPwjiXlgsetVt8ZhWHoWMCiQQGRtwb0Vdr 3yxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=vk0klhZ6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92si7585867plw.158.2019.01.16.14.51.16; Wed, 16 Jan 2019 14:51:33 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=vk0klhZ6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394099AbfAPPgH (ORCPT + 99 others); Wed, 16 Jan 2019 10:36:07 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40849 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387867AbfAPPgG (ORCPT ); Wed, 16 Jan 2019 10:36:06 -0500 Received: by mail-wm1-f66.google.com with SMTP id f188so2431976wmf.5 for ; Wed, 16 Jan 2019 07:36:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6zLLpdXDNbxxW4MvbghkOOmp94mw3IDbzzKNrvQc84w=; b=vk0klhZ6jDRBn0Ys3f3UGTmN6Up/ouWL2pdlPiQfyqBhLVJvQm5L9dw6hRBMgfFpWb A3WAOlbqADlFFRIqXeqh/3qQ3++Pee62puQmiUxJ4gqabcGjQGyKIb4OK10mYj/VMu+N DNSfFLJ5mqTGsAp+g/5v5cgwVNFsImbRM8CakstEkYy41uzCqJoyJqkt6GtG6LRFN1lR lg3RM2RG6dgeJOmS1QoN62nhntZo1iCA3pzo/TKFCbiyQjgco2lcY1zj16PuMsmz56e3 xMcj9SOFk1RYcAIsAex6exLsuOMvQk7P3jUGZZl98NIqmyk7d6i44md/7u6JxW+xe8Ix Beqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6zLLpdXDNbxxW4MvbghkOOmp94mw3IDbzzKNrvQc84w=; b=Hk0J5BeuCBmzyRvOz9QFZQDkVyB9dcHY+SCRMG9Mb0QG19hcIVVM32XDSG5PMAZx68 OhANRk2FjkdBZ1GELa3TvHkk7beu6/xrcBIPafL0grU4Cgtq6cnh43lz2EVYhrjDvpgn lnrx4t63MbggI78dbNF53ub8/WPdBXjpM0RjTGDUh1cg4pOnNsHM/KePXy+Bt4ZzTRET +A8Q2mpd4ZZYeR6luGiinq0o1O03eYnXbC3qjUyp3zZxrEa8f2uRysulVDQ9CKbXL7T2 nVt7oUmzX9clEn38/ujAQBySz7fHe3bmkxqLO0KOcz9yTzSHA8smxkACg+gqAW52isqd etBQ== X-Gm-Message-State: AJcUukfXXjrduK8DY2/w7u/ZnC1Hn/6cWSrdt0ySo4g0H0Ax2iJgmpy4 +4T9hGrl1pMXiXlEZeLuTWOkUA== X-Received: by 2002:a1c:2c44:: with SMTP id s65mr8484233wms.80.1547652964990; Wed, 16 Jan 2019 07:36:04 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id c21sm28758364wre.71.2019.01.16.07.36.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 07:36:03 -0800 (PST) From: Bartosz Golaszewski To: Sasha Levin Cc: Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH STABLE v4.19.15] gpiolib: fix line event timestamps for nested irqs Date: Wed, 16 Jan 2019 16:35:57 +0100 Message-Id: <20190116153557.13720-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski Nested interrupts run inside the calling thread's context and the top half handler is never called which means that we never read the timestamp. This issue came up when trying to read line events from a gpiochip using regmap_irq_chip for interrupts. Fix it by reading the timestamp from the irq thread function if it's still 0 by the time the second handler is called. Fixes: d58f2bf261fd ("gpio: Timestamp events in hardirq handler") Cc: stable@vger.kernel.org Signed-off-by: Bartosz Golaszewski --- Hi Sasha, this is a backport for v4.19.y series. The original patch didn't apply due to a conflict. drivers/gpio/gpiolib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a8e01d99919c..b3ab6c428423 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -817,7 +817,15 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p) /* Do not leak kernel stack to userspace */ memset(&ge, 0, sizeof(ge)); - ge.timestamp = le->timestamp; + /* + * We may be running from a nested threaded interrupt in which case + * we didn't get the timestamp from lineevent_irq_handler(). + */ + if (!le->timestamp) + ge.timestamp = ktime_get_real_ns(); + else + ge.timestamp = le->timestamp; + level = gpiod_get_value_cansleep(le->desc); if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE -- 2.19.1