Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7668018ybi; Thu, 1 Aug 2019 11:47:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMtyO/UeA1NIpMFk/XrqHQ0XiyP7v3yNdrm4sQHo5mlSavOs79IFOsaWdtE+YCCz6b+imf X-Received: by 2002:a63:6d6:: with SMTP id 205mr123766124pgg.262.1564685221705; Thu, 01 Aug 2019 11:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564685221; cv=none; d=google.com; s=arc-20160816; b=F3dCWMTbRfgJVjKkgDLwCmIBeQrc4+yuS7vgTm3Guo8uKWwx+H1GYQaprQwbgt/5RJ VMm/cD5f9UGYR+xjQaE5ZeskFe+MnULwdHsGo9b9wPw+nRZSG1L4QgtKK/K0URVB33pA Maz2FDdbvPdD/iA4h1AcTFqQ8arkoFUbkBPFGqg/uVToPk/X2hY8cT0mIjCT4yYKHQ8M m9szgOXOyq2FPBgClkWh6/myVTBMP24iv9DsLJnpKQSxeRgC+RYjCPIOQHFpxgLvqa6g BxLIrkB8nO2JYrR5M4VgwQxsmHxggqAKZPbQOsJrMySLQTCRip5wYtXsVuRbjcdmtCYP rF3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=ecP8BzjRTmaPVZT171G2tkivu+sU9POVGx+xi0BQoIE=; b=evRoT7KDM8AAFSvwyfFMjNc9vJWrOZgQIKrxXiFwgtwxx6Y35Nqhr2RmsVd6PKQwvO nanjXI9tiZ/Xcnhkdgp3tMTlU+X6CfQ2KDZSVXueMqnps323s2VXx5Ynhk62R3d5L+w6 WUFOOVIT0E/w2JnqGJKw6h0b74Fn771M0xVunocUM2RYMBKCGrcIqkqvT78qORUpM0fw Ll/WVdJbqGUkA0c5Sd3hHnpvuWMaW0RYZvbbwIi9eQlAkbaLL3u9/rGwVUIdPrIgED4+ YjgHNAJp8rymVKy4kuWe/nBDW6yI2YHc+yzLbgwd054dBMxRCM9hKfnS3QM04fIMWdHx ZH7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=EPPcVkyG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si4711265pjo.75.2019.08.01.11.46.46; Thu, 01 Aug 2019 11:47:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=EPPcVkyG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732472AbfHAShD (ORCPT + 99 others); Thu, 1 Aug 2019 14:37:03 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:38020 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbfHAShC (ORCPT ); Thu, 1 Aug 2019 14:37:02 -0400 Received: by mail-qt1-f196.google.com with SMTP id n11so71272792qtl.5; Thu, 01 Aug 2019 11:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ecP8BzjRTmaPVZT171G2tkivu+sU9POVGx+xi0BQoIE=; b=EPPcVkyGBYWuMX5ynsFj+mL+7tV4H/5ZsoM/12cb/0VDhp58PpI6cKAdkBBx4LVWhR Dvfm5fynLniYJVdUyEjQ4UhdxoDdMD0MVzBHpvv0ZPaCQoGhJBm+mw9+Qff0vH4E+vvQ oM8irggmv17Iw3pY0/8efI/o0eOBoGcAYkOjmxX8DXV0LwsseYoIyJNiZ54/mlT+Y5MO Ys8dPJnq3Qd/igR+DBNTaA0lPb/KWw1A7MPo5fFhVwLI2FKE0DhxKhcKBI2fpXgv6CEK S8WcUaovepgAzPrB3jvOkofIHgvO6b5YeBxfaApo/dBguqBSIUu+wL8MTIPBqaLTPxyA 2vdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ecP8BzjRTmaPVZT171G2tkivu+sU9POVGx+xi0BQoIE=; b=JzDnn4stMb0UFh7t9cEhVkvXj39IJYkcIiyLIYRhWRv+ej0w9QMY2DKcrFKO4dYiLy dJbXkrOqT7iOLbnGAAtpfICtlZSjxGsiYl28+jF5dtgvnLgnYjbwGNgkVCIA1xn/JDjr mTVqSlTw/7rtB86axN63C8jwtpgsP0bVAJQb9J+waPTBRDSsfom6FgxH4nxFPDCjXYqA WN4mYVwTCgpuOiAlT7RcRXZskhJhyqFl9Tul43d9q+FBXggzZ5uqFa+vQp4I0oSXGNAt vf6zlfWLuMoJsBIhDZWaZBawmYNm5i1Bmol+/ayiFXR25I/veDSgaL/a08K7lziKAfJs YENg== X-Gm-Message-State: APjAAAXGbG38WGQ+DpcVjpU7wefCcjs7x6vSqOOM6NuegkAFFym0l5Ku tuS6lfP3eOU7Vz3U/2bhq5dqAPRwQoo= X-Received: by 2002:ac8:7651:: with SMTP id i17mr91877728qtr.245.1564684620395; Thu, 01 Aug 2019 11:37:00 -0700 (PDT) Received: from localhost (modemcable249.105-163-184.mc.videotron.ca. [184.163.105.249]) by smtp.gmail.com with ESMTPSA id d141sm30941421qke.3.2019.08.01.11.36.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 11:36:59 -0700 (PDT) From: Vivien Didelot Cc: linux-kernel@vger.kernel.org, Vivien Didelot , Rasmus Villemoes , f.fainelli@gmail.com, andrew@lunn.ch, netdev@vger.kernel.org, davem@davemloft.net Subject: [PATCH net-next 1/5] net: dsa: mv88e6xxx: lock mutex in vlan_prepare Date: Thu, 1 Aug 2019 14:36:33 -0400 Message-Id: <20190801183637.24841-2-vivien.didelot@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190801183637.24841-1-vivien.didelot@gmail.com> References: <20190801183637.24841-1-vivien.didelot@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lock the mutex in the mv88e6xxx_port_vlan_prepare function called by the DSA stack, instead of doing it in the internal mv88e6xxx_port_check_hw_vlan helper. Signed-off-by: Vivien Didelot --- drivers/net/dsa/mv88e6xxx/chip.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 2e500428670c..1b2cb46d3b53 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1453,12 +1453,10 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, if (!vid_begin) return -EOPNOTSUPP; - mv88e6xxx_reg_lock(chip); - do { err = mv88e6xxx_vtu_getnext(chip, &vlan); if (err) - goto unlock; + return err; if (!vlan.valid) break; @@ -1487,15 +1485,11 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", port, vlan.vid, i, netdev_name(dsa_to_port(ds, i)->bridge_dev)); - err = -EOPNOTSUPP; - goto unlock; + return -EOPNOTSUPP; } } while (vlan.vid < vid_end); -unlock: - mv88e6xxx_reg_unlock(chip); - - return err; + return 0; } static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, @@ -1529,15 +1523,15 @@ mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, /* If the requested port doesn't belong to the same bridge as the VLAN * members, do not support it (yet) and fallback to software VLAN. */ + mv88e6xxx_reg_lock(chip); err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin, vlan->vid_end); - if (err) - return err; + mv88e6xxx_reg_unlock(chip); /* We don't need any dynamic resource from the kernel (yet), * so skip the prepare phase. */ - return 0; + return err; } static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, -- 2.22.0