Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3096512rwb; Mon, 19 Sep 2022 15:05:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Bs3/uu0MI8VDD6kJrej0VPjEaFwNF3O0+hTW3QZ40Uvem2ASG9JaeC9DaiJTPoF4Ywm0T X-Received: by 2002:a05:6a00:896:b0:53a:993c:a45e with SMTP id q22-20020a056a00089600b0053a993ca45emr20519935pfj.83.1663625149643; Mon, 19 Sep 2022 15:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663625149; cv=none; d=google.com; s=arc-20160816; b=aaQNZK14ZjnQeMHQ+Ne1ShBnhGvSFRKxInox5imnMqj/CvfocvetNfLN4NPmd8xnrY 0yqn0xNPn6Q16GSMdhnMEK3cTdK96S0/+KOX+ALFqUJubmVGt+2L1gt2JuuN6RLs4lbV N8PCcq+h4XOGtAe6IIsqkiMNTiiZkkOzKloGxPp8zUVxpID/WbdFjthm1eU6rzndzWpT 3UurUJYUdclMU+wmdInmUVU31V9sG/88vAkLSOoM4oGask0cMTe6GmGY953KqOfovzzY UaOSOKwPKmY79AMm0sJ9bvkclR5OOG+XzNqiVn9+E0WWiQApP9VlF5ykBP+ptdsBn6VM 1FaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cYvxKc5DlaYhK9l6PE82liKF9DEhv340Jc5UQRPm/Ms=; b=YiUHOrMsDx7aY/J1yDDl+fgVV7R6emzMREbJopxXVtrFPPKWoMR7aYM92TB74q0Mjn Yosb2ujDqDZq/WrYcbYs3xySk+0/NC8Iy0M4je5ieBjcjBrXcIrhjSoAgT10FiR6vxon hZSFK6YEezNGyiWsG8LH7l+4hRqS2AbZ5ayHlBp+HL+plXJf3x2g83M5WKJak+cimKv+ tZEa+dTLLd8gQ4FMmll6OzvKK0aDilbwS8+93hgZxOp/lJ3OxlJ9YpHJ6D+YjPwQCm60 ZBGk1aCjkKPPaHtGR34Mwp/fWAlIGbe5R+RRVrna7cZEZgUOtgmnPK6KupROpn3Dymyz 8C9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g+SGR57m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a632203000000b004349663187bsi954049pgi.73.2022.09.19.15.05.38; Mon, 19 Sep 2022 15:05:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g+SGR57m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiISV4O (ORCPT + 99 others); Mon, 19 Sep 2022 17:56:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbiISV4E (ORCPT ); Mon, 19 Sep 2022 17:56:04 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18DA04622C for ; Mon, 19 Sep 2022 14:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663624562; 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=cYvxKc5DlaYhK9l6PE82liKF9DEhv340Jc5UQRPm/Ms=; b=g+SGR57mEwiw2zO4vLYpl74dWZdcpSR6jtgVkj59kxXGYgDLAqJwIgrrRtW0AxonTpNiot TrhooJoWUMbMZzStyxfHL1xKqYngCWOlXhQm5VcIiFwpwlFomAEtgSKfk5/KiKdAXiDpXG h8J5zpDuT5Cy7JLqF3nATelDcgyRIKE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-331-9IlhLMZVNI2wO58mAxm7uQ-1; Mon, 19 Sep 2022 17:55:57 -0400 X-MC-Unique: 9IlhLMZVNI2wO58mAxm7uQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2EAA5382578E; Mon, 19 Sep 2022 21:55:57 +0000 (UTC) Received: from cantor.redhat.com (unknown [10.2.16.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E80940C2064; Mon, 19 Sep 2022 21:55:56 +0000 (UTC) From: Jerry Snitselaar To: linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Cc: Fenghua Yu , Dave Jiang , Vinod Koul Subject: [PATCH 2/2] dmaengine: idxd: track enabled workqueues in bitmap Date: Mon, 19 Sep 2022 14:55:53 -0700 Message-Id: <20220919215553.600246-3-jsnitsel@redhat.com> In-Reply-To: <20220919215553.600246-1-jsnitsel@redhat.com> References: <20220919215553.600246-1-jsnitsel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that idxd_wq_disable_cleanup() sets the workqueue state to IDXD_WQ_DISABLED, use a bitmap to track which workqueues have been enabled. This will then be used to determine which workqueues should be re-enabled when attempting a software reset to recover from a device halt state. Cc: Fenghua Yu Cc: Dave Jiang Cc: Vinod Koul Signed-off-by: Jerry Snitselaar --- drivers/dma/idxd/device.c | 2 ++ drivers/dma/idxd/idxd.h | 2 ++ drivers/dma/idxd/init.c | 6 ++++++ drivers/dma/idxd/irq.c | 4 ++-- drivers/dma/idxd/sysfs.c | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c index 31911e255ac1..f0c7d6d348e3 100644 --- a/drivers/dma/idxd/device.c +++ b/drivers/dma/idxd/device.c @@ -196,6 +196,7 @@ int idxd_wq_enable(struct idxd_wq *wq) } wq->state = IDXD_WQ_ENABLED; + set_bit(wq->id, idxd->wq_enable_map); dev_dbg(dev, "WQ %d enabled\n", wq->id); return 0; } @@ -223,6 +224,7 @@ int idxd_wq_disable(struct idxd_wq *wq, bool reset_config) if (reset_config) idxd_wq_disable_cleanup(wq); + clear_bit(wq->id, idxd->wq_enable_map); wq->state = IDXD_WQ_DISABLED; dev_dbg(dev, "WQ %d disabled\n", wq->id); return 0; diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h index fed0dfc1eaa8..f527a7f88b92 100644 --- a/drivers/dma/idxd/idxd.h +++ b/drivers/dma/idxd/idxd.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include "registers.h" @@ -299,6 +300,7 @@ struct idxd_device { int rdbuf_limit; int nr_rdbufs; /* non-reserved read buffers */ unsigned int wqcfg_size; + unsigned long *wq_enable_map; union sw_err_reg sw_err; wait_queue_head_t cmd_waitq; diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index aa3478257ddb..7e27e69ff741 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -151,6 +151,12 @@ static int idxd_setup_wqs(struct idxd_device *idxd) if (!idxd->wqs) return -ENOMEM; + idxd->wq_enable_map = bitmap_zalloc_node(idxd->max_wqs, GFP_KERNEL, dev_to_node(dev)); + if (!idxd->wq_enable_map) { + kfree(idxd->wqs); + return -ENOMEM; + } + for (i = 0; i < idxd->max_wqs; i++) { wq = kzalloc_node(sizeof(*wq), GFP_KERNEL, dev_to_node(dev)); if (!wq) { diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c index 743ead5ebc57..8efaf137fc65 100644 --- a/drivers/dma/idxd/irq.c +++ b/drivers/dma/idxd/irq.c @@ -49,9 +49,9 @@ static void idxd_device_reinit(struct work_struct *work) goto out; for (i = 0; i < idxd->max_wqs; i++) { - struct idxd_wq *wq = idxd->wqs[i]; + if (test_bit(i, idxd->wq_enable_map)) { + struct idxd_wq *wq = idxd->wqs[i]; - if (wq->state == IDXD_WQ_ENABLED) { rc = idxd_wq_enable(wq); if (rc < 0) { dev_warn(dev, "Unable to re-enable wq %s\n", diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c index 3f262a57441b..3325b16ed959 100644 --- a/drivers/dma/idxd/sysfs.c +++ b/drivers/dma/idxd/sysfs.c @@ -1405,6 +1405,7 @@ static void idxd_conf_device_release(struct device *dev) struct idxd_device *idxd = confdev_to_idxd(dev); kfree(idxd->groups); + bitmap_free(idxd->wq_enable_map); kfree(idxd->wqs); kfree(idxd->engines); ida_free(&idxd_ida, idxd->id); -- 2.37.2