From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 87B8941CB1; Thu, 16 Feb 2023 12:09:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D44A642D1D; Thu, 16 Feb 2023 12:09:34 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 2FC1D40E0F; Thu, 16 Feb 2023 12:09:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545772; x=1708081772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Pb298xtmdmJVsr6vOdGVeKDvu23mP3N9B7dlHT3QaM=; b=JFlPv6AVfF2eLsOcTMpjo60Xzba3cAOySuXrx4xfCgclK/4Rc5oEEaEl tDK6Gr5SzKyNBY8giLd3AhgGc9FJKsudckJOXQY10QnghbDJjPASWSy9m UsoddTKABil6nvM1FfpW/lwWlV25Y1HqgQzSaQOSB/HOV1h4qYdEyOs7O imE8mHlZ5oTQlmyR17n2iPgvEzf0hss+5L1+NWrLlzp8pbm3mdTkz+G1p nuWpRd2vT6g0ktaOvVVyiE5xBlCuMDpt7c2Evqu5AMsE2j9bc/35f1miW OV1aa9HyEVLZ1VNdOuGvgBjihu8jIS8LMTLwHjKlvPyU6ypBNHm0ELLLU Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="315368142" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="315368142" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 03:09:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="702522812" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="702522812" Received: from silpixa00401385.ir.intel.com ([10.237.214.22]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2023 03:09:29 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: fengchengwen@huawei.com, Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH v3 1/6] dma/ioat: fix device stop if no copies done Date: Thu, 16 Feb 2023 11:09:14 +0000 Message-Id: <20230216110919.373385-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216110919.373385-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230216110919.373385-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The HW DMA devices supported by IOAT driver do not transition to the "active" state until the first operation is started by the HW. Therefore, if the user calls "rte_dma_stop()" on a device without triggering any operations, the sequence of commands to be sent to the HW is different, as is the final device state. Update the IOAT driver "stop" function to take account of this difference. Fixes: 583f046dd404 ("dma/ioat: add start and stop") Cc: conor.walsh@intel.com Cc: stable@dpdk.org Signed-off-by: Bruce Richardson Reviewed-by: Conor Walsh Acked-by: Kevin Laatz --- drivers/dma/ioat/ioat_dmadev.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/dma/ioat/ioat_dmadev.c b/drivers/dma/ioat/ioat_dmadev.c index 5906eb45aa..aff7bbbfde 100644 --- a/drivers/dma/ioat/ioat_dmadev.c +++ b/drivers/dma/ioat/ioat_dmadev.c @@ -166,17 +166,28 @@ static int ioat_dev_stop(struct rte_dma_dev *dev) { struct ioat_dmadev *ioat = dev->fp_obj->dev_private; + unsigned int chansts; uint32_t retry = 0; - ioat->regs->chancmd = IOAT_CHANCMD_SUSPEND; + chansts = (unsigned int)(ioat->regs->chansts & IOAT_CHANSTS_STATUS); + if (chansts == IOAT_CHANSTS_ACTIVE || chansts == IOAT_CHANSTS_IDLE) + ioat->regs->chancmd = IOAT_CHANCMD_SUSPEND; + else + ioat->regs->chancmd = IOAT_CHANCMD_RESET; do { rte_pause(); retry++; - } while ((ioat->regs->chansts & IOAT_CHANSTS_STATUS) != IOAT_CHANSTS_SUSPENDED - && retry < 200); + chansts = (unsigned int)(ioat->regs->chansts & IOAT_CHANSTS_STATUS); + } while (chansts != IOAT_CHANSTS_SUSPENDED && + chansts != IOAT_CHANSTS_HALTED && retry < 200); + + if (chansts == IOAT_CHANSTS_SUSPENDED || chansts == IOAT_CHANSTS_HALTED) + return 0; - return ((ioat->regs->chansts & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_SUSPENDED) ? 0 : -1; + IOAT_PMD_WARN("Channel could not be suspended on stop. (chansts = %u [%s])", + chansts, chansts_readable[chansts]); + return -1; } /* Get device information of a device. */ -- 2.37.2