Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2935099pxy; Mon, 3 May 2021 11:12:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVzv6pp1JL5zoVdP6gaY3vie4k2cHUk2YA2mzAB/JsbCjZteqPBgjnX4ivHvgLwVmofS11 X-Received: by 2002:a63:bd49:: with SMTP id d9mr11988849pgp.311.1620065464811; Mon, 03 May 2021 11:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620065464; cv=none; d=google.com; s=arc-20160816; b=zFOnIpVrGhB58ILhE5KOT99HtR1F/pPwFY7OXWMx2txqxBdROs1s85jniWVGJK/QXA X1ghN2GzYy8Cqzn/eerGhmZzd0YCMTV7kgGbPq5TBcaR436IH9Oejv+J2wyX6P+uPRhe 4ni0BY6PK+E/LOELflSZDifZWPKLuizjRcQNkbO1fhIWxyVQ/GIwpFLIIJDQsk89cTmE e2N1Nxa1Csl7P1B/ZHYYIEweZ4/RrjrxYHxt5T8WV3nAOQsoHfS5/lEjuuBbaiGB8BUl sgRayd66zSwPMqxMIKAXdQuW3MGapfPq37ybe33W4jsDeKnWofxmxid+aqEbSTe+ODAn z/AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=MrBPc0OKq6I1AXVUqJE37B5U2Emn4XI+wi6tWyGlkEU=; b=D3XdJLbuS2pwrTJluXQ+jKkvKentOAAU/GLh5D9l1pqI6FnEKYXRfpdBzyr2rZoq+Q pi46X8HyIQfTzAo3BRagFZmQnsPsOoyEtsvaU5T59Cey/njjzvqvHOAw4MZTMkdNuJhd NfoJgpaDaQOv+i5lE3rZtJcpawxXzbh2l94qE2OjPrzmQ9pvz/QH9lkdOPpd09HgqR+I qgV5WuqxVLvm6yVvPoFYCsFpkJ2qRVrw2XinGV0AjWV9NzgLiYW7RK2VtThWJW+KDDcj M8pNTbaoW8YgU1xRCHoqnLoIZz6M/buAKCPEQa9NLV8ZM2TfPj5JCNLlz7TlkK51d6Ki XKvg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e24si377696pgv.298.2021.05.03.11.10.51; Mon, 03 May 2021 11:11:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbhECPe7 (ORCPT + 99 others); Mon, 3 May 2021 11:34:59 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:14047 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbhECPe7 (ORCPT ); Mon, 3 May 2021 11:34:59 -0400 X-Originating-IP: 90.65.108.55 Received: from localhost (lfbn-lyo-1-1676-55.w90-65.abo.wanadoo.fr [90.65.108.55]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 04632240007; Mon, 3 May 2021 15:34:03 +0000 (UTC) Date: Mon, 3 May 2021 17:34:03 +0200 From: Alexandre Belloni To: Thomas Gleixner Cc: John Stultz , Stephen Boyd , linux-kernel@vger.kernel.org Subject: Re: [PATCH] alarmtimer: check RTC features instead of ops Message-ID: References: <20210429214902.2612338-1-alexandre.belloni@bootlin.com> <877dkkfdif.ffs@nanos.tec.linutronix.de> <871rasf8qe.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871rasf8qe.ffs@nanos.tec.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 30/04/2021 10:59:53+0200, Thomas Gleixner wrote: > On Fri, Apr 30 2021 at 10:10, Alexandre Belloni wrote: > > On 30/04/2021 09:16:40+0200, Thomas Gleixner wrote: > >> On Thu, Apr 29 2021 at 23:49, Alexandre Belloni wrote: > >> > Test RTC_FEATURE_ALARM instead of relying on ops->set_alarm to know whether > >> > alarms are available. > >> > > >> > Fixes: 7ae41220ef58 ("rtc: introduce features bitfield") > >> > Signed-off-by: Alexandre Belloni > >> > --- > >> > Hello, > >> > > >> > This doesn't seem much but this solve an issue where following a change in the > >> > RTC driver, this part of the code will think the RTC is alarm capable while it > >> > is not, then breaking the alarmtimer functionnality. > >> > >> So a driver has the set_alarm() callback but does not advertise > >> RTC_FEATURE_ALARM for whatever reason and why ever this makes sense. > >> > > > > No, it would be the other way around. The issue happens when you have > > two RTCs, rtc0 is not alarm capable and rtc1 has alarms. > > > > The driver for rtc0 used to not have .set_alarm() to signal it didn't > > support alarms, it then switched to RTC_FEATURE_ALARM, making the > > alarmtimer code select that RTC instead of rtc1, breaking suspend/resume > > on the platform. > > I'm even more confused. So RTC0 does not have .set_alarm() but why does > it turn on RTC_FEATURE_ALARM? I'm obviously misinterpreting the above... > I'm sorry for not being clear. With RTC0 not having alarms and RTC1 having alarms: The previous situation was: The driver for RTC0 didn't have any .set_alarm() to signel it doesn't support alarms. On registration, alarmtimer_rtc_add_device finds out it doesn't have the .set_alarm() callback and doesn't select that RTC. On registration of RTC1, alarmtimer_rtc_add_device finds .set_alarm() and RTC1 is now the alarmtimer rtcdev. The new situation is: The driver for RTC0 always have .set_alarm() but clears RTC_FEATURE_ALARM to signal it doesn't support alarms. On registration, alarmtimer_rtc_add_device finds .set_alarm() and RTC0 is now the alarmtimer rtcdev, leading to an error when rtc_timer_start() is called. I hope this is clearer. -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com