From owner-svn-src-all@freebsd.org Thu May 16 16:31:04 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8ED24159D9E1; Thu, 16 May 2019 16:31:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 33D1189F6E; Thu, 16 May 2019 16:31:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 114FA236A7; Thu, 16 May 2019 16:31:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4GGV3nN073049; Thu, 16 May 2019 16:31:03 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4GGV3rC073046; Thu, 16 May 2019 16:31:03 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201905161631.x4GGV3rC073046@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 16 May 2019 16:31:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347770 - in stable/12/sys/dev/mlx5: . mlx5_core mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12/sys/dev/mlx5: . mlx5_core mlx5_en X-SVN-Commit-Revision: 347770 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 33D1189F6E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 May 2019 16:31:04 -0000 Author: hselasky Date: Thu May 16 16:31:03 2019 New Revision: 347770 URL: https://svnweb.freebsd.org/changeset/base/347770 Log: MFC r347305: Move workqueue from mlx5en(4) to mlx5core. This avoids creating more workqueues in mlx5core to do simple firmware command polling tasks. Sponsored by: Mellanox Technologies Modified: stable/12/sys/dev/mlx5/driver.h stable/12/sys/dev/mlx5/mlx5_core/mlx5_health.c stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/driver.h ============================================================================== --- stable/12/sys/dev/mlx5/driver.h Thu May 16 16:30:25 2019 (r347769) +++ stable/12/sys/dev/mlx5/driver.h Thu May 16 16:31:03 2019 (r347770) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2017, Mellanox Technologies, Ltd. All rights reserved. + * Copyright (c) 2013-2019, Mellanox Technologies, Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -505,6 +505,7 @@ struct mlx5_core_health { u32 prev; int miss_counter; u32 fatal_error; + struct workqueue_struct *wq_watchdog; /* wq spinlock to synchronize draining */ spinlock_t wq_lock; struct workqueue_struct *wq; Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_health.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_core/mlx5_health.c Thu May 16 16:30:25 2019 (r347769) +++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_health.c Thu May 16 16:31:03 2019 (r347770) @@ -604,26 +604,27 @@ void mlx5_health_cleanup(struct mlx5_core_dev *dev) struct mlx5_core_health *health = &dev->priv.health; destroy_workqueue(health->wq); + destroy_workqueue(health->wq_watchdog); } -#define HEALTH_NAME "mlx5_health" int mlx5_health_init(struct mlx5_core_dev *dev) { struct mlx5_core_health *health; - char *name; - int len; + char name[64]; health = &dev->priv.health; - len = strlen(HEALTH_NAME) + strlen(dev_name(&dev->pdev->dev)); - name = kmalloc(len + 1, GFP_KERNEL); - if (!name) - return -ENOMEM; - snprintf(name, len, "%s:%s", HEALTH_NAME, dev_name(&dev->pdev->dev)); + snprintf(name, sizeof(name), "%s-rec", dev_name(&dev->pdev->dev)); health->wq = create_singlethread_workqueue(name); - kfree(name); if (!health->wq) return -ENOMEM; + + snprintf(name, sizeof(name), "%s-wdg", dev_name(&dev->pdev->dev)); + health->wq_watchdog = create_singlethread_workqueue(name); + if (!health->wq_watchdog) { + destroy_workqueue(health->wq); + return -ENOMEM; + } spin_lock_init(&health->wq_lock); INIT_WORK(&health->work, health_care); Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu May 16 16:30:25 2019 (r347769) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu May 16 16:31:03 2019 (r347770) @@ -4133,13 +4133,8 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) goto err_free_sysctl; } - snprintf(unit, sizeof(unit), "mce%u_wq", - device_get_unit(mdev->pdev->dev.bsddev)); - priv->wq = alloc_workqueue(unit, 0, 1); - if (priv->wq == NULL) { - if_printf(ifp, "%s: alloc_workqueue failed\n", __func__); - goto err_free_sysctl; - } + /* reuse mlx5core's watchdog workqueue */ + priv->wq = mdev->priv.health.wq_watchdog; err = mlx5_alloc_map_uar(mdev, &priv->cq_uar); if (err) { @@ -4290,7 +4285,7 @@ err_unmap_free_uar: mlx5_unmap_free_uar(mdev, &priv->cq_uar); err_free_wq: - destroy_workqueue(priv->wq); + flush_workqueue(priv->wq); err_free_sysctl: sysctl_ctx_free(&priv->sysctl_ctx); @@ -4370,7 +4365,7 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vp mlx5_core_dealloc_pd(priv->mdev, priv->pdn); mlx5_unmap_free_uar(priv->mdev, &priv->cq_uar); mlx5e_disable_async_events(priv); - destroy_workqueue(priv->wq); + flush_workqueue(priv->wq); mlx5e_priv_mtx_destroy(priv); free(priv, M_MLX5EN); }