From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A84324B34; Tue, 25 Jun 2024 09:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719309148; cv=none; b=TJ6W5xeRtU0O/BYxmeKTD8OgwVzvk5+zWIp+0Zo5BOehiqhpkvPr//1Wxrio9AlZpQpFopmJHUV6ub25kFLk3ED8o2zMMkM1FYQkp8IzWAFj1shLHT9kN1BLJ2ygODOAceiAKixcakN6LoZvO07+VR2NpemJqNI6SZIkdjGdi8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719309148; c=relaxed/simple; bh=Xzy+hLzVwyLUgG+l+DPD5UQp3+sxq19SBzKINJ399cI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t0o1oPg07UvN+81vtqjlXXna5w9AHR3DuyVx7On/6NVwP0+Z/0Yqnfh6TRoqeI1ZJSFy2gn5qNicqpIjRvShpJjBJPPY3/JgN7O7Cu4E8oSBqU11WwVxq3PxG8+YhpXgEaKaG687BZplOzM8OSDpzTWAvfomy2WPQwhO8BspJaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WFoNS4EX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WFoNS4EX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A530BC32781; Tue, 25 Jun 2024 09:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719309148; bh=Xzy+hLzVwyLUgG+l+DPD5UQp3+sxq19SBzKINJ399cI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WFoNS4EXJPap1lQc8Bd3rv6mwVrs/1fc0gC+fSjmKpIMLHQwySj+2k3G/p71Qvi1q cNbX0JE58t4sgcguWShKLzJuQNwpYY0kKZ1ZfI+0ztwdhMqGeLKotXkvod4KQ+SqYB r1dGvwjmTWg5h/XQgpq1bigHbisYOswko1m5f5Ic= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Shubin , Dave Jiang , Vinod Koul , Sasha Levin Subject: [PATCH 6.6 110/192] dmaengine: ioatdma: Fix error path in ioat3_dma_probe() Date: Tue, 25 Jun 2024 11:33:02 +0200 Message-ID: <20240625085541.395060515@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240625085537.150087723@linuxfoundation.org> References: <20240625085537.150087723@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikita Shubin [ Upstream commit f0dc9fda2e0ee9e01496c2f5aca3a831131fad79 ] Make sure we are disabling interrupts and destroying DMA pool if pcie_capability_read/write_word() call failed. Fixes: 511deae0261c ("dmaengine: ioatdma: disable relaxed ordering for ioatdma") Signed-off-by: Nikita Shubin Reviewed-by: Dave Jiang Link: https://lore.kernel.org/r/20240528-ioatdma-fixes-v2-2-a9f2fbe26ab1@yadro.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/ioat/init.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index e76e507ae898c..26964b7c8cf14 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -534,18 +534,6 @@ static int ioat_probe(struct ioatdma_device *ioat_dma) return err; } -static int ioat_register(struct ioatdma_device *ioat_dma) -{ - int err = dma_async_device_register(&ioat_dma->dma_dev); - - if (err) { - ioat_disable_interrupts(ioat_dma); - dma_pool_destroy(ioat_dma->completion_pool); - } - - return err; -} - static void ioat_dma_remove(struct ioatdma_device *ioat_dma) { struct dma_device *dma = &ioat_dma->dma_dev; @@ -1181,9 +1169,9 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca) ioat_chan->reg_base + IOAT_DCACTRL_OFFSET); } - err = ioat_register(ioat_dma); + err = dma_async_device_register(&ioat_dma->dma_dev); if (err) - return err; + goto err_disable_interrupts; ioat_kobject_add(ioat_dma, &ioat_ktype); @@ -1192,20 +1180,29 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca) /* disable relaxed ordering */ err = pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &val16); - if (err) - return pcibios_err_to_errno(err); + if (err) { + err = pcibios_err_to_errno(err); + goto err_disable_interrupts; + } /* clear relaxed ordering enable */ val16 &= ~PCI_EXP_DEVCTL_RELAX_EN; err = pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, val16); - if (err) - return pcibios_err_to_errno(err); + if (err) { + err = pcibios_err_to_errno(err); + goto err_disable_interrupts; + } if (ioat_dma->cap & IOAT_CAP_DPS) writeb(ioat_pending_level + 1, ioat_dma->reg_base + IOAT_PREFETCH_LIMIT_OFFSET); return 0; + +err_disable_interrupts: + ioat_disable_interrupts(ioat_dma); + dma_pool_destroy(ioat_dma->completion_pool); + return err; } static void ioat_shutdown(struct pci_dev *pdev) -- 2.43.0