Received: by 10.223.176.5 with SMTP id f5csp1029277wra; Tue, 30 Jan 2018 23:53:49 -0800 (PST) X-Google-Smtp-Source: AH8x225ReCK/TFqa8Su3733SHNtiQPqmuvO2/HKUsrAFGe9LlGW8t3jH9MIAZ0Pm8UWZLL3tUqWL X-Received: by 10.98.144.213 with SMTP id q82mr32864350pfk.59.1517385229866; Tue, 30 Jan 2018 23:53:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517385229; cv=none; d=google.com; s=arc-20160816; b=vfCPu4z3imqSHME7ceNyuGc1sSQmoPEe5eSHgVrd6NcMMV0q9kuVRGNtBVL55tsOXr XNMdlL1OuFXXw6v+RH803JG9aV0SKsKqtBOZgpaWR5cyKq+HJ4j5cJ2UFpcYFUQqpVv1 Q6JXwZkigBh45XYwaVyTZ1RPwIe+1eP2tg0kzD37Mtf3CkdvmSLI8VC1HXgJDlMmcOaj GFbCgUULEFGtT0T551gIRZlPg+dw4jQcud2+m5beIe9Jl7bgfHZlz3LbkCQZctapIf9I HiBX5KiQEfwnLuXnRJyX+W5I/CUWpNl+i+8Wm0glp+oPhd3qbYj+b9uLe8age5QUbYHv Tn/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=InTdnfOjj3Xxp4vt6VQJSo5EHL2xT2xSovU1naxl+/Y=; b=vp27/AUsSKfCQvZN0C3loFzthRBJqOPjgMOorzJ9Nh40h1w2abQKiQBfohEBOYklpK i8HytuUsQ/mLZ0s+t4A+V06+9tKtlArpWUze7En12K4g29bNLhNCQL66rhePoyU4uL9V ysz0cnnZSmWEkaVU6EdpR9J0xVHgS5GyW74vA5yLaboOJYXmdMIAe6ELJGdpzRYCj/pX fGXZluo08S/Wb415h2MTh8pXWiwT/aEeMaFx2yU6wpul2xzWPHWDNMO5BEhB2AS0KzKv oSKfio2WqXLGYWb7Ex0kH9885T4Y/oK0bJwXUWRtnQ8H+LdqZF1w1UyQCJQNlm6W9mcA Xeyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HObbqm/c; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p128si1033251pga.15.2018.01.30.23.53.34; Tue, 30 Jan 2018 23:53:49 -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=@chromium.org header.s=google header.b=HObbqm/c; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752970AbeAaHxK (ORCPT + 99 others); Wed, 31 Jan 2018 02:53:10 -0500 Received: from mail-ua0-f193.google.com ([209.85.217.193]:39066 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752833AbeAaHxI (ORCPT ); Wed, 31 Jan 2018 02:53:08 -0500 Received: by mail-ua0-f193.google.com with SMTP id e18so8849017ual.6 for ; Tue, 30 Jan 2018 23:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=InTdnfOjj3Xxp4vt6VQJSo5EHL2xT2xSovU1naxl+/Y=; b=HObbqm/cDtU2w/IjJeIZeBl/0KkqcIoCb5EsrEXxWBbmliRMy4etyFoNVj0Lgr+uF3 0uJJg8VLRfCtWIYLStUVVrZLWstiBZ10WTXi0jeZ/x+m1lQqmANW/BAMJ1XrMhf76FGA C7paj7b/S/VLVU7rGzSKo2nnSvAFZ0urX7U8I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=InTdnfOjj3Xxp4vt6VQJSo5EHL2xT2xSovU1naxl+/Y=; b=blPQU1dmC+jiX6E9EBuRVfXA+hSjS3r1xzVDuxCWKKTOFGybhRRG/tHFCWXUqSMYo3 Np3iWqTZr2xDssTBr2WaOBU8Wg1JU2+MnW9P0cILCrMZErTbDC0ERuL8/rLlTqcTL5R3 PjvK6i2TwGCkoT8bIymfYj5mJoKTF11iSrjYw2wQKGSDXjS3/BvPYSlCH5rGBX+gbrAA +eTGy7v4BbPFdKPAzQOZsC+2hZ5ffM+remBrToDYHI1rUc6fWBEWL4mrH3CX8ocYblFz bzKcEASRZlsSx47NHg9ZxND0iWbx16ts1J/OKzmMZ4cw2Ns1xm+xhKfB3XoE6bQZEbir iSqQ== X-Gm-Message-State: AKwxytdySxv2uKvQ8EvzuHRSy4wE6GoXWrwdkhyXByY9l6gU4uaCGccR c11UtpeY/AeOcxNmzFCFf6xAMkkX1oE= X-Received: by 10.176.6.232 with SMTP id g95mr25012644uag.172.1517385187403; Tue, 30 Jan 2018 23:53:07 -0800 (PST) Received: from mail-ua0-f174.google.com (mail-ua0-f174.google.com. [209.85.217.174]) by smtp.gmail.com with ESMTPSA id t24sm132508ual.54.2018.01.30.23.53.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jan 2018 23:53:06 -0800 (PST) Received: by mail-ua0-f174.google.com with SMTP id i15so8833449uak.3 for ; Tue, 30 Jan 2018 23:53:05 -0800 (PST) X-Received: by 10.159.50.7 with SMTP id x7mr22639301uad.68.1517385185004; Tue, 30 Jan 2018 23:53:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.45.142 with HTTP; Tue, 30 Jan 2018 23:52:44 -0800 (PST) In-Reply-To: <20180130170515.3g6wtadqgmehxh5b@rob-hp-laptop> References: <20180124103516.2571-1-jeffy.chen@rock-chips.com> <20180124103516.2571-9-jeffy.chen@rock-chips.com> <20180130170515.3g6wtadqgmehxh5b@rob-hp-laptop> From: Tomasz Figa Date: Wed, 31 Jan 2018 16:52:44 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 08/13] iommu/rockchip: Control clocks needed to access the IOMMU To: Rob Herring Cc: Jeffy Chen , linux-kernel@vger.kernel.org, Ricky Liang , Robin Murphy , simon xue , devicetree@vger.kernel.org, Heiko Stuebner , "open list:ARM/Rockchip SoC..." , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Mark Rutland , Joerg Roedel , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rob, On Wed, Jan 31, 2018 at 2:05 AM, Rob Herring wrote: > On Wed, Jan 24, 2018 at 06:35:11PM +0800, Jeffy Chen wrote: >> From: Tomasz Figa >> >> Current code relies on master driver enabling necessary clocks before >> IOMMU is accessed, however there are cases when the IOMMU should be >> accessed while the master is not running yet, for example allocating >> V4L2 videobuf2 buffers, which is done by the VB2 framework using DMA >> mapping API and doesn't engage the master driver at all. >> >> This patch fixes the problem by letting clocks needed for IOMMU >> operation to be listed in Device Tree and making the driver enable them >> for the time of accessing the hardware. >> >> Signed-off-by: Jeffy Chen >> Signed-off-by: Tomasz Figa >> --- >> >> Changes in v5: >> Use clk_bulk APIs. >> >> Changes in v4: None >> Changes in v3: None >> Changes in v2: None >> >> .../devicetree/bindings/iommu/rockchip,iommu.txt | 8 +++ > > Please split binding patches to a separate patch. > >> drivers/iommu/rockchip-iommu.c | 74 ++++++++++++++++++++-- >> 2 files changed, 76 insertions(+), 6 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt b/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt >> index 2098f7732264..33dd853359fa 100644 >> --- a/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt >> +++ b/Documentation/devicetree/bindings/iommu/rockchip,iommu.txt >> @@ -14,6 +14,13 @@ Required properties: >> "single-master" device, and needs no additional information >> to associate with its master device. See: >> Documentation/devicetree/bindings/iommu/iommu.txt >> +Optional properties: >> +- clocks : A list of master clocks requires for the IOMMU to be accessible >> + by the host CPU. The number of clocks depends on the master >> + block and might as well be zero. See [1] for generic clock >> + bindings description. > > Hardware blocks don't have a variable number of clock connections. I think you underestimate the imagination of hardware designers. :) For Rockchip IOMMU, there is a set of clocks, which all need to be enabled for IOMMU register access to succeed. The clocks are not directly fed to the IOMMU, but they are needed for the various buses and intermediate blocks on the way to the IOMMU to work. And the set varies based on next to which master block the IOMMU block is located, because the hierarchy of buses and intermediate blocks is different. Best regards, Tomasz