Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp414722img; Tue, 26 Feb 2019 02:18:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IZFsCcWLEtthpx3VJ6ouMrfp0nWqH1LstQh36FiCHAvJuo9ZGpWyVsVH/IERpEY/ZSb4vzE X-Received: by 2002:a63:d25:: with SMTP id c37mr22215780pgl.230.1551176285936; Tue, 26 Feb 2019 02:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551176285; cv=none; d=google.com; s=arc-20160816; b=B3n6jwgtKzUy5w0JpjklYdgLjz3mGmjEApcb7abK3hfVPb91G0vkHu9tfDl3xjWoAe M/ow5MA3arID4VBbet5c9oAFyFIXlglxKyWuqEdp5LdRCqqWtjDfee3E9mHNZ4VmmPzZ xaxYZc4lqam8O66/0ZdES/ajs4+t+3sFh2S+S8fAsVEESP9TvWCqOLJQ6nTxtxN56ILD sShKyJcpuMe+rHZx0XkZyq05Tr7Ov7SUb5PQ9++qOVqPgroWWwTcEwz5uFMDiIosDpp+ gmMpbk0n3Yc014dprLUKGuc6AGKwIa+bIK6KyfnJrzY6HL0n3RKJdkCli3qp7x9pp0RW cf/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=WA/f8ss2biY7S1l6fEMwhLw3XtRQh3PtpW9p8svW6C4=; b=Eno8GxiUOVtiyX/RPcfynfCtBgX82Dqm7rpRK3C35MA3vYuSD/9pdJzWFzK7+ZloLE v5K4DWhmFAHHYAiOp9akn63FOzyTCjPUP3wvLDc2B16BEYyfUutzOyw42eA5RPth1vfN wwi5jFCrLm1yUtA9bJTXLZcSkDkst3K+wTNNYT/dFtT+AS5d4rWjaiBiX1ZITfDGtAFa wrnEmS2BzO/GW3855R7NImi3m3H4imnPZtnNEaySLpQGjtrT2ntJMwJhBrP7ZbuieI2I V7e1+Xt02T2uGOJKf9MdQoI8J0IUHAviaVMuikM3aTfwuO+In+Vvh2cI9U9cg49jUOEa Qlnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lqa0Vgu1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7si12407302pgb.116.2019.02.26.02.17.50; Tue, 26 Feb 2019 02:18:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lqa0Vgu1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727476AbfBZKRX (ORCPT + 99 others); Tue, 26 Feb 2019 05:17:23 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:51842 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbfBZKRX (ORCPT ); Tue, 26 Feb 2019 05:17:23 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x1QAH4iJ117079; Tue, 26 Feb 2019 04:17:04 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1551176224; bh=WA/f8ss2biY7S1l6fEMwhLw3XtRQh3PtpW9p8svW6C4=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=lqa0Vgu1Eo6UUx+ha4mwXvJaE76MvI1F5gCeVIFfew6xnwE5I0z9rcQ0kBiE90tsw M579QnuhehevAbsA93TvXqMcyTFNLqi6I02yV5bMb3YMHok4FYPvTGjBTXGLhNfr8o zIQ6NXF0sF/zQi8NKQ+KBbNjBg6eYiEeUZf+dKlI= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x1QAH3gT103790 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 26 Feb 2019 04:17:03 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Tue, 26 Feb 2019 04:17:03 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Tue, 26 Feb 2019 04:17:03 -0600 Received: from [172.24.190.89] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x1QAGwMX006788; Tue, 26 Feb 2019 04:16:59 -0600 Subject: Re: [RFC PATCH 5/5] mtd: hyperbus: Add driver for TI's Hyperbus memory controller To: Sergei Shtylyov , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Rob Herring CC: , Arnd Bergmann , , Greg Kroah-Hartman , , , , References: <20190219063607.29949-1-vigneshr@ti.com> <20190219063607.29949-6-vigneshr@ti.com> <907041d1-8412-22ca-3716-109a56251850@cogentembedded.com> From: Vignesh R Message-ID: <24b7c553-44c9-4800-a455-31b9b2c1f8c5@ti.com> Date: Tue, 26 Feb 2019 15:48:00 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <907041d1-8412-22ca-3716-109a56251850@cogentembedded.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/02/19 9:59 PM, Sergei Shtylyov wrote: > Hello! > > On 02/19/2019 09:36 AM, Vignesh R (by way of Boris Brezillon ) wrote: > >> Add driver for Hyperbus memory controller on TI's AM654 SoC. Programming >> IP is pretty simple and provides direct memory mapped access to >> connected Flash devices. > > Are you sure you posted the _complete_ driver? > Yes, it is... You can find controller doc here[1]. Default values in the MCR/MTR registers are good enough to simple Hyperflash access. More perf optimization and timing optimizations will come incrementally [1] http://www.ti.com/lit/ug/spruid7b/spruid7b.pdf 12.3.3 Hyperbus Interface >> Add basic support for the IP without DMA. Second ChipSelect is not >> supported for now. >> >> Signed-off-by: Vignesh R >> --- >> drivers/mtd/hyperbus/hbmc_am654.c | 105 ++++++++++++++++++++++++++++++ >> 1 file changed, 105 insertions(+) >> create mode 100644 drivers/mtd/hyperbus/hbmc_am654.c >> >> diff --git a/drivers/mtd/hyperbus/hbmc_am654.c b/drivers/mtd/hyperbus/hbmc_am654.c >> new file mode 100644 >> index 000000000000..1f0d2dc52f9f >> --- /dev/null >> +++ b/drivers/mtd/hyperbus/hbmc_am654.c >> @@ -0,0 +1,105 @@ > [...] >> +static int am654_hbmc_probe(struct platform_device *pdev) >> +{ >> + struct device *dev = &pdev->dev; >> + struct am654_hbmc_priv *priv; >> + struct resource *res; >> + int err; >> + >> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); >> + if (!priv) >> + return -ENOMEM; >> + >> + platform_set_drvdata(pdev, priv); >> + >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> + if (IS_ERR(res)) { >> + dev_err(&pdev->dev, "failed to get memory resource\n"); >> + return -ENOENT; >> + } >> + >> + priv->regbase = devm_ioremap_resource(dev, res); >> + if (IS_ERR(priv->regbase)) { >> + dev_err(dev, "Cannot remap controller address.\n"); >> + return PTR_ERR(priv->regbase); >> + } >> + >> + pm_runtime_enable(&pdev->dev); >> + err = pm_runtime_get_sync(&pdev->dev); > > That's all nice but where's the code that accesses the actual registers? Interface and functional clk needs to be enabled even to access MMIO space to read/write data to flash (done by the map framework). So driver currently just enables everything during probe and disables on remove > >> + if (err < 0) { >> + pm_runtime_put_noidle(&pdev->dev); > > Calling "put" with previously failed "get" sees strange... > Basically pm_runtime_get_sync() increments usage_count even in case of failure and pm_runtime_put_noidle() puts it back. You can find many examples of above piece of code in kernel. >> + return err; >> + } >> + >> + priv->hbdev.needs_calib = true; >> + priv->hbdev.dev = &pdev->dev; >> + priv->hbdev.np = of_get_next_child(dev->of_node, NULL); >> + err = hb_register_device(&priv->hbdev); >> + if (err) { >> + dev_err(&pdev->dev, "failed to register controller\n"); >> + goto err_destroy; >> + } >> + >> + return 0; >> + >> +err_destroy: >> + hb_unregister_device(&priv->hbdev); > > Calling "unregister" with "register" previously failed also looks strange... > Agree, this is unneeded as hb_register_device() takes care of all cleanups in err path. >> + pm_runtime_put_sync(&pdev->dev); > > Why the sync() version? > Why not? Since the device is going away, I think its safer to ensure device has definitely been put to idle state. I see its a common practice in driver code. >> + return err; >> +} > [...] > > MBR, Sergei > -- Regards Vignesh