From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 62F0013664F for ; Thu, 7 Mar 2024 18:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709837578; cv=none; b=KOWKYI/k7JrGoEmowZBfeO8TEprP/WcvXfWxk0bEyvVRT5IvWNmla2H6FcouBaGRAwcfj4SkCJM8XDUxHlrzSLyVzVomQFZ4Zo2rORq3oHNG5NVvHO/7MZF9dJS0rTbeCic9QgowNtO75E1YWl0AMgHCNLUQrffKmCBPfUYoWHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709837578; c=relaxed/simple; bh=n3Kll0juBLOTNi3cn/fisBNxbSwgu3KXTXnol1lKayg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fTNK3cd5utwVIcLBOWOOG/nZ4KgH6JtdpUR0YbREeMfF+GE6Y/k8Zyyq7/FyI0n0i25K9t0PN6qs6hknCM93I/4t/8NzzZQH6oi+CdviFf1mrVHMM9uAQfkv8UeRkEQela2xexYlbRBJS3gxZOLK9MAj1RWWkVsGoBgx0ADUJB8= 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=gqFhXsHD; arc=none smtp.client-ip=209.85.214.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gqFhXsHD" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1dd10ae77d8so10989205ad.0 for ; Thu, 07 Mar 2024 10:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709837577; x=1710442377; darn=lists.linux.dev; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=AQQbLvgd4v+h8o0thODyrb8/bjQo/5KA5hZsJKz+3js=; b=gqFhXsHD8fr+yaUrv2nCZ6ER8wSRiuoVidpSpSRlqS9Dq8TEW05+G//WvoasdU/1mH zOLJQPvWp6Z6iT3GYpIoQpcWAKB8bY+7vgD9aAjl7oMCmONFqeKZxzHlaLWEuwtmuy5P Y9VDOee/9U4nJdBiRXLt01KkWR9gpbxrO3XOp/qXLbzKsyutZ+1ucHdJ5gw6i1eqIyIr evb6iTTKurxabpm1AWWYwGG28MZhYKBpo7X3XDNyCAfzT9o3dRjHCefTJdilMEfiSj/4 b1JZj3Ju7JK8uPZSkzTcQcGTzTRn0YE2vGJ6tyQ7BSe4lZlr9FMUeB0xT4jvLTS5x4nS spgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709837577; x=1710442377; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AQQbLvgd4v+h8o0thODyrb8/bjQo/5KA5hZsJKz+3js=; b=SsjkjcIbRMZKhqUECd9van9ief1IABtqlyrbQ6Dh8mA8WLyNPQh2i9mWsFdgfSyyKF bmsRK/WKkFF4nUiU83lw0SFMTaXfQgW0oLaIZJhAefVFfbgSlpdeOvMtyVBogEREhCaj eNngpaLYlNiDgfSOz/wY8CeYRYe1sC6EU3wcjyweaAGa8WS50uhngHA1C4t9vBMkN7jA GnJQTRVW29JQMZ+WbEWBtcKk1cVxBv6nG1gs686Kxm+sirI3sPnzc22hdy9+hKUqWXCN otZMpRth+lU4kra+ek8os4VOaOZF05peEtlnhoQcf8jNFbE1e7dZlf7tr0fA7dcR48ip NpCA== X-Forwarded-Encrypted: i=1; AJvYcCVFfKTTDSDDOQeS0l8fkpPzg1s5oU5wQE40RkuemkCi1l993TmuDX0e0sAduDEIGyxdA+VYRPAHPcirg4jAD8eJl2Oj X-Gm-Message-State: AOJu0Yw4cL+BX1/ESNFbfAkea547rozglRgvLMdU6gC7ltGDvushh0eq 6OFYmAr6nNhDaIxgRuqZLy04BGpBnFwZWch9BxaN1/YYvT8xy0Yr X-Google-Smtp-Source: AGHT+IHilBvCxdXn41263FwRkBDdMvd1VAR4rFaj12NiHdSFgglCEdzYUDfHPeuKZHjeIbrP8grRZQ== X-Received: by 2002:a17:902:db05:b0:1dd:46ca:18a1 with SMTP id m5-20020a170902db0500b001dd46ca18a1mr3650307plx.34.1709837576535; Thu, 07 Mar 2024 10:52:56 -0800 (PST) Received: from [192.168.1.3] (ip68-4-215-93.oc.oc.cox.net. [68.4.215.93]) by smtp.gmail.com with ESMTPSA id v10-20020a170902f0ca00b001dd635551f1sm385706pla.255.2024.03.07.10.52.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Mar 2024 10:52:56 -0800 (PST) Message-ID: Date: Thu, 7 Mar 2024 10:52:50 -0800 Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next 2/2] net: stmmac: dwmac-imx: add support for PHY WOL Content-Language: en-US To: POPESCU Catalin , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "robh@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , "xiaoning.wang@nxp.com" , "linux-imx@nxp.com" , "alexandre.torgue@foss.st.com" , "joabreu@synopsys.com" , "mcoquelin.stm32@gmail.com" Cc: "netdev@vger.kernel.org" , "devicetree@vger.kernel.org" , "imx@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , GEO-CHHER-bsp-development , "m.felsch@pengutronix.de" References: <20240306172409.878928-1-catalin.popescu@leica-geosystems.com> <20240306172409.878928-2-catalin.popescu@leica-geosystems.com> From: Florian Fainelli Autocrypt: addr=f.fainelli@gmail.com; keydata= xsDiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu9cSDvWtO1hXeHIfQIE/xcqvlRH783KrihLcsmnBqOiS6rJDO2x1eAgC8meAX SAgsrBhcgGl2Rl5gh/jkeA5ykwbxA/9u1eEuL70Qzt5APJmqVXR+kWvrqdBVPoUNy/tQ8mYc nzJJ63ng3tHhnwHXZOu8hL4nqwlYHRa9eeglXYhBqja4ZvIvCEqSmEukfivk+DlIgVoOAJbh qIWgvr3SIEuR6ayY3f5j0f2ejUMYlYYnKdiHXFlF9uXm1ELrb0YX4GMHz80nRmxvcmlhbiBG YWluZWxsaSA8Zi5mYWluZWxsaUBnbWFpbC5jb20+wmYEExECACYCGyMGCwkIBwMCBBUCCAME FgIDAQIeAQIXgAUCVF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PB2izX+ HZA8SL54j479ubxhfuoTu5nXdtFYFj5Lj5x34LKPx7MpgAmj0H7SDhpFWF2FzcC1bjiW9mjW HaKaX23Awt97AqQZXegbfkJwX2Y53ufq8Np3e1542lh3/mpiGSilCsaTahEGrHK+lIusl6mz Joil+u3k01ofvJMK0ZdzGUZ/aPMZ16LofjFA+MNxWrZFrkYmiGdv+LG45zSlZyIvzSiG2lKy kuVag+IijCIom78P9jRtB1q1Q5lwZp2TLAJlz92DmFwBg1hyFzwDADjZ2nrDxKUiybXIgZp9 aU2d++ptEGCVJOfEW4qpWCCLPbOT7XBr+g/4H3qWbs3j/cDDq7LuVYIe+wchy/iXEJaQVeTC y5arMQorqTFWlEOgRA8OP47L9knl9i4xuR0euV6DChDrguup2aJVU8JPBBgRAgAPAhsMBQJU X9LxBQkeXB3fAAoJEGFXmRW1Y3YOj4UAn3nrFLPZekMeqX5aD/aq/dsbXSfyAKC45Go0YyxV HGuUuzv+GKZ6nsysJw== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/7/2024 1:13 AM, POPESCU Catalin wrote: > On 06.03.24 18:41, Florian Fainelli wrote: >> [Some people who received this message don't often get email from >> f.fainelli@gmail.com. Learn why this is important at >> https://aka.ms/LearnAboutSenderIdentification ] >> >> This email is not from Hexagon’s Office 365 instance. Please be >> careful while clicking links, opening attachments, or replying to this >> email. >> >> >> On 3/6/24 09:24, Catalin Popescu wrote: >>> Add support for PHY WOL capability into dwmac-imx MAC driver. >>> This is required to enable WOL feature on a platform where MAC >>> WOL capability is not sufficient and WOL capability built into >>> the PHY is actually needed. >>> >>> Signed-off-by: Catalin Popescu >> >> Nope, this is not about how to do this. You use a Device Tree property >> as a policy rather than properly describe your systems capabilities. > I'm not sure what policy means in that context. > BTW, dwmac-mediatek does the same with binding "mediatek,mac-wol" which > is a commit from 03/2022. Policy here means you want a certain behavior from the OS that is consuming the Device Tree, and that behavior is encoded via a Device Tree property. This is different from describing how the hardware works which does not make any provisions for getting a behavior out of the OS. > I understand this way of doing became "unacceptable" since then ?? It was not acceptable then, but there is only a limited reviewer time, and it is easy unfortunately to sneak through reviewers. >> >> What sort of Wake-on-LAN do you want to be done by the PHY exactly? Does >> the PHY have packet matching capabilities, or do you want to wake-up >> from a PHY event like link up/down/any interrupt? > > PHY is TI dp83826 and has secure magic packet capability. For the wakeup > we rely on a external MCU which is signaled through a PHY's GPIO which > toggles only on magic packet reception. > We want to wakeup _only_ on magic packet reception. Then you need to represent that wake-up GPIO line in the Device Tree, associate it with the PHY's Device Tree node for starters and add in a 'wakeup-source' property in the Device Tree. Now the PHY driver can know about the existence of a GPIO and it can know the PHY is a system wake-up source, so the driver can call device_set_wakeup_capable(). In user-space you have to configure the network interface with WAKE_MAGICSECURE which needs to propagate to the PHY driver for adequate configuration. Still in user-space you need to make the PHY device wake-up *enabled* by doing: echo "enable" > /sys/class/net/ethX/attached_phydev/power/wakeup If both WAKE_MAGICSECURE is enabled and the PHY device in sysfs reports that it is wake-up enabled would you wake-up from the PHY's GPIO. Your PHY driver ought to be modified to check for both device_wakeup_enabled() and wolopts being non-zero to call enable_irq_wake() on the GPIO interrupt line. That's how I would go about doing this, yes it's a tad more complicated than adding an ad-hoc Device Tree property, but it's more flexible and it's transposable to other configurations, too. Whether that sort of encoding needs to be in the individual PHY drivers or somewhere in the PHY library can be decided if we have more than one similar configuration to support. > >> >> If the former, then you would need to interrogate the PHY driver via >> phy_ethtool_get_wol() to figure out what Wake-on-LAN modes it is capable >> of supporting and then make a decision whether to prioritize Wake-on-LAN >> from the PHY or the MAC, or maybe only the PHY can actually wake-up the >> system in your case. >> > stmmac already calls phy_ethtool_get_wol/phy_ethtool_set_wol through > phylink_ethtool_get_wol/phylink_ethtool_set_wol. But needs flag > STMMAC_FLAG_USE_PHY_WOL to be set. Otherwise, it will only work with MAC > WOL which we don't want. With the new binding we just allow the MAC > driver to call the PHY for the WOL capability. This doesn't force WOL to > enabled or disabled, as it is still up to ethtool to configure it. >> If the latter, then you need to add support for WAKE_PHY to the stmmac >> driver. > No, we don't want WAKE_PHY, we want WAKE_MAGIC/WAKE_MAGICSECURE which > stmmac driver already supports. Does not matter, it should be up to user-space to intersect between what the PHY is capable of waking you from, and what the intent is. -- Florian