Received: by 10.223.185.116 with SMTP id b49csp559039wrg; Wed, 14 Feb 2018 03:29:35 -0800 (PST) X-Google-Smtp-Source: AH8x226Fime7ij/ctWq8rUcUSGskHSaicywOU7ebgjmYCLk3W3nuh63ZYoca+OxOK7mGJblI2tp3 X-Received: by 2002:a17:902:12d:: with SMTP id 42-v6mr4311566plb.141.1518607774971; Wed, 14 Feb 2018 03:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518607774; cv=none; d=google.com; s=arc-20160816; b=QyCPfIFtHVO96kJk/66w5RPDjYOrfMFy0IuULad+fkpyEZjpI9k/J6XRsF3nK2M0LL dAxaSlb3BAIjlJOx9BK+4xm61FI618K2iKTEZgX5vjtwNH6x1GHQOz1JIgJEuCADJN3T hoy9dL1wsk7PLYvsIVQIerJY/J/SbHSpNwqQ5/dadNJk++p71htsJQZp090yM76kpFoZ 16O4KqPQcSx5DIuZUCA2vGWa+0LwzPDZi1WizNTooXKQwqhVIvrqMA0f4RL5wJ1TwyEA +6y2B4AnVGnWkbuIKaqrS8/4/gFtITSO0sprPoKi3EJ6+bDaknNlicLgHhUVk9SNamyF qMMw== 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=ahKTzFucfIRidLzzi4U4r3NVg+wUVrvM+iSyGRg14Xc=; b=DWlke6Gr8fBCtB9IPOafpSCzY8Yc/AdtFgX2ryqXGZD8vqrGJYf4S/nykOVTbWsIMZ DBhcg2PlaRYvkSYSc3wcGD+U7Fm5cLceAISZKzbdI89Ejku2pBgIF//7hivc3rFWYFUd eoo74r1kZmc55r8wrFMs6o8I1ZrZY72zm6cw7lhVLwX+WJS9ygZOHDmPrSm0/MDURlxR s10Y6Sp09d55IM6J9lvyI8/1UtJAs4W2+sckAFPXkGrAxUXgHf1pu182EFIN3CgRLUEP 4tHh4D2vy8VNC8ndwXq02t3cdysjxrarNnExcTL8hRbaILCssYqgdWOt91Ughgd2CgN9 puGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=m3nS0IWP; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si2980334pff.233.2018.02.14.03.29.20; Wed, 14 Feb 2018 03:29:34 -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=@google.com header.s=20161025 header.b=m3nS0IWP; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967465AbeBNL1x (ORCPT + 99 others); Wed, 14 Feb 2018 06:27:53 -0500 Received: from mail-vk0-f54.google.com ([209.85.213.54]:38345 "EHLO mail-vk0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967415AbeBNL1u (ORCPT ); Wed, 14 Feb 2018 06:27:50 -0500 Received: by mail-vk0-f54.google.com with SMTP id z9so12651162vkd.5 for ; Wed, 14 Feb 2018 03:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ahKTzFucfIRidLzzi4U4r3NVg+wUVrvM+iSyGRg14Xc=; b=m3nS0IWP05QiSuSQ7YcV6Cjje0No/E42uYXD8ew6wkq+U/Z3LeAJ7D0QGT8rTRwViM G8KiIZaV5iEPLrYdKwnVSXttR4iQDFetf0x+XgRuvqK30sp4t8lDOb8Iu5GlFug/aMRd WTUdDrb6ppRNusDEOj2BVuHotvnkpH76Zu+8M//5cGIQsJhpKmpi7al20Yi+pa+jNfXg CYhCDj/Y86/UCSETZg16RtxSCK2mfpGg82K0ueT72Oc7seSofAhX0v6qzeqbM9A4z1TB KY2DmCOBGiVQbGWr8z8Lexlnx03M0fiNUcrdq5RiOjbbugnOkX2vU9OdxR18IGlwArQH 7ozQ== 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=ahKTzFucfIRidLzzi4U4r3NVg+wUVrvM+iSyGRg14Xc=; b=RGUAfJK41DenoRmzKNQ2haKSFSqhUB9t9GefOfwzXqe7ZJOIFZ7Ey1xOamsU9cp9f+ tCFgX0IpeNvIs7k4LUiKS+AbpS7zO2e4jqZYYbrcdQFC8SxC4q62+TN52lwFX7OCTn43 0crOiiqk0CBuFZSxy6nbJVUrOvT3+8loMnBF7O2m9IuhPjLtCJwoKwrVRzlmV/TV6qXd G5/+qAJw8G16Cmizj5niLqInEfSPk6UnXxRg6sTVEOYuTZMnXShYw2jIaH7au4slfbTQ iqsLuz1V7SyLGlWFqW+Dxsa6qVUNSaZIg28qkn/oZXhUyRArQjiGbc8rR+Sg5XBQ4577 Ir4Q== X-Gm-Message-State: APf1xPBC5Sph5Z2z/HIxbNzHaPQlyBQ3ggnN28kOwphBVZG2X9oUUa4R +sWt35QLYltsGVEioAMmffJpYvWgpswyDv1yiVC3HA== X-Received: by 10.31.77.135 with SMTP id a129mr4252474vkb.36.1518607669279; Wed, 14 Feb 2018 03:27:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.0.68 with HTTP; Wed, 14 Feb 2018 03:27:28 -0800 (PST) In-Reply-To: References: <20180124103516.2571-1-jeffy.chen@rock-chips.com> <20180124103516.2571-9-jeffy.chen@rock-chips.com> From: Tomasz Figa Date: Wed, 14 Feb 2018 20:27:28 +0900 Message-ID: Subject: Re: [PATCH v5 08/13] iommu/rockchip: Control clocks needed to access the IOMMU To: Vivek Gautam Cc: Robin Murphy , Jeffy Chen , Linux Kernel Mailing List , Mark Rutland , devicetree@vger.kernel.org, Heiko Stuebner , Ricky Liang , "open list:ARM/Rockchip SoC..." , "open list:IOMMU DRIVERS" , Rob Herring , "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 On Wed, Feb 14, 2018 at 7:03 PM, Vivek Gautam wrote: > > > On 1/24/2018 7:19 PM, Robin Murphy wrote: >> >> On 24/01/18 10:35, 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 > > > [snip] > > >>> +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? >> >> 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. > > > Just to understand. Is it okay to make the driver "just get whatever clocks > device node gives"? > Doesn't the driver need to be aware of which all clocks are supposed to be > obtained and enabled > It's should good for debug to let the world know which clock we failed to > get. Yeah, in general that's desired. However, it is at least impractical to specify all the clocks in Rockchip case, because it's different for each block and depends on the master next to which it is located. Best regards, Tomasz