Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4150251pxf; Mon, 29 Mar 2021 23:55:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxxtCBQrW0/nKDc9BRkfkviJ83uyxCCszcCogZdN7YuKRywYtVsrbFNDOIL9pbeZVzRLGC X-Received: by 2002:a05:6402:268c:: with SMTP id w12mr31615153edd.280.1617087353943; Mon, 29 Mar 2021 23:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617087353; cv=none; d=google.com; s=arc-20160816; b=V2i9mFOdN6RjxLvCFE0I5SlIRfQdX67uzshj5EoFOfeNwcrcthjbAdYPjgZFF9ZBgN 3Cz3bQCTVUHxs93mOz/HSYPB4OEHyxNuSbnrtaUlDre3uG8Wgs3bOlniccQq4V7yEN8b P5YuIxe8dCTPg2Fju2P2UA+MQ0ptQoDrzh3lEO9BR5EN6G34MAqoyh7J3wnpFiULzufX PjuYxtsP76C8IXkzC+gQbhn1OgNT5bbcmdZBnIJFxfQCgn1SsVB9BYsy0JCtwXRLNrKM 2pJEIncAzUd+X9ObtjiDfjkUU9HqPZJCq1FwT43mapDPEVO1Nikq4aldFFTMvBmuE0Yb ck0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version:user-agent :message-id:in-reply-to:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=P4hH4Lh8hHpEBNnqQwFeNlXZVuQlqdCL0aNU+24yiK0=; b=xQf9YyG38ReqHB6kHICCysQ9cjw92GZ9fNhn3mnXRmuGfFdKuWfMmC54yNS6Q9WF7i QLrwSwcxvbbM7irw3P/TW7MbdiZ6DoFchTzRiGSzu9x2hnaKuaiYiCXsHhy8q0D15nQ/ EV9LtbryrWWS0uT0ID0BO9JFHPzXpEh7HKV3VhyBFSqrj6i/xNn8z88rp6pF88nQ5wA3 Z82b6zz8hGzY/6r0DHTsDYNEJIUDjXBtIDSyMXNkwJ818ptTsDvO39XSnyI1XyLmeDAs 6nqLAqYScH6JP0GgCSuy4gyssoi9okZTnL87d8di8ovBX4BL+EZ4iirJ1/QIY9fqpI9w zteg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="ZP/10mH2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id le4si15026094ejc.684.2021.03.29.23.55.30; Mon, 29 Mar 2021 23:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="ZP/10mH2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230248AbhC3Gwf (ORCPT + 99 others); Tue, 30 Mar 2021 02:52:35 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:55627 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230436AbhC3GwV (ORCPT ); Tue, 30 Mar 2021 02:52:21 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210330065219euoutp0243634b89b0f641a7f291cb77b1063f8c~xDC93NUuW0223802238euoutp02i; Tue, 30 Mar 2021 06:52:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210330065219euoutp0243634b89b0f641a7f291cb77b1063f8c~xDC93NUuW0223802238euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1617087139; bh=P4hH4Lh8hHpEBNnqQwFeNlXZVuQlqdCL0aNU+24yiK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZP/10mH2CPXIFCW2Suk/k6IOFrlvLVm7VY4PvqUpMglXmTN0ogUN9hh+RA6vnM2LL 4f8WbMulQNFFof88XJwnYCSby43wfrz8Q0t/IPnf4kSZSL8cFW/VS1UUDc3zVbnTVF jtloeOSmmcMf6HniB7HUhfC3ewNOb5Q/LflZG568= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20210330065218eucas1p1feda83f7e06fe8c98432f738dc5e0e5d~xDC9ZjRQo1478814788eucas1p17; Tue, 30 Mar 2021 06:52:18 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F5.BF.09444.2AAC2606; Tue, 30 Mar 2021 07:52:18 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210330065217eucas1p2c50a100bf0101e72dd753f37257f6a57~xDC8sxecC0045700457eucas1p2D; Tue, 30 Mar 2021 06:52:17 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210330065217eusmtrp1001c32a5dbba642f5d558b498ab286e1~xDC8sE3Ld1277212772eusmtrp1F; Tue, 30 Mar 2021 06:52:17 +0000 (GMT) X-AuditID: cbfec7f4-dbdff700000024e4-d7-6062caa26231 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id FF.4B.08705.1AAC2606; Tue, 30 Mar 2021 07:52:17 +0100 (BST) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210330065217eusmtip253736d518f78c13e59901495e526f3e2~xDC8ePs1q1721017210eusmtip27; Tue, 30 Mar 2021 06:52:17 +0000 (GMT) From: Lukasz Stelmach To: Alexandre Belloni Cc: Alessandro Zummo , linux-rtc@vger.kernel.org, =?utf-8?Q?Bart=C5=82omiej_=C5=BBolnierkiewicz?= , Marek Szyprowski , linux-kernel@vger.kernel.org Subject: Re: [PATCH] rtc: ds1307: set uie_unsupported if no interrupt is available Date: Tue, 30 Mar 2021 08:52:08 +0200 In-Reply-To: (Alexandre Belloni's message of "Tue, 30 Mar 2021 02:02:05 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg="pgp-sha256"; protocol="application/pgp-signature" X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFKsWRmVeSWpSXmKPExsWy7djP87qLTiUlGMx8p2Kx5OJVdov2d8vY LTbOWM9qcXnXHDaLY6uvsFmsPXKX3YHNY96aao++LasYPabP+8nk8XmTXABLFJdNSmpOZllq kb5dAlfGpYtXWAvaRCu+Hb3F0sB4R7CLkZNDQsBEYv6s1yxdjFwcQgIrGCXW3/nABOF8YZSY cH89G0iVkMBnRokVDdUwHc+6prBCFC1nlLjx6BE7hPOcUeLoiYdAHRwcbAJ6EmvXRoA0iAiY SrQ27mIDqWEWeMwocef4CkaQhLBAiETvh8OsIDaLgKrE96UP2UFsToE8icvXPjKB2LwC5hJn p7WBXSEqYCmx5cV9doi4oMTJmU9YQGxmgVyJmeffMIIskBB4wSHRNGsPM8SpLhJHvnQxQdjC Eq+Ob2GHsGUkTk/uYQE5VEKgXmLyJDOI3h5GiW1zfrBA1FhL3Dn3iw3CdpSYuvkAG0Q9n8SN t4IQe/kkJm2bzgwR5pXoaBOCqFaRWNe/B2qKlETvK4h3JQQ8JPqXTmeBBGiNxLqzfewTGBVm IflmFpJvZgFNZRbQ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LYS69a9Z1nAyLqKUSS1tDg3PbfY UK84Mbe4NC9dLzk/dxMjMIa2Hfu5eQfjvFcf9Q4xMnEwHmJUAep8tGH1BUYplrz8vFQlEV7h A4kJQrwpiZVVqUX58UWlOanFhxhNgV6byCwlmpwPjO68knhDMwNTQxMzSwNTSzNjJXHerXPX xAsJpCeWpGanphakFsH0MXFwSjUwGTbdOSjT/eRBF+/7STovZy2Qa5GdUCbkvDM+Kizmiq5n +7vHZ/lPT0pTsec17Da4WS22THphRPWB43q1s9nXHU74dfkCX/uW9Q5eQluObylmP+SnufBs U+WaE33MXrEzdG8HOH2yWj3vgf8crck6LwT7rYOcDLP2Xr0vq8+wpOFmPhdHUfzm864dj5gT /M5q1rLNt+tcu+TrhWax/CpVi9WL9ZdIJrq+82b573nY+dTew8El51rmel1aemXvV8+1RS7u Ye595x15fVRXTzjy7nWXwoIzk2RKfff8KIzQmMPKdUzJqapW/4PHGV5PbvbCzfFFitcPGXot zvzAGP/DrLyMPalT3VcsNuaRdpASS3FGoqEWc1FxIgAXq2kMNgMAAA== X-CMS-MailID: 20210330065217eucas1p2c50a100bf0101e72dd753f37257f6a57 X-Msg-Generator: CA X-RootMTR: 20210330065217eucas1p2c50a100bf0101e72dd753f37257f6a57 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210330065217eucas1p2c50a100bf0101e72dd753f37257f6a57 References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable It was <2021-03-30 wto 02:02>, when Alexandre Belloni wrote: > On 16/03/2021 19:04:14+0100, Lukasz Stelmach wrote: >> OK, you are right. The problem seems to be elsewhere. >>=20 >> How about this scnario? We call rtc_update_irq_enable(). We read rtc >> with __rtc_read_time() and calculate the alarm time. We get through >> rtc_timer_enqueue() and down to __rtc_set_alarm(). We loose the race >> condition (I can do it, I've got really slow connection to DS3231) and >> we return -ETIME from __rtc_set_alarm() >>=20 >> if (scheduled <=3D now) >> return -ETIME; >>=20 >> and 0 from rtc_timer_enqueue() and the very same zero from >> rtc_update_irq_enable(). The caller of ioctl() thinks they can expect >> interrupts when, in fact, they won't receive any. >>=20 >> The really weird stuff happens in rtc_timer_do_work(). For the timer to >> be dequeued __rtc_set_alarm() needs to return EINVAL three times in a >> row. In my setup this doesn't happen and the code keeps running loops >> around "reporogram" and "again" labels. >>=20 >> With my patch we never risk the above race condition between >> __rtc_read_time() in rtc_update_irq_enable() and the one in >> __rtc_set_alarm(), because we know rtc doesn't support alarms before we >> start the race. In fact there is another race between __rtc_read_time() >> and actually setting the alarm in the chip. >>=20 >> IMHO the solution is to introduce RTC_HAS_ALARM flag for struct >> rtc_device and check it at the very beginning of __rtc_set_alarm() the >> same way it is being done in ds1337_set_alarm(). What are your thoughts? >>=20 > > I did introduce RTC_FEATURE_ALARM for that in v5.12. I'm sending patches > that are not well tested but should solve your issue. Oh, I didn't see that one coming (-; I was working on a slightly larger feature elsewhere in the tree and didn't rebase too often. I will test the patches. =2D-=20 =C5=81ukasz Stelmach Samsung R&D Institute Poland Samsung Electronics --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEXpuyqjq9kGEVr9UQsK4enJilgBAFAmBiypgACgkQsK4enJil gBDwvggAil1Ff0dCZuWdYkRAm05OuqXUM9ki+5t+wJOpnNeL+ukrHagoKTMQt7um LiqYV+QLk+4YMkgdQ0NrIFTOoXBk4k0Vbj333/vTEk30RK1qVLTHAkN4mHi2v1LW Te/5h64p3U+DZWDkmniLWNmhJqjoXpohytmbBo5BDQ75+ZttkaN2KZHqdIDSxs41 RpWMNDn3qnpv0xUggUoTkh0gwljToLPPpyFOAg9GZZALRBkCmMqipnzDUKNlk8ir mulX0PFjptdgVBknElxtrbdvqrO0zSAv+zwEAOAz4G3Apn2RCpfDv/kaRO1g1hlA OuA1u86B92uhNjhycumYhPiB3RPH6g== =5P0R -----END PGP SIGNATURE----- --=-=-=--