Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp306382rdb; Wed, 17 Jan 2024 02:32:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IH93NNYSPv2ZLVuOxNC5YXlXHiNFJnBE6v/kElQUkDXhX+fd57YHhu7dfUuVsZBeEajeARP X-Received: by 2002:a2e:93c3:0:b0:2cc:df53:5321 with SMTP id p3-20020a2e93c3000000b002ccdf535321mr3984020ljh.3.1705487549439; Wed, 17 Jan 2024 02:32:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705487549; cv=pass; d=google.com; s=arc-20160816; b=sHMsZv471Lv7m9PJlQPAQIgyFc4Ce78lzkreQ3j+lc0AwBNeJqUQAcbysmg13u76F6 X3k5U8JEHvt43xnJSgfjD8vibk5vs0eclIaQXwy80M8roWjicEuFy1QgmWr3XQgyPXdv aZh9PrcY95QvSybYASJDsURQb4VIKHPrgjzlFhUKQU4oF84gaxIBppoz0IHKV8DIc7Dw 4ghsv9Jy4C4Bi5/Br0A97gb3xOuiGpSNQHfd+3ZNlbie7kO5lZ2ffalwMjoP3Z40Bg/I sISQkIbPJwQ4vyIsnMc4HndX5vLiV5/A+QEGFRE38YF2y+aeUfJplViYEEq/tfheSAaM hMBA== 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 :dkim-signature; bh=M1XvatqbunGN5DfTHWsSYsH7oVXhgrr6KjLBG+a/sYs=; fh=pTEbnkwF6ue36a7udjCwWXyDIQqG5z1WR5z+4Yc/QL0=; b=M+ucagfTcawSW8gO//4leDQ+DSJuxPRIH+yZDemk1UJ+wtAIZxBsoqxfSeIyaQWBXD pCQH0rFST0Zu9GKM9kKrkw4ZRK1WaDXy1kkBLtfjNzJHW9PB1GVyuI4pzNPgsht6UNg9 J5J9Un9MLrqx3ZbPo8K+HlgjA0KjhUQeKzXpbl8eUsfWPfkUfWlDVdcpnYDX08v2Q59D LMOFPuiAVg6eySG5Q32CDU0HC1NdG7Ag7NVHFD6kWNPnKlkSuq1X8vz4DCkFuHqicpwo 1el0fKVwm5MdspR9O3KkONvxXRULjkIKJchD6yugDSqrHSX2JdS5WuTteLXfxmKQGhtd AzMg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@alu.hr header.s=mail header.b=EqerjZEj; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=UCZ2W8OW; arc=pass (i=1 spf=pass spfdomain=alu.hr dkim=pass dkdomain=alu.hr dmarc=pass fromdomain=alu.hr); spf=pass (google.com: domain of linux-kernel+bounces-28845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=alu.hr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c8-20020a50d648000000b00558b0d81dffsi5577227edj.434.2024.01.17.02.32.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 02:32:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28845-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=@alu.hr header.s=mail header.b=EqerjZEj; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=UCZ2W8OW; arc=pass (i=1 spf=pass spfdomain=alu.hr dkim=pass dkdomain=alu.hr dmarc=pass fromdomain=alu.hr); spf=pass (google.com: domain of linux-kernel+bounces-28845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=alu.hr 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 206141F21CCF for ; Wed, 17 Jan 2024 10:32:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7892A1DDD0; Wed, 17 Jan 2024 10:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=alu.hr header.i=@alu.hr header.b="EqerjZEj"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=alu.unizg.hr header.i=@alu.unizg.hr header.b="UCZ2W8OW" Received: from domac.alu.hr (domac.alu.unizg.hr [161.53.235.3]) (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 D00C41DDC8; Wed, 17 Jan 2024 10:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=161.53.235.3 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705487473; cv=none; b=qBwVbZXnJo3Rug8zrqxEYxHNzrWFlj1Y3aO1d9YtVP7MwscPa1vrFt4hSB1Q4UIyYHwjp+bU0L9NjHEJsAnCKKvrjXetEGoZ6/yXU+f1mro4OdDUEugQe1mItLqiO8Y2S8QdEew6MPLsmhFGzIU493empeNXZRPvHdmTg94aJrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705487473; c=relaxed/simple; bh=iwSt0dX080YAZAjn6l0J2DH9z0NHNrOKDfSGJeVuk2Q=; h=Received:DKIM-Signature:X-Virus-Scanned:Received:Received: DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent:Subject: Content-Language:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; b=AsYpUik46Eyk7zrBXocw9UkQ+Rd6SqEbcBJMy4ej/T6Oy+fz2qkVcGZ2wgb1e8mYjxt+p+PwrOJxLh1j4Ct6tbV5RCzmUzqSp1g0rtiR7TJAuk9yrm2biOlLbGfIBs/Jtx1WmGUXuOY84o9PSANjChd8DmYQWg5+HCbcW+OWGYI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alu.hr; spf=pass smtp.mailfrom=alu.hr; dkim=pass (2048-bit key) header.d=alu.hr header.i=@alu.hr header.b=EqerjZEj; dkim=fail (2048-bit key) header.d=alu.unizg.hr header.i=@alu.unizg.hr header.b=UCZ2W8OW reason="signature verification failed"; arc=none smtp.client-ip=161.53.235.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alu.hr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alu.hr Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id C14606017C; Wed, 17 Jan 2024 11:30:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.hr; s=mail; t=1705487458; bh=iwSt0dX080YAZAjn6l0J2DH9z0NHNrOKDfSGJeVuk2Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=EqerjZEjtm+TYGTrkvZPBdK3LDNPyshZ60TIZ4IrfuBJQp27noPbojxqjy2OSfC8m JEh6pqhDqa3TqL/NofyF4qkdH2S3WCm6ALq/QjCpfsm/1r0MLkYxGC4TCdTQzMiAqX dAAkh+M/oUMY44Z6J1ExB8aPRRnKBZCCGMPqzbKn66MUMWHcZbTu+1Ig8JP9D5B/aS O6CnZkk/uQTQh9zmBmKahW3zcZiTK9fJWQJ2QbN/bPa61+qJ8QxGjLoSbdwWOFrQ8j +OxFp3ia/qOTQDAYXhseMBW9A0Q8GZNU5sY0qxC3sWLuzMPYERid1gyGC07ZgjwRbD HHQoWq4WaOhIQ== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eKV4VozrfsID; Wed, 17 Jan 2024 11:30:56 +0100 (CET) Received: from [10.0.1.190] (unknown [161.53.83.23]) by domac.alu.hr (Postfix) with ESMTPSA id 3681860177; Wed, 17 Jan 2024 11:30:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1705487456; bh=iwSt0dX080YAZAjn6l0J2DH9z0NHNrOKDfSGJeVuk2Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=UCZ2W8OWe6R7kIOQORPkPRTQEi4uf3Ss1maQsrE0OcNLWMYJbGVY1S2+JxcnaQtaA 2Dk0gsR4EhZp5UXV+qjyj4Z3w1wtPHOcZ5isE+fPLlRveY2R+IuoQXF9ZR6nTF02a5 41z4NCbpfCr7qVugG3F2JQ8XAw556XGtER+dKO1gJ5vXwV1qBcVMeHjJXp8731lmb/ ate34pEnVTz4Po8vQwNrtVkXb3fOGsHhj6EiwYmNCzsvd6IJW/VyPWQn949ExMCsPs 4HkL8OFm0fff45WNsQA9Z0uio/4meJ4LWTKH2/EwxNc+JZjq7VN6o+O9zmEal1DY2Z ScsjErwWMm3Xg== Message-ID: <4523ad21-d06a-4ba2-9b46-974a6093b189@alu.unizg.hr> Date: Wed, 17 Jan 2024 11:30:53 +0100 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 AUTOSEL 6.7 021/108] r8169: improve RTL8411b phy-down fixup Content-Language: en-US To: Jakub Kicinski , Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Heiner Kallweit , Mirsad Todorovac , Simon Horman , "David S . Miller" , nic_swsd@realtek.com, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org References: <20240116194225.250921-1-sashal@kernel.org> <20240116194225.250921-21-sashal@kernel.org> <20240116174315.2629f21c@kernel.org> From: Mirsad Todorovac In-Reply-To: <20240116174315.2629f21c@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/17/24 02:43, Jakub Kicinski wrote: > On Tue, 16 Jan 2024 14:38:47 -0500 Sasha Levin wrote: >> Mirsad proposed a patch to reduce the number of spinlock lock/unlock >> operations and the function code size. This can be further improved >> because the function sets a consecutive register block. > > Clearly a noop and a lot of LoC changed. I vote to drop this from > the backport. Dear Jakub, I will not argue with a senior developer, but please let me plead for the cause. There are a couple of issues here: 1. Heiner's patch generates smaller and faster code, with 100+ spin_lock_irqsave()/spin_unlock_restore() pairs less. According to this table: [1] https://mirrors.edge.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook-1c.2023.06.11a.pdf#table.3.1 The cost of single lock can be 15.4 - 101.9 ns (for the example CPU), so total savings would be 1709 - 11310 ns. But as the event of PHY power down is not frequent, this might be a insignificant saving indeed. 2. Why I had advertised atomic programming of RTL registers in the first place? The mac_ocp_lock was introduced recently: commit 91c8643578a21e435c412ffbe902bb4b4773e262 Author: Heiner Kallweit Date: Mon Mar 6 22:23:15 2023 +0100 r8169: use spinlock to protect mac ocp register access For disabling ASPM during NAPI poll we'll have to access mac ocp registers in atomic context. This could result in races because a mac ocp read consists of a write to register OCPDR, followed by a read from the same register. Therefore add a spinlock to protect access to mac ocp registers. Reviewed-by: Simon Horman Tested-by: Kai-Heng Feng Tested-by: Holger Hoffstätte Signed-off-by: Heiner Kallweit Signed-off-by: David S. Miller Well, the answer is in the question - the very need for protecting the access to RTL_W(8|16|32) with locks comes from the fact that something was accessing the RTL card asynchronously. Forgive me if this is a stupid question ... Now - do we have a guarantee that the card will not be used asynchronously half-programmed from something else in that case, leading to another spurious lockup? IMHO, shouldn't the entire reprogramming of PHY down recovery of the RTL 8411b be done atomically, under a single spin_lock_irqsave()/spin_unlock_irqrestore() pair? Best regards, Mirsad Todorovac -- CARNet system engineer Faculty of Graphic Arts | Academy of Fine Arts University of Zagreb CARNet sistem inženjer Grafički fakultet | Akademija likovnih umjetnosti Sveučilište u Zagrebu