From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (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 F21F243712B for ; Thu, 6 Aug 2026 22:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786055692; cv=none; b=a/znWiMlkFxWZPfoCeuM1JJk0gSCoIi0WtAumlppNQ/y16iPt8pqsOuti6SOs6uf7L7s1UymqREf2c5/S7JYLtRfTPFuUnpGdW3y8izM4HVhbzlUjhjAtjFh11LmwIsZ3wpqJzLjsmi7eqHITXYQFa2gN5IC41jNGXh4lG0qVk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786055692; c=relaxed/simple; bh=epcEbLSaBihKKb5cz0M8hdhr+ScKrzadPnLxeb8ZJaU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=q7ipfpMPnKqMZF355wnTEV6P9/rrkkfhSx0wMID8q2DDZhgtbebdiGXqeYeEdCF6mHJD6MC5g7IHnUv2Sm9cHkAiAYNgwkklVLxIe/2BSuYhkH2+R0zeEGJjOG7/7yAareMcSx9J5BcCOGWPskjjNsROfGKTzi87H/ECQfAdUwE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RIbcSfGV; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RIbcSfGV" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786055685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wIkgpJ6Hjjg0HhVdJPiDETikGObwkMPvScfiWimMD3M=; b=RIbcSfGVx8MvYhYKDo0QeYO9RrTh5QKyNwI50RgCApfkbf2rwm7wD0p3HFKc+TkaQ3SAvE /4Cft7UYkgGtyBASEoIogpNl3u9wzclJSa4iZCUQ9JLCKtlUnm84zsEcUdbPL20SmkJa4B U+C73le8GQ7/+Vs0PXLq17bpntadcJk= Date: Thu, 6 Aug 2026 23:34:24 +0100 Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net v3 2/2] net: ravb: serialize PTP clock teardown To: xuanqiang.luo@linux.dev, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, niklas.soderlund@ragnatech.se, kuba@kernel.org Cc: paul@pbarker.dev, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, richardcochran@gmail.com, masaru.nagai.vx@renesas.com, sergei.shtylyov@cogentembedded.com, luoxuanqiang@kylinos.cn, stable@vger.kernel.org References: <20260806095126.57803-1-xuanqiang.luo@linux.dev> <20260806095126.57803-3-xuanqiang.luo@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20260806095126.57803-3-xuanqiang.luo@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 06/08/2026 10:51, xuanqiang.luo@linux.dev wrote: > From: Xuanqiang Luo > > ravb_get_ts_info() can run without RTNL while ravb_ptp_stop() unregisters > the PHC. The PTP interrupt handler can race with the same teardown, so both > paths may access the clock while it is being freed. > > Protect the clock pointer with priv->lock, clear it before unregistering > the PHC, and unregister the detached clock outside the lock. I think adding spinlock here is a bit of overkill. For ravb_get_ts_info() you can simply extend struct ravb_ptp to store clock index on init and reset it to -1 on ptp stop. For interrupt race I think ravb_ptp_stop() can be split into disable interrupt function (like ravb_ptp_disable()) and actual clock free. In this case ravb_ptp_disable() can be run before synchronize_irq() with ptp_clock_unregister() afterwards in teardown callbacks, like it's already done for ring allocations.