Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp280690rdb; Tue, 31 Oct 2023 07:23:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET5WPViX5ZwuK2ypMZDRr2oJT6gZXBZPta305aGwCCjpAw+shmKS0OCi7o2asDeR92I1/1 X-Received: by 2002:a05:6e02:1a08:b0:34a:a4a5:3f93 with SMTP id s8-20020a056e021a0800b0034aa4a53f93mr18054114ild.5.1698762220552; Tue, 31 Oct 2023 07:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698762220; cv=none; d=google.com; s=arc-20160816; b=XJso5oxzOzzCLAinh/lRemDq+P8MHdCMF7UPEuFWgSkYzylF5bRMmkFqd6Pv6jhjad WEbjw6pF7ONuo87dKcZAqUvTZ/F4i+47KojMUwjJCdy/foSwzdnHfEfwEg+bhGEo9WeE 53Ikrjm8w19GZ2gWNM7/KH73U0/IVx+NZ8Cw+xm9n6wcTfPzF8seVyAKxZ56d3HkBZlP BhrjOOZ1VmBFHcdgwS8ucDK06gy72k03zQixFymUoT3StoYY52IouszuccERy3FIPAbG 0KTQWEj5AhQfKZMHhyXn+KV4JVZwqUY7/13+dS5CY9OFBi5xbJ70v1aGCgrLJzS4a2Fp WzKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j61vRiW7204CC4WYEem9RMmkzHnicbmTEIy8QjC3zrI=; fh=8WutLte5sqsIp0QNGNr3bVo1nt3XY1qC5lOLXvo5AZg=; b=aUjuPpLSGtiJSurO3817N3Gog/EAYORTacqssKXqCfKtjd9hicZEXgXCjUNTPLEksz sG/KgNGgQYz4NoxFbtGct2ILe7s7TjwI1vzhK+hxhg10CaW2E36iygcnQn1zonLvNDEN V8b2hz2vs+2f8m8Al1G7isdT7r6TnrqhJkSLQFxs7u5PQe3ULuPI8hEe7rBLg+PD2CiW RVMTN3lpJndIKb3vQzMdrrduENFX7qMxck5vYbeiUGgI7FdTZubOnWHqGlhRfSyLDACi 0d3Iu2Jo4ReEEONmwfmeaZRpELVE5uqyKrCWdifVK6knKX0H7Wa6BkxXcVKFAj9XqZo7 EEYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="IF/eYp2S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id 138-20020a630190000000b005644a9be955si1127946pgb.179.2023.10.31.07.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:23:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="IF/eYp2S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7B4FF804C66E; Tue, 31 Oct 2023 07:23:37 -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 S1343911AbjJaOX3 (ORCPT + 99 others); Tue, 31 Oct 2023 10:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235662AbjJaOX2 (ORCPT ); Tue, 31 Oct 2023 10:23:28 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88D2DC9; Tue, 31 Oct 2023 07:23:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D3DBC433C8; Tue, 31 Oct 2023 14:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698762205; bh=gHF4eLRcWSiCzarvxwZwly4HI7O2WIslxS/qaonfnn4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IF/eYp2S75f9+6CreJlVFYfR+mY6FyCR/9KiNtiYPaP0qLKjxIkDse+nhKqTi66os 1CzFoWhIsoj9Cz2byYZMH9eyI1Sgo7/pq8LcaMN2o0e7jj+fx9phqA0FLjw2lIATOT P/hqOhMta3RA4afNUT6pEguAuSFticwlM3z4MnJzKRbkoM+7Go1Bl9BOyGoK5FHWvi a7doouIyGKGVIMyHQMZWCA7VhD52vxM/T3bqFPp9fF9rqHhKfg1GhoZRug274n1ZQJ ebV0fhvl9VUvEr1uOrLv3yoLv17cZrN0Y/teVBXBq+mGtAf8ktAdT0x6r58G1SYPKZ Bg/jSkwvNKZmw== Date: Tue, 31 Oct 2023 14:23:18 +0000 From: Mark Brown To: Md Sadre Alam Cc: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, robh+dt@kernel.org, conor+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, quic_srichara@quicinc.com, qpic_varada@quicinc.com Subject: Re: [RFC PATCH 4/5] spi: qpic: Add support for qpic spi nand driver Message-ID: References: <20231031120307.1600689-1-quic_mdalam@quicinc.com> <20231031120307.1600689-5-quic_mdalam@quicinc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="910ikmaqu7YIRsJ2" Content-Disposition: inline In-Reply-To: <20231031120307.1600689-5-quic_mdalam@quicinc.com> X-Cookie: Is it clean in other dimensions? X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Tue, 31 Oct 2023 07:23:37 -0700 (PDT) --910ikmaqu7YIRsJ2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 31, 2023 at 05:33:06PM +0530, Md Sadre Alam wrote: > +config SPI_QPIC_SNAND > + tristate "QPIC SNAND controller" > + default y > + depends on ARCH_QCOM > + help > + QPIC_SNAND(Quad SPI) driver for Qualcomm QPIC_SNAND controller. > + I don't see any build dependencies on anything QC specific so please add an || COMPILE_TEST here, this makes it much easier to do generic changes without having to build some specific config. > +++ b/drivers/spi/Makefile > @@ -153,6 +153,7 @@ obj-$(CONFIG_SPI_XTENSA_XTFPGA) +=3D spi-xtensa-xtfp= ga.o > obj-$(CONFIG_SPI_ZYNQ_QSPI) +=3D spi-zynq-qspi.o > obj-$(CONFIG_SPI_ZYNQMP_GQSPI) +=3D spi-zynqmp-gqspi.o > obj-$(CONFIG_SPI_AMD) +=3D spi-amd.o > +obj-$(CONFIG_SPI_QPIC_SNAND) +=3D spi-qpic-snand.o Please keep this alphabetically sorted (there are some mistakes there but no need to add to them). > + * Sricharan R > + */ > + > +#include > +#include > + This should be including the SPI API, and other API headers that are used directly like the platform and clock APIs. > +static int qcom_snand_init(struct qcom_nand_controller *snandc) > +{ > + u32 snand_cfg_val =3D 0x0; > + int ret; =2E.. > + ret =3D submit_descs(snandc); > + if (ret) > + dev_err(snandc->dev, "failure in sbumitting spiinit descriptor\n"); > + > + free_descs(snandc); This seems to be doing a bit more than I would expect an init function to, and it's very surprising to see the descriptors freed immediately after something called a submit (which suggests that the descriptors are still in flight). > +static int qpic_snand_read_page(struct qcom_nand_controller *snandc, > + const struct spi_mem_op *op) > +{ > + return 0; > +} > + > +static int qpic_snand_write_page(struct qcom_nand_controller *snandc, > + const struct spi_mem_op *op) > +{ > + return 0; > +} =2E.. > +static int qpic_snand_exec_op(struct spi_mem *mem, const struct spi_mem_= op *op) > +{ > + struct qcom_nand_controller *snandc =3D spi_controller_get_devdata(mem-= >spi->master); > + dev_dbg(snandc->dev, "OP %02x ADDR %08llX@%d:%u DATA %d:%u", op->cmd.op= code, > + op->addr.val, op->addr.buswidth, op->addr.nbytes, > + op->data.buswidth, op->data.nbytes); > + > + /* > + * Check for page ops or normal ops > + */ > + if (qpic_snand_is_page_op(op)) { > + if (op->data.dir =3D=3D SPI_MEM_DATA_IN) > + return qpic_snand_read_page(snandc, op); > + else > + return qpic_snand_write_page(snandc, op); So does the device actually support page operations? The above looks like the driver will silently noop them. > + snandc->base_phys =3D res->start; > + snandc->base_dma =3D dma_map_resource(dev, res->start, > + resource_size(res), > + DMA_BIDIRECTIONAL, 0); > + if (dma_mapping_error(dev, snandc->base_dma)) > + return -ENXIO; > + > + ret =3D clk_prepare_enable(snandc->core_clk); > + if (ret) > + goto err_core_clk; The DMA mapping and clock enables only get undone in error handling, they're not undone in the normal device release path. > + > + ret =3D clk_prepare_enable(snandc->aon_clk); > + if (ret) > + goto err_aon_clk; > + > + ret =3D clk_prepare_enable(snandc->iomacro_clk); > + if (ret) > + goto err_snandc_alloc; > + > + ret =3D qcom_nandc_alloc(snandc); > + if (ret) > + goto err_snandc_alloc; > + > + ret =3D qcom_snand_init(snandc); > + if (ret) > + goto err_init; > + > + // setup ECC engine > + snandc->ecc_eng.dev =3D &pdev->dev; > + snandc->ecc_eng.integration =3D NAND_ECC_ENGINE_INTEGRATION_PIPELINED; > + snandc->ecc_eng.ops =3D &qcom_snand_ecc_engine_ops; > + snandc->ecc_eng.priv =3D snandc; > + > + ret =3D nand_ecc_register_on_host_hw_engine(&snandc->ecc_eng); > + if (ret) { > + dev_err(&pdev->dev, "failed to register ecc engine.\n"); > + goto err_init; > + } > + > + ctlr->num_chipselect =3D QPIC_QSPI_NUM_CS; > + ctlr->mem_ops =3D &qcom_spi_mem_ops; > + ctlr->mem_caps =3D &qcom_snand_mem_caps; > + ctlr->dev.of_node =3D pdev->dev.of_node; > + ctlr->mode_bits =3D SPI_TX_DUAL | SPI_RX_DUAL | > + SPI_TX_QUAD | SPI_RX_QUAD; > + > + ret =3D spi_register_master(ctlr); > + if (ret) { > + dev_err(&pdev->dev, "spi_register_controller failed.\n"); > + goto err_init; > + } > + > + return 0; > +err_init: > + qcom_nandc_unalloc(snandc); > +err_snandc_alloc: > + clk_disable_unprepare(snandc->aon_clk); > +err_aon_clk: > + clk_disable_unprepare(snandc->core_clk); > +err_core_clk: > + dma_unmap_resource(dev, res->start, resource_size(res), > + DMA_BIDIRECTIONAL, 0); > + > + return ret; > +} > + > +static int qcom_snand_remove(struct platform_device *pdev) > +{ > + struct spi_controller *ctlr =3D platform_get_drvdata(pdev); > + spi_unregister_master(ctlr); > + > + return 0; > +} > + > +static const struct qcom_nandc_props ipq9574_snandc_props =3D { > + .dev_cmd_reg_start =3D 0x7000, > + .is_bam =3D true, > + .qpic_v2 =3D true, > +}; > + > +static const struct of_device_id qcom_snandc_of_match[] =3D { > + { > + .compatible =3D "qcom,ipq9574-nand", > + .data =3D &ipq9574_snandc_props, > + }, > + {} > +} > +MODULE_DEVICE_TABLE(of, qcom_snandc_of_match); > + > +static struct platform_driver qcom_snand_driver =3D { > + .driver =3D { > + .name =3D "qcom_snand", > + .of_match_table =3D qcom_snandc_of_match, > + }, > + .probe =3D qcom_snand_probe, > + .remove =3D qcom_snand_remove, > +}; > +module_platform_driver(qcom_snand_driver); > + > +MODULE_DESCRIPTION("SPI driver for QPIC QSPI cores"); > +MODULE_AUTHOR("Md Sadre Alam "); > +MODULE_LICENSE("GPL"); > --=20 > 2.34.1 >=20 --910ikmaqu7YIRsJ2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmVBDdUACgkQJNaLcl1U h9Ayhgf+Ka7rwW/sqJZ1kD93K1uUeVHjyDvf9z9Z5yfcVvPLmIkHxGj4/ETeJFnP QIHcNM4TsiFOAjfsSU0JyCZKrw+7jgOgRE4EVfWUAqLwD3FdY9wTjmQmp5/pVlwF PbU9JbZjvWnPHhTjoZJNUJbA80Ea3E3ROE7FAS+P9VNTBgRqX00ubdyhXQ4ya3MT F3M8NiZmWmKNXOhoOOcNZkNNovhJh2X5ZY3GKhJ1mDdqlCcs3Uy7QU6lyhf6S9wR QhnUtjZuFqRSiSkVa7oTQIr7vZeG+gRj4uaK+QzglDmCJCInE/atWbONPyipveku 8Ya+gviROLEJ0/htPxRIOAWjmwlKQw== =ddU9 -----END PGP SIGNATURE----- --910ikmaqu7YIRsJ2--