From patchwork Tue Mar 26 16:29:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Ignacio Tornos Martinez X-Patchwork-Id: 13604656 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 BBC8A13CC73 for ; Tue, 26 Mar 2024 16:30:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711470604; cv=none; b=aNQ1Te5BhkW3qyp8WS+klMcaJaZYjxIFmb6hG2pKscQMUDOfKoO0ZYaOvGDizzUOfPgKTJrrPmfet0AicJZEbm5XcXW3Lra0Pr5RplagZiEQG42FGfOM71j8Zw1pNXD9Eu2eqpXZUww+6fgozEmThIq8cdKIe05GxSCImz42LM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711470604; c=relaxed/simple; bh=rjSUXjjrKiWdU5sbS7+AjRgyC6HxieupC43ocaHS1/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pRDWxOwJIow9kdyGyEyzbA10yC4Ly27IzupT5eFGjtmxASI0+ZlFyg5G5W6rgFI4/wih8V7sWK13lpGGSC9N1s2T2Wh9D94pbOCltcwQQO+bwa6HBR0AoExLGTd8WNFvi3YxroP/8/XLxTnQYH/d45weqkg35ApqS6la/KWA8dM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZyTBAEX+; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZyTBAEX+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711470601; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7eFdufef3zYONep2oCLblhXQDLYYjXipt4Q1WaXEK5M=; b=ZyTBAEX+RNhdRROOQXNx3PoU8NbZhFoBrFAMGkKZurA28b7m1DWNsODKho5CdXuOYSa5to U6Qbp8cMUWUUZNL59rjiicojlVj4wKZ+ggwoIL+LYdMOOymOcTo+OiOjdVlWEobMujN1FZ /YuiTtS7TPeLlGDc1EQ5mF7gDUYOcVo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-okaYP1U4PZu-9kpR-wRCZA-1; Tue, 26 Mar 2024 12:29:57 -0400 X-MC-Unique: okaYP1U4PZu-9kpR-wRCZA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B465380F7E3; Tue, 26 Mar 2024 16:29:56 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.193.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id D056A1C060D4; Tue, 26 Mar 2024 16:29:53 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: horms@kernel.org Cc: dave.stevenson@raspberrypi.com, davem@davemloft.net, edumazet@google.com, jtornosm@redhat.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, stable@vger.kernel.org Subject: [PATCH v2 1/2] net: usb: ax88179_178a: avoid the interface always configured as random address Date: Tue, 26 Mar 2024 17:29:43 +0100 Message-ID: <20240326162943.306577-1-jtornosm@redhat.com> In-Reply-To: <20240326092459.GG403975@kernel.org> References: <20240326092459.GG403975@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Patchwork-Delegate: kuba@kernel.org After the commit d2689b6a86b9 ("net: usb: ax88179_178a: avoid two consecutive device resets"), reset is not executed from bind operation and mac address is not read from the device registers or the devicetree at that moment. Since the check to configure if the assigned mac address is random or not for the interface, happens after the bind operation from usbnet_probe, the interface keeps configured as random address, although the address is correctly read and set during open operation (the only reset now). In order to keep only one reset for the device and to avoid the interface always configured as random address, after reset, configure correctly the suitable field from the driver, if the mac address is read successfully from the device registers or the devicetree. cc: stable@vger.kernel.org # 6.6+ Fixes: d2689b6a86b9 ("net: usb: ax88179_178a: avoid two consecutive device resets") Reported-by: Dave Stevenson Signed-off-by: Jose Ignacio Tornos Martinez --- V1 -> V2: - Split the fix and the improvement in two patches as Simon Horman suggests. drivers/net/usb/ax88179_178a.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index 88e084534853..8ca8ace93d9c 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c @@ -1273,6 +1273,7 @@ static void ax88179_get_mac_addr(struct usbnet *dev) if (is_valid_ether_addr(mac)) { eth_hw_addr_set(dev->net, mac); + dev->net->addr_assign_type = NET_ADDR_PERM; } else { netdev_info(dev->net, "invalid MAC address, using random\n"); eth_hw_addr_random(dev->net); From patchwork Tue Mar 26 16:31:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Ignacio Tornos Martinez X-Patchwork-Id: 13604657 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 7BCC2C138 for ; Tue, 26 Mar 2024 16:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711470721; cv=none; b=Ik54/RYxF6Z4HiDq224Af4fNTjL4f7xfYpPXOj13xECMf7Svy+gyiOhIolDe8Sb2YbEeuy8bfq/9UZx9JHqMUAqivbN2C4OeKonlzcN49Wp6gbcAikMpt6JAJsr6YY1uejbCLdnLgNiuYT4khDnmA0gOF8HUh3J8qoNAZgAmtuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711470721; c=relaxed/simple; bh=+zJiSFJrk/XKOS5ppHx/5iDVjPDpD/O/rYYxY9qcQBY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QztdWo4OjHhcBAfBUUcwB85NpG+l1a2at7ZlB7IRYsS+vTD9cB9G4x/R6x2cW8U9DhcsdBfCPRBiVicpR3rNOO2Ia+fwePmegBUwjj0ZQW4MkxdketS+hYM79bCN7mWxdwBeyEefjOySRspzm81gf+fKNciYvb4w2Ye+GNGVF7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fbNgat0f; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fbNgat0f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711470718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hIMLqIfssOdXqJZFHxIfokX5il4SRVSK3jc88qoSirw=; b=fbNgat0f9rgYlPgwsNDAVhYJWf1hCgsmcJQEUYMiHA2g4Ru8hOF6ZGCDyLHGdVUCCS4+Sx NltLIHTSsP6q3UpD4wGDSO+1SwUOmky3H4oJlcxMkXHyx1b1OmsdQblZbfA49hAaeSSgb8 PZ44Biap3c+VcMKE8LxUpjd8FVMBOWQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-ol52tx1iOu-jYNW4xbojQg-1; Tue, 26 Mar 2024 12:31:55 -0400 X-MC-Unique: ol52tx1iOu-jYNW4xbojQg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C29A800274; Tue, 26 Mar 2024 16:31:55 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.193.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84280C15772; Tue, 26 Mar 2024 16:31:52 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: horms@kernel.org Cc: dave.stevenson@raspberrypi.com, davem@davemloft.net, edumazet@google.com, jtornosm@redhat.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, stable@vger.kernel.org Subject: [PATCH v2 2/2] net: usb: ax88179_178a: non necessary second random mac address Date: Tue, 26 Mar 2024 17:31:07 +0100 Message-ID: <20240326163107.306612-1-jtornosm@redhat.com> In-Reply-To: <20240326092459.GG403975@kernel.org> References: <20240326092459.GG403975@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Patchwork-Delegate: kuba@kernel.org If the mac address can not be read from the device registers or the devicetree, a random address is generated, but this was already done from usbnet_probe, so it is not necessary to call eth_hw_addr_random from here again to generate another random address. Indeed, when reset was also executed from bind, generate another random mac address invalidated the check from usbnet_probe to configure if the assigned mac address for the interface was random or not, because it is comparing with the initial generated random address. Now, with only a reset from open operation, it is just a harmless simplification. cc: stable@vger.kernel.org # 6.6+ Fixes: 9fb137aef34e ("net: usb: ax88179_178a: allow optionally getting mac address from device tree") Signed-off-by: Jose Ignacio Tornos Martinez --- V1 -> V2: - Split the fix and the improvement in two patches and keep curly-brackets as Simon Horman suggests. drivers/net/usb/ax88179_178a.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index 8ca8ace93d9c..08c9b2ab9711 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c @@ -1276,7 +1276,6 @@ static void ax88179_get_mac_addr(struct usbnet *dev) dev->net->addr_assign_type = NET_ADDR_PERM; } else { netdev_info(dev->net, "invalid MAC address, using random\n"); - eth_hw_addr_random(dev->net); } ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN,