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 B3FA5423F1; Mon, 16 Jan 2023 16:37:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8A5242D0C; Mon, 16 Jan 2023 16:37:40 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 515BB40F18; Mon, 16 Jan 2023 16:37:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673883458; x=1705419458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E+L7rpIcPsEH0Ztr+0whh7NB28tFlYDHF0rcs5bb29k=; b=VuEKeOVUtAAx4tjO0UL6Ngbts1pTzPLY09bnPsCjvIQtm8XIGRNk9k7u Ijbp6NhsMA9W0SJPBQh+Ls+/134Fff1NTSpKvwa64Bqu4AN8o6iSdVfVu Xvjxn96SVErXEkGNIAEVFyENteoxRok2ecJ4bKDzH5Lo+q0kmW/ctjHNS fcU0DL0FfwMREd1Z8o57p/K5JEJc1GorIvKvrQQsTdbGJU/TRshQC4Ady JhTGUCplPnEfoMx64oCWgSjibedeNqMxzzqeqcmhLbyo9MSmxvIrC4m+4 6eWn0n93J9UzHHKemPhHos6rhwgJCFlLGv7ijzmvEjbS0xyrTuZrhF1xW g==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="351735350" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="351735350" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 07:37:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="727505465" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="727505465" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga004.fm.intel.com with ESMTP; 16 Jan 2023 07:37:36 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH 1/5] dma/ioat: fix device stop if no copies done Date: Mon, 16 Jan 2023 15:37:10 +0000 Message-Id: <20230116153714.554470-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116153714.554470-1-bruce.richardson@intel.com> References: <20230116153714.554470-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 --- 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