Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4176797rdh; Fri, 29 Sep 2023 13:40:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFG+pcLBu+Oy54I79p7RuQsFjImWCjrOCKnXjhU6ef+5qFbCEDKhku2oeFe3d+vZnSt9UuQ X-Received: by 2002:a05:6808:114b:b0:3ae:4774:c00c with SMTP id u11-20020a056808114b00b003ae4774c00cmr7094295oiu.53.1696020057672; Fri, 29 Sep 2023 13:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696020057; cv=none; d=google.com; s=arc-20160816; b=TrkWLnr3L1EsVfqpCBZcpE7oCcQl0C3iXIxeD8QpNrnlp9JYDrlOrKLvFycuv09jK2 Gyl4pCqKJvnOXPBNqOJsJkU5cEiXjGlczA+7NveQjH0JtR9MBLiYXCP8iB2U/9IOTqHj kmVqxBrgxN3qC+N7xjQHiyKON78KnupBns1TexrXYwhbv7jIwAzVLwmosWowLBT/hgxA OhO4avmlRZxcCEMu7G9H8r/GQp0huUNY1hvdvKN+LFpOkVVws0W3QIiFVt/QyOr3V+xz +0RJDV0CKfDb9aG7JxF1GYK+JrHD9Oq8kdS581rrmOVldiQESSlkiRnHereHnGqoP5Aw teJQ== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=/omWOnUopIQaBLJ6GGrAgyTNWLTcb1siWJJxie6fb7w=; fh=UcnwdxbETIcsGDom+5aECewfByNd5xIaqe3DRrgyMjY=; b=EX5R5c6Ap17I339XwJS6p2GcK2B4xYAuh4Vz8FWzcazEWkIRG43Uj+d53nBCh1ffPd VYj9UZMCf+kA8xW2f2qayQ93gJw7hXF9WD+8TVelxWLTfS8D8n3YmHjWd6FoYXqaiNEL m+M/CZvWIj0nT8M+sbOUteHYyZt/CuNlztEhsP1sBhw7hkp12bK7qsxn7fxm7GuLA4zk SN/PdmoTlSgX63Ul7NqCyYABDZiyTuZL/Qu2QnzYgo59k3tfZoaNsHkvcpMa0Qs1VDVG A2QbCiTBrmzDgbxvfPKEc1+R2tga5km9irnSh7n6E7W0mkxW7BE+hSz+0L6qvDvykdcZ kWHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=CPJsKfL1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w22-20020a637b16000000b005855424fc29si7635329pgc.53.2023.09.29.13.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 13:40:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=CPJsKfL1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 378388266402; Fri, 29 Sep 2023 13:35:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232878AbjI2Ufg (ORCPT + 99 others); Fri, 29 Sep 2023 16:35:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbjI2Ufe (ORCPT ); Fri, 29 Sep 2023 16:35:34 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE0871A7 for ; Fri, 29 Sep 2023 13:35:30 -0700 (PDT) Received: from [192.168.1.18] ([86.243.2.178]) by smtp.orange.fr with ESMTPA id mKCtqYUXuDYMSmKCuqSlsu; Fri, 29 Sep 2023 22:35:28 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1696019728; bh=/omWOnUopIQaBLJ6GGrAgyTNWLTcb1siWJJxie6fb7w=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=CPJsKfL1f7BtX1obCd4opisP33OL0ev+Kbwz9LO4o6N+sFGSLvUQK3hMND7zA84gx kjOSh/DEo0n2Bq9tPOeXbsurmszLL6JrsfXBNu6JMSnrD0QeDevQwmvfBHDcXHHWBi nYWhG6bKwYB/6pmkybrAtvvzPD42XDMZ6wmcDJb+U7rPtrDPxqVRYnsJ1j7F3P6jxj 3oq94aPPd1QwnuB7psjsAXOxhAGAmA1rTwnEu0WeX2hgxZ1Gi80IQW11yRKltrEhfa aZy5v8qZO49plOr3XGsTPy3wDsO9Tu3lpP5WQWKUMJIebn05MQsKvgaIOj+547rMI9 4J9Vpb80qqX7g== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 29 Sep 2023 22:35:28 +0200 X-ME-IP: 86.243.2.178 Message-ID: <0750d8b2-b624-3293-23ac-a034c88d8e0e@wanadoo.fr> Date: Fri, 29 Sep 2023 22:35:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH V6 1/1] dmaengine: amd: qdma: Add AMD QDMA driver To: Lizhi Hou , vkoul@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nishad Saraf , nishad.saraf@amd.com, sonal.santan@amd.com, max.zhen@amd.com References: <1696008263-42937-1-git-send-email-lizhi.hou@amd.com> <1696008263-42937-2-git-send-email-lizhi.hou@amd.com> Content-Language: fr From: Christophe JAILLET In-Reply-To: <1696008263-42937-2-git-send-email-lizhi.hou@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 29 Sep 2023 13:35:55 -0700 (PDT) Le 29/09/2023 à 19:24, Lizhi Hou a écrit : > From: Nishad Saraf > > Adds driver to enable PCIe board which uses AMD QDMA (the Queue-based > Direct Memory Access) subsystem. For example, Xilinx Alveo V70 AI > Accelerator devices. > https://www.xilinx.com/applications/data-center/v70.html > > The QDMA subsystem is used in conjunction with the PCI Express IP block > to provide high performance data transfer between host memory and the > card's DMA subsystem. > ... > +static int amd_qdma_probe(struct platform_device *pdev) > +{ > + struct qdma_platdata *pdata = dev_get_platdata(&pdev->dev); > + struct qdma_device *qdev; > + struct resource *res; > + void __iomem *regs; > + int ret; > + > + qdev = devm_kzalloc(&pdev->dev, sizeof(*qdev), GFP_KERNEL); > + if (!qdev) > + return -ENOMEM; > + > + platform_set_drvdata(pdev, qdev); > + qdev->pdev = pdev; > + mutex_init(&qdev->ctxt_lock); If this was done later, it could simplify some error handling below. > + > + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); > + if (!res) { > + qdma_err(qdev, "Failed to get IRQ resource"); > + ret = -ENODEV; > + goto failed; > + } > + qdev->err_irq_idx = pdata->irq_index; > + qdev->queue_irq_start = res->start + 1; > + qdev->queue_irq_num = res->end - res->start; > + > + regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); > + if (IS_ERR(regs)) { > + ret = PTR_ERR(regs); > + qdma_err(qdev, "Failed to map IO resource, err %d", ret); > + goto failed; > + } > + > + qdev->regmap = devm_regmap_init_mmio(&pdev->dev, regs, > + &qdma_regmap_config); > + if (IS_ERR(qdev->regmap)) { > + ret = PTR_ERR(qdev->regmap); > + qdma_err(qdev, "Regmap init failed, err %d", ret); > + goto failed; > + } > + > + ret = qdma_device_verify(qdev); > + if (ret) > + goto failed; > + > + ret = qdma_get_hw_info(qdev); > + if (ret) > + goto failed; > + > + INIT_LIST_HEAD(&qdev->dma_dev.channels); > + > + ret = qdma_device_setup(qdev); > + if (ret) > + goto failed; > + > + ret = qdma_intr_init(qdev); > + if (ret) { > + qdma_err(qdev, "Failed to initialize IRQs %d", ret); > + return ret; Should it be "goto failed"? > + } > + qdev->status |= QDMA_DEV_STATUS_INTR_INIT; > + > + dma_cap_set(DMA_SLAVE, qdev->dma_dev.cap_mask); > + dma_cap_set(DMA_PRIVATE, qdev->dma_dev.cap_mask); ... > +struct qdma_device { > + struct platform_device *pdev; > + struct dma_device dma_dev; > + struct regmap *regmap; > + struct mutex ctxt_lock; /* protect ctxt registers */ > + const struct qdma_reg_field *rfields; > + const struct qdma_reg *roffs; > + struct qdma_queue *h2c_queues; > + struct qdma_queue *c2h_queues; > + struct qdma_intr_ring *qintr_rings; > + u32 qintr_ring_num; > + u32 qintr_ring_idx; > + u32 chan_num; > + u32 queue_irq_start; > + u32 queue_irq_num; > + u32 err_irq_idx; > + u32 fid; > + u32 status; Using such a mechanism with this 'status' in the probe and amd_qdma_remove(), apparently only to simplify the error handling of the probe looks really unusual to me. CJ > +}; ...