From patchwork Wed Oct 10 14:29:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 981923 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42VcCn2ly7z9s7T for ; Thu, 11 Oct 2018 01:38:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbeJJWAz (ORCPT ); Wed, 10 Oct 2018 18:00:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:38262 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726665AbeJJWAz (ORCPT ); Wed, 10 Oct 2018 18:00:55 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 52A65B0E7; Wed, 10 Oct 2018 14:38:26 +0000 (UTC) From: Oliver Neukum To: netdev@vger.kernel.org, davem@davemloft.net, jkohoutek@suse.com, mario_limonciello@dell.com Cc: Oliver Neukum Subject: [PATCH] r8152: limit MAC pass-through to one device Date: Wed, 10 Oct 2018 16:29:33 +0200 Message-Id: <20181010142933.31051-1-oneukum@suse.com> X-Mailer: git-send-email 2.16.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org MAC address having to be unique, a MAC coming from the host must be used at most once at a time. Hence the users must be recorded and additional users must fall back to conventional methods. Signed-off-by: Oliver Neukum Fixes: 34ee32c9a5696 ("r8152: Add support for setting pass through MAC address on RTL8153-AD") --- drivers/net/usb/r8152.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index f1b5201cc320..7345a2258ee4 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -766,6 +766,9 @@ enum tx_csum_stat { TX_CSUM_NONE }; +/* pass through MACs are per host, hence concurrent use is forbidden */ +static struct r8152 *pass_through_user = NULL; + /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). * The RTL chips use a 64 element hash table based on the Ethernet CRC. */ @@ -1221,7 +1224,14 @@ static int set_ethernet_addr(struct r8152 *tp) * or system doesn't provide valid _SB.AMAC this will be * be expected to non-zero */ - ret = vendor_mac_passthru_addr_read(tp, &sa); + if (!pass_through_user) { + ret = vendor_mac_passthru_addr_read(tp, &sa); + if (ret >= 0) + /* we must record the user against concurrent use */ + pass_through_user = tp; + } else { + ret = -EBUSY; + } if (ret < 0) ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa.sa_data); } @@ -5304,6 +5314,8 @@ static void rtl8152_disconnect(struct usb_interface *intf) cancel_delayed_work_sync(&tp->hw_phy_work); tp->rtl_ops.unload(tp); free_netdev(tp->netdev); + if (pass_through_user == tp) + pass_through_user = NULL; } }