From patchwork Thu Feb 15 18:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 201723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp81594dyb; Thu, 15 Feb 2024 11:49:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUTWWzC8tatFLss9Tboia6SBb0lETlWe/++AUYv2SqmdF4TxxbP/q5ejEMGMYlSwRWeKXHvnpBmUcDgCXzANExvgGVpRQ== X-Google-Smtp-Source: AGHT+IHB0cr7jK7L/r8AgZIbo9sMYHmteIiFJZMMXVIEqgLwAK5K7nBhpw/LPCwm1+BGoKo8/9c7 X-Received: by 2002:a17:90a:bb89:b0:296:4c7d:8fca with SMTP id v9-20020a17090abb8900b002964c7d8fcamr2859065pjr.25.1708026585737; Thu, 15 Feb 2024 11:49:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708026585; cv=pass; d=google.com; s=arc-20160816; b=tYxiX4UUZ5EBEJi3fL8q4BjA4L9XSS5WZNQ+t/7aItyKrEA/OOTOARKsMPWUrQZ20c XeGAdKXOzEdPjCj+cjnbns0yIiwWKumy5tviJHMPmFIQ1uahzxuLPkJhOEyflCVAUBXj Xb5GlPl+2SX1t8DOXw959+/wlZ953A59ODwEGjuq01AfkMOQMntaY5zwqWm9mDf63Y+5 jcP4eO5UXYPNg/3WLcEj8IR/Bh8E7xh8CWd5EBuxEzYuwF5L5imfhkKYyZ4oUbgI+9fF m8c4g8up2yx+TVFHwcaKQiSoskP4685CXP4p9TNIAZ3/Xb0IrDTUKMXr763mzwudSu1Y gWNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iWvamRPa010oDBPvLHGOQI7U/I1KkMGFzljSlQooH4c=; fh=l2OKHc1IbmjwtP84rQE5m+XX6I0z6uuk/Evrdgxq5/s=; b=xbIBjW9Sdy7cir4DvLVUKjzrllWywXTt95cPeURAglQYY45WtSpnulSHhnYOYRXvl/ 8S8N35/H/x4IUxeUPw6vkL99U4KtUq+mr3KHxKn51JZbWX5Y9JnyD93R8ejFgMYPBGCm WtLmkTwcbVvOg50TJHJ9spZQEQKEbjI3bbnjIO6AREC4zx28eRk8Bu4d7x/fMdIaf6rQ tosRqWAzdyMBROizD4vIX1cW6mYLAH9XA/ZzLNaumiJBIH7GrtRMx00gWu8AuxwBf4SD Z+SasNEblV4E0iaCM8FSW7gm+W/Vz83DuginafnOMJhWn9I3CVUQxE1c9Z/3Dbu7HSiB updQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=G0H340WL; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-67507-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67507-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id sh2-20020a17090b524200b00298d20b379bsi1695570pjb.68.2024.02.15.11.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:49:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67507-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=G0H340WL; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-67507-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67507-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3A99428F7D8 for ; Thu, 15 Feb 2024 18:32:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9282E13AA4F; Thu, 15 Feb 2024 18:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="G0H340WL" Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) (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 1D71713A26F for ; Thu, 15 Feb 2024 18:27:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021660; cv=none; b=oCbEigJS71gEfP6p8CkEqsPEa9aE9OKBdPTT/D3x88tzt06X6Kv7P0eWhdmHcHV7SzZmLC5Lfvf0igupQOwNgwTsAmBWElzXCygt2s7NhfnXDV5mc4eEqR13q1+HcB8Y2zoVFGcxJGYcfMLKXdtD0DtNiA6PccjiXaKmew1RvYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021660; c=relaxed/simple; bh=sf2J1R72NttaMwiXPSuml6mpSaVqcNW49OejKEyn4DY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=kSYpk8ay5eolMD03j4JWyd261HFosOYnpBAfUWEK3UMixUJ/bEV9SNZ+EN6dFOzSw/we1V8m6deaswjZk8gd1Szz3qIDC7SGHk5UngEjIIPfVZhPTZzQ87oyH4MkUFEoGnkDozFwJuXz+VEVN8feEbMIFKfbTrA3oesTDicUxGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=G0H340WL; arc=none smtp.client-ip=209.85.221.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-4c02af52a21so455606e0c.3 for ; Thu, 15 Feb 2024 10:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1708021658; x=1708626458; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=iWvamRPa010oDBPvLHGOQI7U/I1KkMGFzljSlQooH4c=; b=G0H340WLfqPwQtIdAQc5MFkoqvPzScd55OW7795IoV5QUCK88zXY2bGcA07d7WEgRH sSoUAjvV4GWuaXW/af5vcRosJO8jPshJEcchrq6K7+Ypg3iJjGBHp5YhSN6Hc9AjpF2s SMJliLZuw0cD2AB6QWL+6Odr6iIi1k0jjf7WU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708021658; x=1708626458; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iWvamRPa010oDBPvLHGOQI7U/I1KkMGFzljSlQooH4c=; b=KRuBuV+4x7YIPQ/MVHhXMKg1faVRTVqGBJ2sImSFCC0Bt7i76Nun0x4lrKyTE4g+ZO 2GA700Tm6CBmLnGVPAKCGqM3RIn4BSgGAZGTNayP8PFP/AYpdGApJTCr5siwX+36t1ZF wFILKxBQjBzgzro3Xir4x81P6LpWuizm844W5sTZQUJWtOfyHOY6Nuu2DDq2bR2qBHRS KQnKJVzdiqG8BMAiSUPic/jLxfp1Wx1I0XyNMc2LuwZxz4lZOkBka0lX1qO6yrZCjQO1 ZhvJbpCVash/NQznvMErCTU6LvZOwtybHDji+1diqjzydlVji72kJYw0zOFWZOpm55LD edUg== X-Forwarded-Encrypted: i=1; AJvYcCW6wtj+BQZJfLcPvHAhvKGSesylYl+fxgZPPVgQVgJQjq0r6VgkbrU9aaweTLksfheBGBwbn0qhjcA39ft640/nXA1GQ+94+KeCmo2N X-Gm-Message-State: AOJu0YzL4VLRdmg0qFxnE//mpq//4rweUQeIGumGSTqqkwLPFFDWGtlx hF0TA8v0ckOx/5y+grulho/kMsM6YRVHCjupPKoDdPT6D9nGwLFV6w/ry5rhkw== X-Received: by 2002:a1f:e042:0:b0:4c0:fda:7d8c with SMTP id x63-20020a1fe042000000b004c00fda7d8cmr2724538vkg.2.1708021657784; Thu, 15 Feb 2024 10:27:37 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id mf4-20020a0562145d8400b0068f13038031sm901515qvb.5.2024.02.15.10.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:27:37 -0800 (PST) From: Justin Chen To: netdev@vger.kernel.org Cc: Florian Fainelli , Justin Chen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , bcm-kernel-feedback-list@broadcom.com (open list:BROADCOM ASP 2.0 ETHERNET DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] net: bcmasp: Indicate MAC is in charge of PHY PM Date: Thu, 15 Feb 2024 10:27:31 -0800 Message-Id: <20240215182732.1536941-2-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215182732.1536941-1-justin.chen@broadcom.com> References: <20240215182732.1536941-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790995685437438907 X-GMAIL-MSGID: 1790995685437438907 From: Florian Fainelli Avoid the PHY library call unnecessarily into the suspend/resume functions by setting phydev->mac_managed_pm to true. The ASP driver essentially does exactly what mdio_bus_phy_resume() does. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller") Signed-off-by: Florian Fainelli Signed-off-by: Justin Chen --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c index f59557b0cd51..6ad1366270f7 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -1050,6 +1050,9 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) netdev_err(dev, "could not attach to PHY\n"); goto err_phy_disable; } + + /* Indicate that the MAC is responsible for PHY PM */ + phydev->mac_managed_pm = true; } else if (!intf->wolopts) { ret = phy_resume(dev->phydev); if (ret) From patchwork Thu Feb 15 18:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 201724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp81796dyb; Thu, 15 Feb 2024 11:50:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWIoMdJQsq05UhCGejAXgnEO1Z0ALeTx6e9FkaBW+rn3DUUM1ywhTP1gDezF1B1syjVTAyNYCqADa+KH/rM4FZbkonF5g== X-Google-Smtp-Source: AGHT+IERmaWm34vAPf8jA/BJqceJIDyInFtlnOylPF56I4Qn8tGJge8qHjHQXZOBLuqFU2cOrvkE X-Received: by 2002:a05:6358:706:b0:178:8a53:87f with SMTP id e6-20020a056358070600b001788a53087fmr2979995rwj.1.1708026614486; Thu, 15 Feb 2024 11:50:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708026614; cv=pass; d=google.com; s=arc-20160816; b=uLUZPZBbCaQtqOrhkNt47aXwnyjiA8yBbSyaN5of+xK8V2NH8KN7jJ2+/1Qk1w6LoH v8/KGMdjmycw4Pc4sJb78GM6Rod/vYxRppKkj+WF0rNwCr1T7ElIXD/IJOe0rg2yimms KhK0+ZJksRQ0hS+5YDI68sFJ+fw1epiLKQD6wBoahcf2vau8ZwImynlL/YR5XyA+pBx4 TjjPcIH36dkE4abyPc/EuqFQ7EWRbrvpo9OF0C6SHhdsdtlb3RkWFy4Jl298SYeKwHo2 afsX59alur+wkFqPW+Edd+BydPV8/03RjpnTyoeJQZBpMCGQxElS4VcTNcEAqyWL6N+w or5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fl0lbVWFk7esL9ghuxTeB/l0ggA63ROJq7hUF6DPi6w=; fh=wwtHFuHvBN9hgrPXd8aoRO0YhsRYOLrVUU7vlkjW028=; b=DJkFZRJWFpFFVknxdKjYDLqVEHWqLpYiY0SywkEU4NmmaAZoWw10b/mQBK/kDcNxdA LxqPYW9A2LqSSJoE4JPiEepAo9LqwtmV1ydz347aY/l5NS7Jw4wGlHiG0IWcRVCAXic4 KbOpa+BxCWWfajb2976pvdbWsyL3gBPxdwgqz4GElbYZJPTx/Y3mKY7zfUOZgS73rRwj t+UYTLgaWIYLzAF440e2TUdZ2EkRaylriFKw3SD9NqwS0EYxDrs45j1fVegveop1ZQJO YwVH2pEMy1wLagVRafXUSsPgjayTqe/r6m1Cs7PGWfz5ilf2T7IUqvzlbDx4qKLGR3N1 ZUpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="YU7/lnHs"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-67508-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67508-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id by24-20020a056a02059800b005dc365174desi1678803pgb.377.2024.02.15.11.50.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:50:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67508-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="YU7/lnHs"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-67508-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67508-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EBB1E28FA1E for ; Thu, 15 Feb 2024 18:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1441713B280; Thu, 15 Feb 2024 18:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="YU7/lnHs" Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 BDC2B13A274 for ; Thu, 15 Feb 2024 18:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021662; cv=none; b=bdYzZP5IT4ZSAbl5eK8UcODFg7Z7OL2Qx7YnMoIyNDaLPlqfRDYJQkMMS0XUe8YHmf6/Dc5x679vER0mfayF+pxVM6GZ2Z0pXiC5HEMbCMStqtvT3KgbWk9XAnn9P279XSw88EmfPd25oZmC+9VhmAh1k6Zd1Kj7y3BIcUX9x/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021662; c=relaxed/simple; bh=jLl9Z2fTsH6Rmmj0FW2/msC3++4LT5xvr/9S1+KPYzA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=K9kOHivMWBSiwTIOwksTicFVMHh8b9Mi8EKkdhY6ZYSPAZHJ5lliFdGYRGbmQ4W+Xpf6vqhC5s85yDubm38Gdv3n8cJnRs1ghEls7P/wA9V3iUj/LqCPiDKBVt36yxpo+XOLWYX12dHRuRpOT3VW1p33IfOLdYa1nfUnQpxwbXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=YU7/lnHs; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3bba50cd318so880960b6e.0 for ; Thu, 15 Feb 2024 10:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1708021659; x=1708626459; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=fl0lbVWFk7esL9ghuxTeB/l0ggA63ROJq7hUF6DPi6w=; b=YU7/lnHsQoJeqkvEOK5GYtMOyjHq/z0SfwK9I9VPg+VMiK7yRSgzGQxsBKg71AQ7Lq jYipdrdVAYC/6jjWRhrDG4t8MZsh6EVgMuIvSe6TnbQ1kZXC6Eb1M50dyR9S3wuprADV WicDfTISCWCdQHeXKmJ/HzolGjD+8UBh45DWs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708021659; x=1708626459; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fl0lbVWFk7esL9ghuxTeB/l0ggA63ROJq7hUF6DPi6w=; b=e/xtzJWgUYGlCtLCMqQVDtV2vIGtHghqb9Xbc0U/j0jfPeIVR3VKjzMkFVFwfhxi02 u8K/ea7imLDvU+fmIeJ/JFlH3sKPrJom7O5gtWK2cTDgJX4m1xmGGEqIQ25Ci88nqxN2 DdRhgFgSyBQGSndL2aTr3Acx5dalkkMumDs4DGeJDUcttBfuW85xt404O3AWlXsJiAAN Hp2lDGaKgQjWxxY/XssEP58SsZrBxuF3cTMDUUoHirpcTSHVRb8+Cx1Kc/TDMp6BcBCX r1poJq4pJk8ut31jONwFW0vwQUc9Sb0XVAqSI86mxC+HW3WTC+oESZouzxYWSM02N9wg ukAw== X-Forwarded-Encrypted: i=1; AJvYcCUuSkwlFv7k8pFT/LN1M+6pbFfBImFZDK1hQoC7k8dvAtrAenTOutlEsT0liBF8jhmOTilrN+VJNuyNGPYnXnR74Lu8OxNKw+YXl7v9 X-Gm-Message-State: AOJu0YxCIOZu3Uf7aYQIlbP1PGh0TKBwKTu94NdOqrt3CbOfQLAwC/Dz m5VV7Ius9nWBs3REk+M9JZqqV66QV6HOPLhHKyAhFKLl2KsHu7gEghsFyom9lQ== X-Received: by 2002:a05:6808:9a3:b0:3c0:326a:9cff with SMTP id e3-20020a05680809a300b003c0326a9cffmr2709373oig.23.1708021659611; Thu, 15 Feb 2024 10:27:39 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id mf4-20020a0562145d8400b0068f13038031sm901515qvb.5.2024.02.15.10.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:27:39 -0800 (PST) From: Justin Chen To: netdev@vger.kernel.org Cc: Justin Chen , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Hangyu Hua , bcm-kernel-feedback-list@broadcom.com (open list:BROADCOM ASP 2.0 ETHERNET DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] net: bcmasp: Sanity check is off by one Date: Thu, 15 Feb 2024 10:27:32 -0800 Message-Id: <20240215182732.1536941-3-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215182732.1536941-1-justin.chen@broadcom.com> References: <20240215182732.1536941-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790995715491500969 X-GMAIL-MSGID: 1790995715491500969 A sanity check for OOB write is off by one leading to a false positive when the array is full. Fixes: 9b90aca97f6d ("net: ethernet: bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active()") Signed-off-by: Justin Chen Reviewed-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c index 29b04a274d07..80245c65cc90 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c @@ -535,9 +535,6 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, int j = 0, i; for (i = 0; i < NUM_NET_FILTERS; i++) { - if (j == *rule_cnt) - return -EMSGSIZE; - if (!priv->net_filters[i].claimed || priv->net_filters[i].port != intf->port) continue; @@ -547,6 +544,9 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, priv->net_filters[i - 1].wake_filter) continue; + if (j == *rule_cnt) + return -EMSGSIZE; + rule_locs[j++] = priv->net_filters[i].fs.location; }