Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp835638rwb; Wed, 28 Sep 2022 09:39:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GAV9eroJz71C5MnR3TP0Ryzo+3T93izBBOjTlVGmj+uOeTFEeDqyQ7lr3JyZVtBbrXbZz X-Received: by 2002:a05:6a00:88f:b0:52c:6962:274f with SMTP id q15-20020a056a00088f00b0052c6962274fmr36385412pfj.12.1664383178140; Wed, 28 Sep 2022 09:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664383178; cv=none; d=google.com; s=arc-20160816; b=tU8VAolckO9pqjPIwow1wf1qYYvcnfnpCYjhw9U10wKtyklO52YREF3p25M8Ai47ZM hLb+ksS5T8aYPhhyg3BxaZf3K3LLFny0HSXsjHgidtIxLOQPdv/LFWvLYDjvB6H+GVDx aeJhDhLG4H8cItyJMlbuGHAYN3NUYjY3JtTIu2v9BkH0KoMhWcHoioA/xmFH93Q/+0/b CZ4xwipEUHekcZN0zOyOqRccBEroMbqyldvzRE1cz+dPHRIzHJ8phyGJ3+tApzA9HSMj NLHM/YhNxHwdtQxOiAQRzIXKC2a9M0UbFoLENW3I/S3dyCpWZBZ2dBYgVcnGujxgW1ku vUXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=NztAqH2bfpopUiOW0g8cmN7CllpxFJe4d0aTGxf7ZPk=; b=VvEgPZ2UZc5r6dYtzOjEBd9WHDK1Xez/ANQiKDEiMP/+Z2V271sPiRQAPCxjoP4su8 tEiRcGgAfeYw0IhXxJGgCo2CLIOMw8BIOxSE4c8nGeRdcwzxY9KQR4rhCLZT4ILZ7yyz 3tKpbU5KUKW7F1uXKZcVCXTZAFXM9lMzEYTvH8/NzLw5bOx52y1wg3LCVTANobRmcBiW AcHAdM2floqmXnI6EUcvfxysVKX2IGDZ+4oTQulleDfKQrt2873vVGUnh6W+x7Z5vYnj KXa2Jbra4Es7+w1hvahMJeAHp0z74vLqCNCGM2v5B/JfgaS1EdHfKnfmwb9ugbL4Y1UU k8cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e9bENAQs; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a625803000000b0053a81f65dd3si3096456pfb.287.2022.09.28.09.39.25; Wed, 28 Sep 2022 09:39:38 -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=@intel.com header.s=Intel header.b=e9bENAQs; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233277AbiI1Pin (ORCPT + 99 others); Wed, 28 Sep 2022 11:38:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233659AbiI1Pia (ORCPT ); Wed, 28 Sep 2022 11:38:30 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7079A98DB; Wed, 28 Sep 2022 08:38:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664379509; x=1695915509; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=oVdfOOd1cyOseQwIDkFgUNlgmXR4bsi2J2HqIl9UECM=; b=e9bENAQsxoQ8BuNk05bIDBz7tgu/O0B76BrlJdEZTWpaJ2440FlrkC2Z zuGMPAbvEwb/zc8/3JC0WiiNngYHimcA6EqEzGlS5CAXvpd5fzioVgoQN JaeRxnoPAG/fNXNjzltuj4vxqokk1Hq3DA//81fVcYXB6XNOhI9rtAiIC w77ff0Q8W0lWjdMHlGrl4ssshlH0Cc8qNmNyk0twFNnewoEx/fJ8tss/1 IKKSyQJ8QxccKYI3SLTzqiUDIebNk1fBJqxveeTLDZPkzAxq8xclBsGes 8Y+/uTm7R26yCk6Fuck3Zv/9FVPpD/0NIkDZ0TCUzMHNsrzh/gQC65DcQ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="288794391" X-IronPort-AV: E=Sophos;i="5.93,352,1654585200"; d="scan'208";a="288794391" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2022 08:38:28 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="684451803" X-IronPort-AV: E=Sophos;i="5.93,352,1654585200"; d="scan'208";a="684451803" Received: from djiang5-mobl2.amr.corp.intel.com (HELO [10.212.108.153]) ([10.212.108.153]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2022 08:38:26 -0700 Message-ID: Date: Wed, 28 Sep 2022 08:38:26 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.3.0 Subject: Re: [PATCH 2/2] dmaengine: idxd: track enabled workqueues in bitmap Content-Language: en-US To: Jerry Snitselaar , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Cc: Fenghua Yu , Vinod Koul References: <20220919215553.600246-1-jsnitsel@redhat.com> <20220919215553.600246-3-jsnitsel@redhat.com> <20220928152120.3wsvc4iungzsmryn@cantor> From: Dave Jiang In-Reply-To: <20220928152120.3wsvc4iungzsmryn@cantor> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 On 9/28/2022 8:21 AM, Jerry Snitselaar wrote: > On Mon, Sep 19, 2022 at 02:55:53PM -0700, Jerry Snitselaar wrote: >> 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", > Hi Dave and Fenghua, > > Thinking about this last night, this should probably clear the bit here in > the case where an error is returned from idxd_wq_enable here, yes? I can > send a v2. Ah yeah I think so. We failed to enable, so just give up. Thanks. > >> 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 >>