Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1920526lqp; Tue, 16 Apr 2024 01:36:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+gnFVa/N+MuKfT1N9NRhUlz2jgeUNYS41E3ncVARrtxP/RnNM29SX899RHys62Z2yFGaU4+uhsn5ygkIEm3mt4vleCUxNzwvk2HC5Dw== X-Google-Smtp-Source: AGHT+IHS4DHthueGFvsgcmUlSCF4X9BUSBL20LJuKWVmI498lIz2eno9bVj8VhMmtWjue8Y2AcIS X-Received: by 2002:a05:622a:2a0c:b0:436:f18f:9f31 with SMTP id hc12-20020a05622a2a0c00b00436f18f9f31mr7735702qtb.20.1713256591320; Tue, 16 Apr 2024 01:36:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713256591; cv=pass; d=google.com; s=arc-20160816; b=Qv5dWPjLgaYUzjeWdf+NYGpojUbBnudC9ZK+p2/Y38z029OTnxuIkurgYLDVtqzmaq MGoUsogdkovaEYU+YqhW8x8w5kIh61hY1Qkhn+znpCVNkIrVceuFk7hphihV4wvIKOsL hOG/8kc57po2gGmE9uGp6mQGZy8DwNX7lQoPUeyGjDiJklUWvwb16iXa9LjpnGO1Gfmg 3N9mVxrQo7txQ5WOJ2lSCq6xp9qVrjzj/bTWiOpUVUb92CjOrtbSoPCgbY9stpSmyJuw 770Zq42jYMQROvpYwUHHgSdq4FjFPaei8VAbW2U0PTO+yY1fUxpLUrjrrpx4Y7B+z+f7 BfEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=gunZQjBXlTN74AuFxyYpvMjk5/cg4ebKFt9lvmAInR0=; fh=KGXnGHwzEH8HGJ+N2jO+RfigRj3PJyhuFSFgFj0uUZU=; b=mnycQaj+ZDOyscS+hYWqwkL4OPCLkHeNrvoxTQRImttdh1Z9ogorVUjHeDYU63XexT 9ktS8GJJ/1XtK1dW0FeGpJX+7QoX4rZSJe7suIS2mZeHDUR4+lOhyKRA38thZrqE5Do+ Z5Kb85+CEYtQA/+EzT+uiJRDfXYqBedgTwA3FVqWWbmQ6Bu9fYj21HbmCMzH8pYJ68w6 w15d14E0LtUJV+VtewY2SLSdh1u227Uk2AMKR6xtNFtfgty9YPTzDLu7EqUOt+bGgKhO XLiyqm79P7Sz+LM902q3iUQYJrg7h1QZj+Siinvt/2I3z5ozkLzw4T9h0bz7F27VGDeb o82Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="NYRh5pJ/"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-146504-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ey20-20020a05622a4c1400b004370a9dba80si4323579qtb.140.2024.04.16.01.36.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 01:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146504-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="NYRh5pJ/"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-146504-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E0A721C21552 for ; Tue, 16 Apr 2024 08:36:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF30183CA0; Tue, 16 Apr 2024 08:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="NYRh5pJ/" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 7AB3D205E10; Tue, 16 Apr 2024 08:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713256581; cv=none; b=u+MEhjF68XgvNmRpV7xAkmQ8T7p0u5GDrbfQ+bKki2riJ97q0rl/FXtCX0Fquw//QBe98D1Fi2woFpUKHDYQWp8OCQOoSHHpMVdzCjDFBu5tGc6YpgQJfbU2DnrhYDX9VJwgezSYz0xV+YC0YShneY6Hx8UBEULIbTzYX1W2VTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713256581; c=relaxed/simple; bh=AveT/kzhMyKqy9qT8luIjlZhEw74u3Rg6QrwfWqr29U=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=DU3YN6axj1wfTW3SFFGLR82rGaWUOi7edOsJ0d9mGMwH8dsv88GHGH3HSLxpsikPON9KckSeQAMnDbkYDR7+XdgXgBoTgqvwd/xAC8N4AsqYAoKaNV1S7Y6eAx6JtLn27WX0NqDDbSdIKJPeKUomDL6hsprJgJxlZ1x49vRJYoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=NYRh5pJ/; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43G8a5ET051699; Tue, 16 Apr 2024 03:36:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1713256565; bh=gunZQjBXlTN74AuFxyYpvMjk5/cg4ebKFt9lvmAInR0=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=NYRh5pJ/awzVIVr4sD0Qm2nOpnz+fNtcJuwBVUH09sLg4gr37FOxU/L1UY1w/cTMV jxqZaAOI86/Aa1lA/vToagLbAxf/77FVw1WdPdL6DJRa1tM1yzlFlugUFkhNdnUeTi 5cIgmeWO1Rz+oHEqVHNrdtLYDgDfOZEbX1bSFLlc= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43G8a5Uj060264 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 16 Apr 2024 03:36:05 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 16 Apr 2024 03:36:05 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 16 Apr 2024 03:36:05 -0500 Received: from [172.24.227.220] (chintan-thinkstation-p360-tower.dhcp.ti.com [172.24.227.220]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43G8a0Dr067512; Tue, 16 Apr 2024 03:36:01 -0500 Message-ID: Date: Tue, 16 Apr 2024 14:05:59 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v5 1/2] net: ethernet: ti: am65-cpts: Enable RX HW timestamp for PTP packets using CPTS FIFO Content-Language: en-US To: Paolo Abeni , Dan Carpenter , Siddharth Vadapalli , Heiner Kallweit , Andrew Lunn , Roger Quadros , Richard Cochran , Jakub Kicinski , Eric Dumazet , "David S. Miller" CC: , References: <20240402114405.219100-1-c-vankar@ti.com> <20240402114405.219100-2-c-vankar@ti.com> <7c8be16329668d343a971e265e923543cba5e304.camel@redhat.com> From: Chintan Vankar In-Reply-To: <7c8be16329668d343a971e265e923543cba5e304.camel@redhat.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 On 04/04/24 16:10, Paolo Abeni wrote: > On Tue, 2024-04-02 at 17:14 +0530, Chintan Vankar wrote: >> Add a new function "am65_cpts_rx_timestamp()" which checks for PTP >> packets from header and timestamps them. >> >> Add another function "am65_cpts_find_rx_ts()" which finds CPTS FIFO >> Event to get the timestamp of received PTP packet. >> >> Signed-off-by: Chintan Vankar >> --- >> >> Link to v4: >> https://lore.kernel.org/r/20240327054234.1906957-1-c-vankar@ti.com/ >> >> Changes from v4 to v5: >> - Updated commit message. >> - Replaced "list_del_entry()" and "list_add()" functions with equivalent >> "list_move()" function. >> >> drivers/net/ethernet/ti/am65-cpts.c | 64 +++++++++++++++++++++++++++++ >> drivers/net/ethernet/ti/am65-cpts.h | 6 +++ >> 2 files changed, 70 insertions(+) >> >> diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c >> index c66618d91c28..bc0bfda1db12 100644 >> --- a/drivers/net/ethernet/ti/am65-cpts.c >> +++ b/drivers/net/ethernet/ti/am65-cpts.c >> @@ -906,6 +906,70 @@ static int am65_skb_get_mtype_seqid(struct sk_buff *skb, u32 *mtype_seqid) >> return 1; >> } >> >> +static u64 am65_cpts_find_rx_ts(struct am65_cpts *cpts, u32 skb_mtype_seqid) >> +{ >> + struct list_head *this, *next; >> + struct am65_cpts_event *event; >> + unsigned long flags; >> + u32 mtype_seqid; >> + u64 ns = 0; >> + >> + am65_cpts_fifo_read(cpts); >> + spin_lock_irqsave(&cpts->lock, flags); > > am65_cpts_fifo_read() acquires and releases this same lock. If moving > to a lockless schema is too complex, you should at least try to acquire > the lock only once. e.g. factor out a lockless __am65_cpts_fifo_read > variant and explicitly acquire the lock before invoke it. > Moving to a lockless schema is complex for now, but I will make the changes suggested by you in next version. >> + list_for_each_safe(this, next, &cpts->events) { >> + event = list_entry(this, struct am65_cpts_event, list); >> + if (time_after(jiffies, event->tmo)) { >> + list_del_init(&event->list); >> + list_add(&event->list, &cpts->pool); > > Jakub suggested to use list_move() in v4, you should apply that here, > too. > Okay. I will update that too. > Cheers, > > Paolo > >