Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1582285imi; Sat, 23 Jul 2022 10:09:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vbdEnASLcHKR1fNaJ5Ox5CxXfQ+OEYhFLKXpbDvJBLW48r0elQS0rArXXDfLakG6bMgIl2 X-Received: by 2002:a17:907:1c8a:b0:6e9:2a0d:d7b7 with SMTP id nb10-20020a1709071c8a00b006e92a0dd7b7mr3914788ejc.572.1658596187870; Sat, 23 Jul 2022 10:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658596187; cv=none; d=google.com; s=arc-20160816; b=eyleakY/f4LAXfEXU6gYPXK/mHcRIYpX+WDFvMxtcKSd6C2cna6jIEGLSlreJY97We zZboRhbCV30vOgdRp0wE1LidTS5Z2JajqqylXTVQ3bRYK+WDkNpn19uD0UJs/4E6FllH sWn9F9jG4+elsCug1TRzlb/wGUkknTjdUoThTgT7Ns7DtS8UdJrhjKkx+MpTIVDfLhq8 6Mmn0L6hzxiJokPNPLik26oafvDP+B1LizALMrwXBirlVsZGupXq7lPbDaJLD1uiUiBK ZlcG+CjkbjO7eK57lQx4puFDu5VAyhUH4j2kFWSf8Ssp5rmchjFK9EJ/DcuTfEdwC2U6 Qz8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=J+yuOIpiX9jbg4PTUbl3EOsA6jXr8ghRw/xmsjUTpbs=; b=JqxRIKu8cGFkJhInFlHwB0RPW9JBMTimxyDJA3af2KsljVoenohOkTQ/xj3N2qX9nb v8Qx+15hSqcbJVvqNtY4nL/wMdVy0QMmbXXIyAVO8vQRvBba3/oTkl/iSv5gigFr3HOt y2dGui3dtXaPQA6jeBy7hLfBdg+Mykgz2dtwYPRNEId0C5uR2oed2J6/qBUDph7xOsVl r+56iZTxh4ij7po2j3gkshY3AAHl44PGwiyBA7D6TFTve0NgQZH4WJ01JjdAac8XXLDz GMLi9Hx7ErlctAhR0XqTp8rZLJUS1E/gg2hjFXgndvhUY8HY10A0OGy9DuQDj16qyo71 xB+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hu9-20020a170907a08900b007156fe1aa78si4345060ejc.403.2022.07.23.10.09.19; Sat, 23 Jul 2022 10:09:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235226AbiGWRG2 (ORCPT + 99 others); Sat, 23 Jul 2022 13:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230005AbiGWRG0 (ORCPT ); Sat, 23 Jul 2022 13:06:26 -0400 Received: from out28-1.mail.aliyun.com (out28-1.mail.aliyun.com [115.124.28.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D27A1AF2E; Sat, 23 Jul 2022 10:06:23 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07462738|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.0428046-0.00500691-0.952188;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047190;MF=zhouyanjie@wanyeetech.com;NM=1;PH=DS;RN=23;RT=23;SR=0;TI=SMTPD_---.Obm0Iun_1658595976; Received: from 192.168.10.152(mailfrom:zhouyanjie@wanyeetech.com fp:SMTPD_---.Obm0Iun_1658595976) by smtp.aliyun-inc.com; Sun, 24 Jul 2022 01:06:18 +0800 Subject: Re: [PATCH 3/3] SPI: Ingenic: Add SFC support for Ingenic SoCs. To: Mark Brown Cc: tudor.ambarus@microchip.com, p.yadav@ti.com, michael@walle.cc, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, aidanmacdonald.0x0@gmail.com, tmn505@gmail.com, paul@crapouillou.net, dongsheng.qiu@ingenic.com, aric.pzqi@ingenic.com, rick.tyliu@ingenic.com, jinghui.liu@ingenic.com, sernia.zhou@foxmail.com, reimu@sudomaker.com References: <1658508510-15400-1-git-send-email-zhouyanjie@wanyeetech.com> <1658508510-15400-4-git-send-email-zhouyanjie@wanyeetech.com> From: Zhou Yanjie Message-ID: <89d22457-8c62-e441-3bf4-2734ec2a45e1@wanyeetech.com> Date: Sun, 24 Jul 2022 01:06:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, On 2022/7/23 上午2:38, Mark Brown wrote: > On Sat, Jul 23, 2022 at 12:48:30AM +0800, 周琰杰 (Zhou Yanjie) wrote: > > This looks mostly good, a few small issues though: > >> +++ b/drivers/spi/spi-ingenic-sfc.c >> @@ -0,0 +1,662 @@ >> +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +/* >> + * Ingenic SoCs SPI Flash Controller Driver > Please make the entire comment a C++ one so things look more > intentional. I'm sorry, I didn't understand well what you meant :( Could you please explain a little more detail? > >> +static irqreturn_t ingenic_sfc_irq_handler(int irq, void *data) >> +{ >> + struct ingenic_sfc *sfc = data; >> + >> + writel(0x1f, sfc->base + SFC_REG_INTC); >> + >> + complete(&sfc->completion); >> + >> + return IRQ_HANDLED; >> +} > This doesn't pay any attention to any status registers in the chip so > won't work if the interrupt is shared and won't notice any error reports > from the device... This interrupt is exclusively owned by SFC, do we still need to perform the operation you said? I haven't done these operations before because I want to minimize the overhead and avoid affecting performance. > >> +static int ingenic_sfc_setup(struct spi_device *spi) >> +{ >> + struct ingenic_sfc *sfc = spi_controller_get_devdata(spi->master); >> + unsigned long rate; >> + int ret, val; >> + >> + if (!spi->max_speed_hz) >> + return -EINVAL; >> + >> + ret = clk_set_rate(sfc->clk, spi->max_speed_hz * 2); >> + if (ret) >> + return -EINVAL; > The setup() operation should be safe for use on one device while another > device is active. It's not going to be a problem until there's a > version of the IP with more than one chip select, but that could happen > some time (and someone might decide to make a board using GPIO chip > selects...) but this should really go into the data path. Sure, I will change it in the next version. >> + ret = clk_prepare_enable(sfc->clk); >> + if (ret) >> + goto err_put_master; > Nothing ever disables this clock. It might also be nice to enable the > clock only when the controller is in use, that bit is not super > important though. Sure, will add it. > >> + ret = devm_request_irq(&pdev->dev, sfc->irq, ingenic_sfc_irq_handler, 0, >> + dev_name(&pdev->dev), sfc); >> + if (ret) { >> + dev_err(&pdev->dev, "Failed to request irq%d, ret = %d\n", sfc->irq, ret); >> + goto err_put_master; >> + } > It's not safe to use devm here... Sure, will fix it in the next version. > >> + ret = devm_spi_register_controller(&pdev->dev, ctlr); >> + if (ret) >> + goto err_put_master; > ...unregistering the controller may free the driver data structure and > the interrupt handler uses it so we could attempt to use freed data in > the window between the controller being unregistered and the interrupt > being freed. Sure. Thanks and best regards!