Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6420500ybx; Mon, 11 Nov 2019 08:52:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyNA6EPu8JHaocWojrfaODyQxN41SQr8BOl/T6MUroyjEZzIOUDhT088Idqu05tuKYwx1Gs X-Received: by 2002:a17:906:411:: with SMTP id d17mr23453197eja.299.1573491147641; Mon, 11 Nov 2019 08:52:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573491147; cv=none; d=google.com; s=arc-20160816; b=sZGnlz6iO51i91Km/KH8pvnXUfrNXdIr3uh2D6Y////EwZZs3vsk8UDCrNZXJ4cOnE Q/riSe9GrKfH+Su1hIM10+eCG7SzFrDad2EmZgqVPsT/FWcVQo7SuNQ/1nUfsD5RZ+DG XgMn4U2yrecJb5t0gmd4hJS+RLNIapxjcUcLOPfhgHAciwhM0ObQF1WzIUrKNvYcEaV8 DrX0uzLfETua7DUHdmJxU/tWp1myA48ewRkwrtShJkr16LbvWFvXayY2Gl20NTp5cWFk A42H20Zvp//Gane1npEbbMkp8oHivT9CQsWQT8l0Nun9qeFCYiMrcyAR76sjVBTwBrHz gHbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from; bh=zFlMLMhSEGIr4+nszp0CQyhgWM3tywe/+a8T7N5SoCU=; b=POs3KJ1tYsoWlIqhO28k2M+1EE0u/EUbabsgXm170eePhm/mdyIe+Auf0uC3LFl41O +5j4EMB13vgS1VjwuaMoHJ+53zZLBvL11ZO/GNqxyZOny0/uC9KKIepExUyd6j2TWrZ0 c7byGgZC94+Ma/QYwTK7kfWi3HaeEHF+gn+S7IR+PwJy3QHNmfCdspKG15plgofss8ut Ni3Ad/RbyNt0bsXGNeAfUgcinNFgy5wd8Ln8nw9Wz2TR1bKyaNQ0mY23ZBQcrUukB+G/ EsZ/ZP4WPXapig1FphWoBzmdmYry+m39qZ+yh3I+ndkUJPuOCnXpVqygPU97MNQFjIbX iMGg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h23si4364755ede.355.2019.11.11.08.52.03; Mon, 11 Nov 2019 08:52:27 -0800 (PST) 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; 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbfKKQvR (ORCPT + 99 others); Mon, 11 Nov 2019 11:51:17 -0500 Received: from inva021.nxp.com ([92.121.34.21]:44298 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726957AbfKKQvM (ORCPT ); Mon, 11 Nov 2019 11:51:12 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3AF2620063D; Mon, 11 Nov 2019 17:51:10 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2D9E020062E; Mon, 11 Nov 2019 17:51:10 +0100 (CET) Received: from fsr-ub1464-137.ea.freescale.net (fsr-ub1464-137.ea.freescale.net [10.171.82.114]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id EAEA0205FE; Mon, 11 Nov 2019 17:51:09 +0100 (CET) From: Ioana Ciornei To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei Subject: [PATCH 4/4] staging: dpaa2-ethsw: ordered workqueue should be per ethsw Date: Mon, 11 Nov 2019 18:50:58 +0200 Message-Id: <1573491058-24766-5-git-send-email-ioana.ciornei@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573491058-24766-1-git-send-email-ioana.ciornei@nxp.com> References: <1573491058-24766-1-git-send-email-ioana.ciornei@nxp.com> Reply-to: ioana.ciornei@nxp.com X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create a different ordered workqueue per dpaa2-ethsw instance. Without this change, we overwrite the global queue and leak memory when probing multiple instances of the driver. Signed-off-by: Ioana Ciornei --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 17 +++++++++-------- drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 37ee9b0aa326..39c0fe347188 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -18,8 +18,6 @@ #include "ethsw.h" -static struct workqueue_struct *ethsw_owq; - /* Minimal supported DPSW version */ #define DPSW_MIN_VER_MAJOR 8 #define DPSW_MIN_VER_MINOR 1 @@ -1229,8 +1227,10 @@ static int port_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + struct ethsw_port_priv *port_priv = netdev_priv(dev); struct ethsw_switchdev_event_work *switchdev_work; struct switchdev_notifier_fdb_info *fdb_info = ptr; + struct ethsw_core *ethsw = port_priv->ethsw_data; if (!ethsw_port_dev_check(dev)) return NOTIFY_DONE; @@ -1266,7 +1266,7 @@ static int port_switchdev_event(struct notifier_block *unused, return NOTIFY_DONE; } - queue_work(ethsw_owq, &switchdev_work->work); + queue_work(ethsw->workqueue, &switchdev_work->work); return NOTIFY_DONE; @@ -1427,9 +1427,10 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) } } - ethsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM, - "ethsw"); - if (!ethsw_owq) { + ethsw->workqueue = alloc_ordered_workqueue("%s_%d_ordered", + WQ_MEM_RECLAIM, "ethsw", + ethsw->sw_attr.id); + if (!ethsw->workqueue) { err = -ENOMEM; goto err_close; } @@ -1441,7 +1442,7 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) return 0; err_destroy_ordered_workqueue: - destroy_workqueue(ethsw_owq); + destroy_workqueue(ethsw->workqueue); err_close: dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); @@ -1529,7 +1530,7 @@ static int ethsw_remove(struct fsl_mc_device *sw_dev) ethsw_teardown_irqs(sw_dev); - destroy_workqueue(ethsw_owq); + destroy_workqueue(ethsw->workqueue); dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index db7eef134230..a0244f7d5003 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -70,6 +70,7 @@ struct ethsw_core { struct notifier_block port_nb; struct notifier_block port_switchdev_nb; struct notifier_block port_switchdevb_nb; + struct workqueue_struct *workqueue; }; #endif /* __ETHSW_H */ -- 1.9.1