Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1280283pxb; Fri, 21 Jan 2022 14:13:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJy24YD4IyIBpdY8Jcue/tZJeOTmvtTq9NFLQ2VIiBkQuaaCpis1JSs7F09yznFGgVKIjekF X-Received: by 2002:a17:903:4101:b0:14a:cae5:48a with SMTP id r1-20020a170903410100b0014acae5048amr5675187pld.25.1642803183142; Fri, 21 Jan 2022 14:13:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642803183; cv=none; d=google.com; s=arc-20160816; b=R9wD7eFGnOq6dAnv2AwKhZ/GeV6XjVnHixyufWby3UFALn3TGmKdVWH/e9jb1lJsry 9u5F2Upync9U0MKPg9zUr+B33h3MUJ2/u7VERBCuKjHoctgm7HdVOX3YBdfQfFRKvoKV MeONuc9NR8/ruYL86kVwgiGufkSxTiqiU2srmDwQoaPAHFBLsAgJThDB4frt6/dFvDmO LBBJxyVcToSqlrKpmwBpplK8L1TtSOMSpX8hkKAGLWmfKtIkbgP9fVumNq9Iujjr0P6a 775fa90ARwcHraGhJIrWuzuSE4pG/dutssQVrqFO/POZGQ117u1ZblbQczuwpxXEQkgA jC+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LI7fgGU1QLBmTbo6Itbou4oEcT/ffjAEXYDBbz7bC8o=; b=aAxaj+Km52J1svH2DqR62mOpxIw5s5iWR5k03AlOSiFIW7GOzL9SW85MZ9+1/3dqBe xeP4FrRcSBTHJnhMHrPEVAMQZP2mIVhcOzj6dT+QnFlu4+3XVB1jDLrADriNZOEDIK2v epndXRKYe4f7wnLSmC2RXk74aDrV3gM2XdWKQ/0nDOTEmB4SVp9bjM1kOzOB4rLsd7hN QCtJ8N7nmeY8B1gt7PX59RlSBRa8Jcv8td/jV4Zad7qe6Cs0MN1EmzQBKYjs3MWVIGPg ELKmbjPQZWU0TkUReXidX0OyoJLDbS3daPcNVq6yiEcbWxm7pgzQuItPPAmP3RAS5uLH ytkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=DcGAfY3n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f198si6671776pfa.347.2022.01.21.14.12.51; Fri, 21 Jan 2022 14:13:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=DcGAfY3n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238172AbiATNrC (ORCPT + 99 others); Thu, 20 Jan 2022 08:47:02 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:46274 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235845AbiATNrB (ORCPT ); Thu, 20 Jan 2022 08:47:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=LI7fgGU1QLBmTbo6Itbou4oEcT/ffjAEXYDBbz7bC8o=; b=DcGAfY3n9u4WLa8D6DpfOrUvEA BWinE8CxJwNtOpCkJ0qNrH/j5cIt7/jIP/slGn/CFIBsWkB9yrPSoza2OPvy4fNXZmNa1q4mL6cgJ VI135fzyhLv7Px03eaHzpnh/9ryUvD89FDRrG2b4VfjKxwYl31R8UdrIuAXfIjRUAWXM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nAXmA-001zjh-Ij; Thu, 20 Jan 2022 14:46:54 +0100 Date: Thu, 20 Jan 2022 14:46:54 +0100 From: Andrew Lunn To: Kai-Heng Feng Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net: phy: marvell: Honor phy LED set by system firmware on a Dell hardware Message-ID: References: <20220120051929.1625791-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220120051929.1625791-1-kai.heng.feng@canonical.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 01:19:29PM +0800, Kai-Heng Feng wrote: > BIOS on Dell Edge Gateway 3200 already makes its own phy LED setting, so > instead of setting another value, keep it untouched and restore the saved > value on system resume. Please split this patch into two: Don't touch the LEDs Save and restore the LED configuration over suspend/resume. > -static void marvell_config_led(struct phy_device *phydev) > +static int marvell_find_led_config(struct phy_device *phydev) > { > - u16 def_config; > - int err; > + int def_config; > + > + if (phydev->dev_flags & PHY_USE_FIRMWARE_LED) { > + def_config = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL); > + return def_config < 0 ? -1 : def_config; What about the other two registers which configure the LEDs? Since you talked about suspend/resume, does this machine support WoL? Is the BIOS configuring LED2 to be used as an interrupt when WoL is enabled in the BIOS? Do you need to save/restore that configuration over suspend/review? And prevent the driver from changing the configuration? > +static const struct dmi_system_id platform_flags[] = { > + { > + .matches = { > + DMI_MATCH(DMI_SYS_VENDOR, "Dell EMC"), > + DMI_MATCH(DMI_PRODUCT_NAME, "Edge Gateway 3200"), > + }, > + .driver_data = (void *)PHY_USE_FIRMWARE_LED, > + }, This needs a big fat warning, that it will affect all LEDs for PHYs which linux is driving, on that machine. So PHYs on USB dongles, PHYs in SFPs, PHYs on plugin PCIe card etc. Have you talked with Dells Product Manager and do they understand the implications of this? > + {} > +}; > + > /** > * phy_attach_direct - attach a network device to a given PHY device pointer > * @dev: network device to attach > @@ -1363,6 +1379,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > struct mii_bus *bus = phydev->mdio.bus; > struct device *d = &phydev->mdio.dev; > struct module *ndev_owner = NULL; > + const struct dmi_system_id *dmi; > bool using_genphy = false; > int err; > > @@ -1443,6 +1460,10 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > phydev_err(phydev, "error creating 'phy_standalone' sysfs entry\n"); > } > > + dmi = dmi_first_match(platform_flags); > + if (dmi) > + phydev->dev_flags |= (u32)dmi->driver_data; Please us your new flag directly. We don't want this abused to pass any old flag to the PHY. > + > /** > * struct phy_device - An instance of a PHY > * > @@ -663,6 +665,7 @@ struct phy_device { > > struct phy_led_trigger *led_link_trigger; > #endif > + int led_config; You cannot put this here because you don't know how many registers are used to hold the configuration. Marvell has 3, other drivers can have other numbers. The information needs to be saved into the drivers on priv structure. > > /* > * Interrupt number for this PHY > @@ -776,6 +779,12 @@ struct phy_driver { > */ > int (*config_init)(struct phy_device *phydev); > > + /** > + * @config_led: Called to config the PHY LED, > + * Use the resume flag to indicate init or resume > + */ > + void (*config_led)(struct phy_device *phydev, bool resume); I don't see any need for this. Andrew