Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1154187lqb; Thu, 30 May 2024 01:40:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV89nTFf/sNqA7ipxR6MEZBuepE1hx6uM7sT1+YbiW/QOQMUPtFA8Z32wJaDvJtw+r6XVtea2CRi+8tO4gdxNqQJPiKhtLX4LJZx8X3Mw== X-Google-Smtp-Source: AGHT+IHKMUX3sbcubIOiNVDa9SybhTDrjUsYplFQSY4TdM4fiA89KTMbTjPz2Rix8goB/u+IQagH X-Received: by 2002:a17:902:ecd1:b0:1e6:7700:1698 with SMTP id d9443c01a7336-1f619624c66mr19181805ad.35.1717058446865; Thu, 30 May 2024 01:40:46 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9b5bd7si115565415ad.453.2024.05.30.01.40.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 01:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=HW5CL7ur; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-195076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 B91AFB2108C for ; Thu, 30 May 2024 08:39:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EF121761AA; Thu, 30 May 2024 08:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HW5CL7ur" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 E3C3E176185; Thu, 30 May 2024 08:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717058360; cv=none; b=NDNZXnJU2k6lFUlI2svnBVNcN67ud0Gv/8bWkvrwKEgI+QCiBGtF4GBtAekocX98a4QPGpJpHqafXqN1l+Bj3IU/65lb2u3sqcrd0zCqIoVeGS0LpKR4rAR2/HV2rNAAtt3Y9v6+3n2Tk/LzkGzFwkm2eBH8xrzwLDBcTKwVHoQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717058360; c=relaxed/simple; bh=oBD7vg86GXe+oDTvDJhgKE8cSH7YYaTNNz6p30fZnDY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=klitUiQMJxZW7Fr6DjIUjpjmh61NXZzq6UhQvXwMYFZ1PETVIVU3I0FsTvgt2RzwW/aORtiiDIuiKq7RtKzW+EnFnUamjlWHZzwSdz4yKUmFO+AyakNApWVXIQk2v1VqPDrNYcsdRTeHw9w5nqz/SIhzlktFJjl5PxwEeSvlLM0= 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=HW5CL7ur; arc=none smtp.client-ip=209.85.208.43 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-f43.google.com with SMTP id 4fb4d7f45d1cf-57a1fe63947so254558a12.1; Thu, 30 May 2024 01:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717058357; x=1717663157; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tMJb+X5rFOm/8h5g2VHIevAuWgAsNBn0K9qQmDWI2IA=; b=HW5CL7ur+OFLdF6MgA6e+kzYSqDL6fC7bySQZggl9hSqc/fC7GnKM4qsVyhxr7A0ym iPSjK9pOTWGUiGXxuS1vPw2ycjNJw4ehJIrkSkAILKxELx5sgOqN1esJj3FuL0UppOLu 2Aj6lxkBRVHp97RxaMi53M+cxRy7pAB/pmoELlseq3M1YyFEpxFeNCfLRTYCMGNlN7dL XhbUGwTtHO4MDoR0ZoIcGTnWHMqJK5w7vuxUaPlu+XdpY14cryT20Kc+XRh21sWXs/Qn mvKoZmY6UK1O7/nADpxlMcKBxnnc/afPiOlwapJiQpqqpi5WbgMcREABAqX6KEW/+ZQ4 QY7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717058357; x=1717663157; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tMJb+X5rFOm/8h5g2VHIevAuWgAsNBn0K9qQmDWI2IA=; b=J21yle/ozTiSXhmhboQ9iTYx21UxTG/EX02ZqbONUglOsrVD5zciWYh2ncqZiFd0G7 URcpwfPPfkSbaUBxTtZR4/LBdheDfRe1Gx7dOTQOJ5A4onKtFYX9CmBMeNFrV8rfRlN2 8tMzmZs7UUWJrN4We++O2OuR163iRpXeW5aGRMJtiDhiBR/5Sm2EOA0e0bZ79lMAXWNA aG/pKYap5yQQDtvEkBAckRcTHnSR1qZPprnfn/IPnh9sV8WhO5tQKGi5S4ux5NwM77yC Ckl1TlYewLTYaIkafKpWbbq0v884hDlS9So1RDsrhr3NNcS2ZlEcV3dwYM0gyTQQOcgh 7nrw== X-Forwarded-Encrypted: i=1; AJvYcCUdCsMHbuah7ddHHKbK+f1q04cUgrFMuFy/fC2ckaSviALYVMq31BuK3TeromHlyWH1rEo1pkAQpjtZQ++vqm+6WfuEsDoHyjcpuH+cb/eHDkq3CjNGb5oGdQXgiLmqiKphVLDYskFweNXwgxsPxNYkNK4IIi1hnbtSjnPEdYDxTk6DRBox0xAoFSLkHDw74qjGcW/GK2bGZ/EF10I= X-Gm-Message-State: AOJu0YyPAz+yzx7O3fTAaLWPe3qGhMJO5S0FZcnkeVdWkaCeUKBAmX8x YmPJV+DjglSmAaEIJDQvQR94N2f6Dy/a0/MWAQ+bCjYWMxUBetkPLdmdE82tQ8HZyIC9HqHAw8n h7jFy3Yx9lzS2BP1h4Km1mpdcjEU= X-Received: by 2002:a17:907:11cf:b0:a59:c28a:7ec2 with SMTP id a640c23a62f3a-a65e8f6f43bmr92418466b.41.1717058357020; Thu, 30 May 2024 01:39:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240513103813.5666-1-lakshmi.sowjanya.d@intel.com> <20240513103813.5666-11-lakshmi.sowjanya.d@intel.com> In-Reply-To: From: Andy Shevchenko Date: Thu, 30 May 2024 11:38:40 +0300 Message-ID: Subject: Re: [PATCH v8 10/12] pps: generators: Add PPS Generator TIO Driver To: "D, Lakshmi Sowjanya" Cc: Andy Shevchenko , "tglx@linutronix.de" , "jstultz@google.com" , "giometti@enneenne.com" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "netdev@vger.kernel.org" , "linux-doc@vger.kernel.org" , "intel-wired-lan@lists.osuosl.org" , "Dong, Eddie" , "Hall, Christopher S" , "Brandeburg, Jesse" , "davem@davemloft.net" , "alexandre.torgue@foss.st.com" , "joabreu@synopsys.com" , "mcoquelin.stm32@gmail.com" , "perex@perex.cz" , "linux-sound@vger.kernel.org" , "Nguyen, Anthony L" , "peter.hilber@opensynergy.com" , "N, Pandith" , "Mohan, Subramanian" , "T R, Thejesh Reddy" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 30, 2024 at 8:52=E2=80=AFAM D, Lakshmi Sowjanya wrote: > > -----Original Message----- > > From: Andy Shevchenko > > Sent: Monday, May 27, 2024 8:04 PM > > Mon, May 27, 2024 at 11:48:54AM +0000, D, Lakshmi Sowjanya kirjoitti: > > > > -----Original Message----- > > > > From: Andy Shevchenko > > > > Sent: Monday, May 13, 2024 4:49 PM > > > > On Mon, May 13, 2024 at 04:08:11PM +0530, > > > > lakshmi.sowjanya.d@intel.com > > > > wrote: .. > > > > > +static ssize_t enable_store(struct device *dev, struct > > > > > +device_attribute > > > > *attr, const char *buf, > > > > > + size_t count) > > > > > +{ > > > > > + struct pps_tio *tio =3D dev_get_drvdata(dev); > > > > > + bool enable; > > > > > + int err; > > > > > > > > (1) > > > > > > > > > + err =3D kstrtobool(buf, &enable); > > > > > + if (err) > > > > > + return err; > > > > > + > > > > > + guard(spinlock_irqsave)(&tio->lock); > > > > > + if (enable && !tio->enabled) { > > > > > > > > > + if (!timekeeping_clocksource_has_base(CSID_X86_AR= T)) { > > > > > + dev_err(tio->dev, "PPS cannot be started = as clock is > > > > not related > > > > > +to ART"); > > > > > > > > Why not simply dev_err(dev, ...)? > > > > > > > > > + return -EPERM; > > > > > + } > > > > > > > > I'm wondering if we can move this check to (1) above. > > > > Because currently it's a good question if we are able to stop PPS > > > > which was run by somebody else without this check done. > > > > > > Do you mean can someone stop the signal without this check? > > > Yes, this check is not required to stop. So, I feel it need not be m= oved to (1). > > > > > > Please, correct me if my understanding is wrong. > > > > So, there is a possibility to have a PPS being run (by somebody else) e= ven if there > > is no ART provided? > > > > If "yes", your check is wrong to begin with. If "no", my suggestion is = correct, i.e. > > there is no need to stop something that can't be started at all. > > It is a "no", PPS doesn't start without ART. > > We can move the check to (1), but it would always be checking for ART eve= n in case of disable. Please do, > Code readability is better with this approach. > > struct pps_tio *tio =3D dev_get_drvdata(dev); > bool enable; > int err; > > if (!timekeeping_clocksource_has_base(CSID_X86_ART)) { > dev_err(dev, "PPS cannot be started as clock is not relat= ed to ART"); started --> used > return -EPERM; > } > > err =3D kstrtobool(buf, &enable); > if (err) > return err; > > > > > I.o.w. this sounds too weird to me and reading the code doesn't giv= e > > > > any hint if it's even possible. And if it is, are we supposed to > > > > touch that since it was definitely *not* us who ran it. > > > > > > Yes, we are not restricting on who can stop/start the signal. > > > > See above. It's not about this kind of restriction. > > > > > > > + pps_tio_direction_output(tio); > > > > > + hrtimer_start(&tio->timer, first_event(tio), > > > > HRTIMER_MODE_ABS); > > > > > + tio->enabled =3D true; > > > > > + } else if (!enable && tio->enabled) { > > > > > + hrtimer_cancel(&tio->timer); > > > > > + pps_tio_disable(tio); > > > > > + tio->enabled =3D false; > > > > > + } > > > > > + return count; > > > > > +} --=20 With Best Regards, Andy Shevchenko