Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2449753lqb; Mon, 27 May 2024 23:09:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLEEECgd0tAAJqCRe2qXxekbYKhPRKqeDAhpJ2f9xRAJw59qj4ST95iSMN3fePEom4lKUHGZLBQMnKLYNHt3la67p4RnHGjS3OP9WmWg== X-Google-Smtp-Source: AGHT+IHM9MWuQmx3YPfbcxUACwcDG3bZEta+B/nS4uH7hQSHkO4tGB5yvymufdD4+b9QBDxqD4gv X-Received: by 2002:a17:902:ea01:b0:1f4:bcef:e968 with SMTP id d9443c01a7336-1f4bceff3e8mr33597385ad.53.1716876582569; Mon, 27 May 2024 23:09:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716876582; cv=pass; d=google.com; s=arc-20160816; b=Voa2Weix3+X78EMI1quqGA6ih0pQfGACFNEAeOQNlEeMQGwt32UZVm+r7dLgXyvoiW zlnA16vlnQcb8CcCqK3+DXzJYjT+dxmkQlNd3nRshY9mivgDdKaJ0YJmez2P6mbzRYfp jYFr2TDfvIGEyjsiKQwr7QeNv91H6o8YAsNUKDkAZ0CyEVJbfSosSLLe6vapBgsX22F4 K6KQopjJUK1UMk7cwen1esO5W1PDQQKJclmq7GOZmQgJbg7E34vypuwixiO3Fw1Ph5ym TvJSKXab8NFuXfzTP3CXNPF7cVNDT4k6Dz0F+dLeECpwusAxD7dLwTUcAPCUDDGTCVDR PSCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=y8piNnp1SBPkGgev/yT4P8AhRttOS2ersi1LqVH9rCk=; fh=87/eY8gQF4FDF3HwXnnmaJwLYvnDECX4QrU8m57oL/g=; b=AHj/vr8F36AjooLrbEkBX8heq+hZNP8OHd+44kE7pp4TATMD3I5lNiNOHWTCF/rtr3 IrPpx/So7OB4RiVLFEnKuFhyvgQQaTHkl+HCkWC7dmqvjjsVq9BcN1bCku57BlDtfcEz K/T2Pc75dge/icfVUcL3d7ZYt2zsY9l9IuUBcexlRUFuFCHGKu6oeJxpfiebPZAVFXSg P8ANiZDmRTRbI/JhHXi8AkPePs1KVjecqFo817vuX6TzM/NyPL0z1ziWLCNEh0SIdBFH jKR3Ue462DvPuPsxAKliUEKZ/h20FIFE5OXuLpwa8INwn1U5/zjG55nU7dyNrdMEA8Cf FEvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="I/KYSXpG"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191799-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9a9643si72445495ad.426.2024.05.27.23.09.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 23:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191799-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="I/KYSXpG"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191799-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EF1092838AA for ; Tue, 28 May 2024 06:09:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1860D6A33A; Tue, 28 May 2024 06:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I/KYSXpG" 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 33E964D9F4; Tue, 28 May 2024 06:09:25 +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=1716876565; cv=none; b=PSautrxn8KRjZk3cN2+D1BfrSD/1YxCw7WseHR4fFMlbUjud4QYK3C8jpVmS6IUnT6J3dpk888a0yDLFmG+Pr+yehLMdN4QQoykw1fWpxpeXaiW+94dYaVMEu4sbCLAFHZtHGrBdgxb+sA/TX7G31646feWR8Mq23BnRYkjtRqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716876565; c=relaxed/simple; bh=ZSYu74n0jq7FH0Svutdp6klx3j4BlvlPnAQfADz0IqU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wpgil4JylgbZ/zPZrxZz3kOlN5lLCv4W0/nxifnj8sCErNn42bc+xxl1PFytFPyU1YnBWSNB7/oVHph5mWtvTaigM4ZbqrQo/NCQ0CkdKoCRzp6yKxvjaPTmsWT2MzFFFZ7hEkIVLiVc+B4XRlLm39og3+D4HsqVl4dNEDO8ERA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I/KYSXpG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id D4EABC32782; Tue, 28 May 2024 06:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716876564; bh=ZSYu74n0jq7FH0Svutdp6klx3j4BlvlPnAQfADz0IqU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=I/KYSXpGK5Y+7Ze7M2UUTZJ196NMmqesbqijHwrYyRNEFIMwNxXgN5DiToUMZ+cD2 vYkO3Y5kYzTFRcFya3iMV0Hcwg1GgG2aJu7u3P0rIeXoafmoi4ghCB85eU4tik8l2x OK3SinNpNInFFXDbztZYm3feTSE2bDWGIu3BUxfzh4Rzeb/snjUoZF6jS5bXSw3fNF em+GBDxaFXKTmEN+m1re2Kd08NxhmKK9nqBbNv/UgkywPH4apb93yUF1DNYlOD1Gs5 a5x0p8bB9GLeGuYh+Paj4hwv6kEDYxNUEpZ/htEhCuZ2GSB1sx9ISGxefgIrDx3EeH T9QesbKvh6mvQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BECA7C27C44; Tue, 28 May 2024 06:09:24 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Tue, 28 May 2024 09:09:24 +0300 Subject: [PATCH v2 2/3] dmaengine: ioatdma: Fix error path in ioat3_dma_probe() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240528-ioatdma-fixes-v2-2-a9f2fbe26ab1@yadro.com> References: <20240528-ioatdma-fixes-v2-0-a9f2fbe26ab1@yadro.com> In-Reply-To: <20240528-ioatdma-fixes-v2-0-a9f2fbe26ab1@yadro.com> To: Vinod Koul , Dave Jiang , Logan Gunthorpe Cc: Andy Shevchenko , Nikita Shubin , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux@yadro.com, Nikita Shubin X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1716876563; l=2344; i=n.shubin@yadro.com; s=20230718; h=from:subject:message-id; bh=ndoUzkFelZyO92hJgOMyePUbXfzsIUrSz43B8VvnQSw=; b=wPSkPuxu2pQ/S9Wnfb/LNOSGOhJ/T6XgcFUSUkg+ERcfklrp/fTuxSQ2uetgygBmRXOPVY0/dI5J LdjVOBlmBqYjmezsWEvpefml+CHqRjgOmAPfvUvxxcW0msPMgAed X-Developer-Key: i=n.shubin@yadro.com; a=ed25519; pk=vqf5YIUJ7BJv3EJFaNNxWZgGuMgDH6rwufTLflwU9ac= X-Endpoint-Received: by B4 Relay for n.shubin@yadro.com/20230718 with auth_id=161 X-Original-From: Nikita Shubin Reply-To: n.shubin@yadro.com From: Nikita Shubin 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 --- 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 e76e507ae898..26964b7c8cf1 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.2