Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp377481lqt; Thu, 6 Jun 2024 06:28:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCULU427/RVU4mMNCL+6nKLhZlwpLVdCiIq6ERHJcaAsk2B44NGPxu2OQ88+rSYIQZH7cUYMvXYsPMkIIZAOcg+CvSBGqahRfDIA0k1W1g== X-Google-Smtp-Source: AGHT+IHQQsh/nWqqABGe00Z/C9HVohGQ28QZ+mKXWEdDbXhAHGHEFJ+mjL0zdbnMjuR6JlFTHGvv X-Received: by 2002:a50:d592:0:b0:57a:48c:c0f4 with SMTP id 4fb4d7f45d1cf-57a8b6a69efmr3942317a12.17.1717680531104; Thu, 06 Jun 2024 06:28:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717680531; cv=pass; d=google.com; s=arc-20160816; b=eY3wDT6+uwICjB5yr3c7BS77XzHRlA8Ztf9J6gLfWnDxDLkGPoRs/S1dfX2c85eoJS q7mV88ZzM5Bxb4k9nzlInmqWsl46IEZezEBLjF/QN8qWJNmUHcinRdQ1lD/yboLmulVh RtHBBhy88KZwOvaIzVLP+tv32qaubAV6kGQw8lY/zaHa7keUMEzbOrMs+jNN/Hu9//GQ RJQFUK6IQeWFVoBT+kzVTw0q1sXFo+VYKtTHDZPJ8w/dI9awufCHekWu94srM6THrSOf QH/I6aXgX8m2A03bYFhu7kRnRjUq+uiC+e4lhROce5pEjcanZR+wolXBcx+HdJf37Cdt AiMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=utY5xIcszx7G2aTGA/r1H6iz9uoTwSG/cIJhnifoGOg=; fh=Ckqgv+QuFc1eduWhIx0FbAzsEI7PfePQ14NBjZfs/SY=; b=tQHAzTa2Y0VRDjMVMRhBprGKqytQ8QdutHZwFhxJqpfn4pjC+CdMauoHbxsZXw/Wxx EjExmqqsCYXW4fdKHzB8V/Gh+BoUDCJOZeoZd/FjpgRD58U4gSHEHIbWiVaoArwmrWFr QQxMlMsgIgsy6noaoW5XKL5kF6Y6cZTzlSwA6bAtWay4NLi8owZ4fV7xC3B0Bm6pU40Y VSGQzIUZqGyrEJAS2ceP6rGgtAgg4aWiHf0EnVX5tqhewJ+qP1LaoyeSXtuhgaJaO+w7 cMF1dFCP/q29tO0bEG6SqBSzAbyUWc6woyDTgkTJGLGF/97y4okZK40r0T1h+qzgbM4f hh9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=TW0KvQ+w; arc=pass (i=1 spf=pass spfdomain=rts-flowmailer.siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of linux-kernel+bounces-204364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204364-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae1fe044si729447a12.238.2024.06.06.06.28.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 06:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=TW0KvQ+w; arc=pass (i=1 spf=pass spfdomain=rts-flowmailer.siemens.com dkim=pass dkdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of linux-kernel+bounces-204364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204364-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.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 am.mirrors.kernel.org (Postfix) with ESMTPS id D042E1F21CA2 for ; Thu, 6 Jun 2024 13:28:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52014196434; Thu, 6 Jun 2024 13:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=siemens.com header.i=diogo.ivo@siemens.com header.b="TW0KvQ+w" Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A3C9195FDB for ; Thu, 6 Jun 2024 13:28:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.65.225 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717680517; cv=none; b=dzvxfvjkIGzLmiPoTdervPn4DAmuHrG1kXhRhQHTMS3KHHhrPuJ32heucbKg19expYu3IjslI4aE+iv2jDTFUr16Fgkb2gtDxYhXqEKesfikxUXKwU/gPQridj7H6rjHmEwUzIiTXPxMqLoIFMD1FHPkNukDbTBiG+GaLRVdOTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717680517; c=relaxed/simple; bh=yjkWMEhTTHw95CioVsQeuppHqqaXxYjWyu4hGhWgAqY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Dz42UDTs/wTj1wShYK8XhMjZmsBX0g1EKSkxieMpfMwOPqHPBcWHR23Xt/kLYRMQEp3ebdBAScAT972LsFsKx4HKJQULuUuSLsf11Vd8xtPNaNnQyQ7aA3pIkwBZAc18jhIoaxeZB298jC04HTDiwAOwIIbEHCvMBC+ccIWmy6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com; dkim=pass (1024-bit key) header.d=siemens.com header.i=diogo.ivo@siemens.com header.b=TW0KvQ+w; arc=none smtp.client-ip=185.136.65.225 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 20240606132831b8517594b31b015687 for ; Thu, 06 Jun 2024 15:28:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=utY5xIcszx7G2aTGA/r1H6iz9uoTwSG/cIJhnifoGOg=; b=TW0KvQ+wMGMxNr23pWsjhl6GhMaonhAwv9UdPUC/EKSfBZopTYGerLxzQr9qFYBF/32Pml c20qYCya0SrMhTolGT2Tk6n86ZWc2d19lJ8dcopDXvlUl9GOVR+yAbpBZN9UA7rXwkpQhz1i sCZWNlwu3A5YkMKtTC24K5XG/JL64=; Message-ID: Date: Thu, 6 Jun 2024 14:28:29 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net-next v2 2/3] net: ti: icss-iep: Enable compare events To: Paolo Abeni , MD Danish Anwar , Roger Quadros , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Richard Cochran , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jan Kiszka , Jacob Keller , Simon Horman Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, diogo.ivo@siemens.com References: <20240604-iep-v2-0-ea8e1c0a5686@siemens.com> <20240604-iep-v2-2-ea8e1c0a5686@siemens.com> Content-Language: en-US From: Diogo Ivo In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer Hi Paolo, On 6/6/24 11:32 AM, Paolo Abeni wrote: > On Tue, 2024-06-04 at 14:15 +0100, Diogo Ivo wrote: >> @@ -571,6 +573,57 @@ static int icss_iep_perout_enable(struct icss_iep *iep, >> return ret; >> } >> >> +static void icss_iep_cap_cmp_work(struct work_struct *work) >> +{ >> + struct icss_iep *iep = container_of(work, struct icss_iep, work); >> + const u32 *reg_offs = iep->plat_data->reg_offs; >> + struct ptp_clock_event pevent; >> + unsigned int val; >> + u64 ns, ns_next; >> + >> + spin_lock(&iep->irq_lock); > > 'irq_lock' is always acquired with the irqsave variant, and here we are > in process context. This discrepancy would at least deserve a comment; > likely the above lock type is not correct. If my reasoning is correct I believe this variant is correct here. The register accesses in the IRQ handler and icss_iep_cap_cmp_work() are orthogonal, so there should be no need to guard against the IRQ handler here. This is the case for the other places where the _irqsave() variant is used, so using the _irqsave() variant is overkill there. From my understanding this is a remnant of the SDK's version of the driver, where all of the processing now done in icss_iep_cap_cmp_work() was done directly in the IRQ handler, meaning that we had to guard against some other thread calling icss_iep_ptp_enable() and accessing for example ICSS_IEP_CMP1_REG0 concurrently. This can be seen in the comment on line 114: struct icss_iep { ... spinlock_t irq_lock; /* CMP IRQ vs icss_iep_ptp_enable access */ ... }; For v3 I can add a comment with a condensed version of this argument in icss_iep_cap_cmp_work(). With this said it should be possible to change this spinlock to a mutex as well, since all the possibilities for concurrency happen outside of interrupt context. I can add a patch to this series doing that if you agree with my reasoning above and find it beneficial. For this some comments from TI would also be good to have in case I missed something or there is some other factor that I am not aware of. Best regards, Diogo