Received: by 10.223.176.46 with SMTP id f43csp472438wra; Fri, 26 Jan 2018 01:46:39 -0800 (PST) X-Google-Smtp-Source: AH8x224v9Y5ju1oxZQjwiGCyF8YlY21lHfxbEw94XXCHKWZg66viPgbYg4vnADoN1vp7MGyB/JpW X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr13718291plk.212.1516959999760; Fri, 26 Jan 2018 01:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516959999; cv=none; d=google.com; s=arc-20160816; b=NTmotEcEPykuUaDpA0kIKnS24RTwzIVn+wVFfsyv9e24hKjS2F8C6ThTkfPvevOmxi yrilVjOX1KVHLnKqwuAFRgc32bIe/XWtbByczubNUyyOisgvM8cNr2D8NFyVjGvZ7+X9 jfwrjOnTupeneHE/GhJv9qE4UoB9EOVJGyEs6CX4uZPhIBrUB3xLpKfg1h67r/v9776Q 6EgE5tZcpeGpVKg7MsElaFj1k4FOFt65cATg9/xbEnz5zWnyaum0JEZ3chmlgyHfE9Up E3u09BARjbhv7+eLdn/bwVTXFudPJgtNfAvxsCxhisLmKtSORGpKqJ02vK02kS/91ETY eVwQ== 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:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id:arc-authentication-results; bh=ncMdyr0IA908LLNd6oVcQneoLEftH9oGc9cMaWmdCqg=; b=jqyLjtt5XykgyNuFtW0Ie/ZRdyIMTsqiUmAX8TqCxkxDcfDO3VZiIHZwTic/3XAvNz cqT12nOaQdh05wjO5vrHgmRHAsengVlV0UbAtgXgvpykHdaXIev6BQFQaOlzoRIS1/h8 JUvB8XGBYwL+pGwLYxkUlh87sUVagfrgmN9ItK7dqHf0ks6w/ZTmkdBp9VDQlx8utAX9 /5UsEBGFkhFmKhdrkbTXt3En+OikCt5rwZIuu72FWwB+iMwFQgF9pyALdtkfnzLXabtf 0pdjzTRU6JAORkQEy26jvn1DW86qZA+rZ6W24o3pzOd+Q3vGQ/HnfwQvHO6kjNYNSaaj x6tA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si3508235plz.396.2018.01.26.01.46.24; Fri, 26 Jan 2018 01:46:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946AbeAZJpy (ORCPT + 99 others); Fri, 26 Jan 2018 04:45:54 -0500 Received: from regular1.263xmail.com ([211.150.99.140]:51439 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752707AbeAZJpw (ORCPT ); Fri, 26 Jan 2018 04:45:52 -0500 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.16]) by regular1.263xmail.com (Postfix) with ESMTP id 6DD1A4AA5; Fri, 26 Jan 2018 17:45:42 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from [172.16.22.190] (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id CCCF93B0; Fri, 26 Jan 2018 17:45:33 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: robin.murphy@arm.com X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <95af7eb317fcec0420d788cf8c265f6c> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from [172.16.22.190] (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 15829FYPE4V; Fri, 26 Jan 2018 17:45:43 +0800 (CST) Message-ID: <5A6AF8BB.4040601@rock-chips.com> Date: Fri, 26 Jan 2018 17:45:31 +0800 From: JeffyChen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20130126 Thunderbird/19.0 MIME-Version: 1.0 To: Robin Murphy , linux-kernel@vger.kernel.org CC: jcliang@chromium.org, xxm@rock-chips.com, tfiga@chromium.org, devicetree@vger.kernel.org, Heiko Stuebner , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Rob Herring , Mark Rutland , Joerg Roedel , linux-arm-kernel@lists.infradead.org, aisheng.dong@nxp.com Subject: Re: [PATCH v5 08/13] iommu/rockchip: Control clocks needed to access the IOMMU References: <20180124103516.2571-1-jeffy.chen@rock-chips.com> <20180124103516.2571-9-jeffy.chen@rock-chips.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, Thanks for your reply. On 01/24/2018 09:49 PM, Robin Murphy wrote: >> >> +Optional properties: >> +- clocks : A list of master clocks requires for the IOMMU to be >> accessible > > s/requires/required/ ok > >> + by the host CPU. The number of clocks depends on the master >> + block and might as well be zero. See [1] for generic clock > > Oops, some subtleties of English here :) > > To say "the number of clocks ... might as well be zero" effectively > implies "there's no point ever specifying any clocks". I guess what you > really mean here is "...might well be...", i.e. it is both valid and > reasonably likely to require zero clocks. ok > >> + bindings description. >> + >> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt >> Optional properties: >> - rockchip,disable-mmu-reset : Don't use the mmu reset operation. >> @@ -27,5 +34,6 @@ Example: >> reg = <0xff940300 0x100>; >> interrupts = ; >> interrupt-names = "vopl_mmu"; >> + clocks = <&cru ACLK_VOP1>, <&cru DCLK_VOP1>, <&cru HCLK_VOP1>; >> #iommu-cells = <0>; >> }; >> diff --git a/drivers/iommu/rockchip-iommu.c >> b/drivers/iommu/rockchip-iommu.c >> index c4131ca792e0..8a5e2a659b67 100644 >> --- a/drivers/iommu/rockchip-iommu.c >> +++ b/drivers/iommu/rockchip-iommu.c >> @@ -4,6 +4,7 @@ >> * published by the Free Software Foundation. >> */ >> +#include >> #include >> #include >> #include >> @@ -91,6 +92,8 @@ struct rk_iommu { >> struct device *dev; >> void __iomem **bases; >> int num_mmu; >> + struct clk_bulk_data *clocks; >> + int num_clocks; >> bool reset_disabled; >> struct iommu_device iommu; >> struct list_head node; /* entry in rk_iommu_domain.iommus */ >> @@ -450,6 +453,38 @@ static int rk_iommu_force_reset(struct rk_iommu >> *iommu) >> return 0; >> } >> +static int rk_iommu_of_get_clocks(struct rk_iommu *iommu) >> +{ >> + struct device_node *np = iommu->dev->of_node; >> + int ret; >> + int i; >> + >> + ret = of_count_phandle_with_args(np, "clocks", "#clock-cells"); >> + if (ret == -ENOENT) >> + return 0; >> + else if (ret < 0) >> + return ret; >> + >> + iommu->num_clocks = ret; >> + iommu->clocks = devm_kcalloc(iommu->dev, iommu->num_clocks, >> + sizeof(*iommu->clocks), GFP_KERNEL); >> + if (!iommu->clocks) >> + return -ENOMEM; >> + >> + for (i = 0; i < iommu->num_clocks; ++i) { >> + iommu->clocks[i].clk = of_clk_get(np, i); >> + if (IS_ERR(iommu->clocks[i].clk)) { >> + ret = PTR_ERR(iommu->clocks[i].clk); >> + goto err_clk_put; >> + } >> + } > > Just to confirm my understanding from a quick scan through the code, the > reason we can't use clk_bulk_get() here is that currently, clocks[i].id > being NULL means we'd end up just getting the first clock multiple > times, right? right, without a valid name, it would return the first clock. /* Walk up the tree of devices looking for a clock that matches */ while (np) { int index = 0; /* * For named clocks, first look up the name in the * "clock-names" property. If it cannot be found, then * index will be an error code, and of_clk_get() will fail. */ if (name) index = of_property_match_string(np, "clock-names", name); clk = __of_clk_get(np, index, dev_id, name); > > I guess there could be other users who also want "just get whatever > clocks I have" functionality, so it might be worth proposing that for > the core API as a separate/follow-up patch, but it definitely doesn't > need to be part of this series. right, i can try to do it later :) > > I really don't know enough about correct clk API usage, but modulo the > binding comments it certainly looks nice and tidy now; > > Acked-by: Robin Murphy thanks. > > Thanks, > Robin.