Received: by 10.213.65.68 with SMTP id h4csp221165imn; Tue, 13 Mar 2018 01:59:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELuWBmdzZvp6vCNvhX+YQOJcZ5qgrXo7SXHY+cXaVb7fKc5IvSFQ9FujGNJEhtYC3rNIB2Zc X-Received: by 2002:a17:902:76c9:: with SMTP id j9-v6mr6861835plt.250.1520931581379; Tue, 13 Mar 2018 01:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520931581; cv=none; d=google.com; s=arc-20160816; b=rqxm7CzCCVy2CZzq+fly3oH9K1w6zurA42chBvFmakqsOOdcQMLvzEwdJdWKKKmx+c Jkx8GzvPOfWAQU8MqmuaI9667R7APKZrwW+1inyiJS3xEiOfYV8lY7D+Qjnjsd3pKLmN 89YZddg1ZxnKthv4k5bDFcw39MmKiDysmD/HMcN+C/unSCBN7gLfjl70cQBeJhEtKVCh zo8FsiQ7CHOp8x9OTz/pwpdz1NAU6QYgryg8pAYAQyVZ7YCd2UTS7KpxEQ35lOD39rNl lw6E+Jlb+gwkH9RpTZcJTRunHEjCSxyRjcjlL944wWG/aWS2ecrHjZWFoeHu9DvqmmgT bbaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=h+ELcrmywAA6wjlCdnzQKq46IV7qW/8GC/tvCPFokJg=; b=gMk5Jz4eWio681tfL84+rdNbvisyLuJYS3CcZlsCFC3byRk5jhwmSHzSBsaruNl/0J CeeHnio08xF3jGzZxij4fATRwOA2HXfWLJbLjHgoHIlbXbPpyX4lLyr9ErcRt4tY4ngY o+lHyBxUeIhH3JukXxkDWRcY/vDL2YxkXzOuuTzSpS9Z3OfWf8q46lErXj+RwaeoWAIw 7yxBGDJmJ4eMdJvVNXD6kle0qUfST/LmtZjHwixX9DrDK8csXR8cQRP1GRFSa8oKOkyN 0s6jWWOzFY0DxJm5afhfksmXvI9Xglpk+FKOJX7juG+FuyxiNv/llbr9U2XAnIaILOce FdLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=DmIuNEMD; dkim=pass header.i=@codeaurora.org header.s=default header.b=AfFT2X/Q; 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 d12si6204365pgq.734.2018.03.13.01.59.25; Tue, 13 Mar 2018 01:59:41 -0700 (PDT) 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=@codeaurora.org header.s=default header.b=DmIuNEMD; dkim=pass header.i=@codeaurora.org header.s=default header.b=AfFT2X/Q; 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 S1752515AbeCMI4H (ORCPT + 99 others); Tue, 13 Mar 2018 04:56:07 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37022 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752466AbeCMI4E (ORCPT ); Tue, 13 Mar 2018 04:56:04 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4839E60807; Tue, 13 Mar 2018 08:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520931363; bh=RymPXr798gAxD6zuzrS6KVTm8jjFI8UK3JGw6Zd0DGI=; h=From:To:Cc:Subject:Date:From; b=DmIuNEMDXhqZfSPO2bj+9QaHT5I/TqUmaMmggdst07PMErgw8RNwN9bE/qZeTeJ45 P6awFrZg78/Csm4mofmurVBuS60lLq6biLBJieboj3mU7Xs7LIhAAVqyHgHGS+wKJi 1zQm8nJi5vASMxiYubPv67cLkwyqlcGeVcDh+7Ig= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from blr-ubuntu-41.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D9DE560300; Tue, 13 Mar 2018 08:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520931361; bh=RymPXr798gAxD6zuzrS6KVTm8jjFI8UK3JGw6Zd0DGI=; h=From:To:Cc:Subject:Date:From; b=AfFT2X/Qly9hgd7QAPIzxAZ6dMBxlLj7cSewHEsjq7wAkt+nOLDwqo1WntEeMJrLc +jDnUCpo6W61rqe5S/O+ZYDOEynvG3kmA8n6Pk+Cc8RlliuR+Qvl7G5q+w6kCDEt2y pOegXVUg9H5DrIPv4ygEfYNTzwYKDGJdE0HMOUbo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D9DE560300 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org From: Vivek Gautam To: joro@8bytes.org, robh+dt@kernel.org, robin.murphy@arm.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: mark.rutland@arm.com, will.deacon@arm.com, robdclark@gmail.com, tfiga@chromium.org, sricharan@codeaurora.org, m.szyprowski@samsung.com, architt@codeaurora.org, linux-arm-msm@vger.kernel.org, vivek.gautam@codeaurora.org Subject: [PATCH v9 0/5] iommu/arm-smmu: Add runtime pm/sleep support Date: Tue, 13 Mar 2018 14:25:29 +0530 Message-Id: <20180313085534.11650-1-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series provides the support for turning on the arm-smmu's clocks/power domains using runtime pm. This is done using the recently introduced device links patches, which lets the smmu's runtime to follow the master's runtime pm, so the smmu remains powered only when the masters use it. As not all implementations support clock/power gating, we are checking for a valid 'smmu->dev's pm_domain' to conditionally enable the runtime power management for such smmu implementations that can support it. This series also adds support for Qcom's arm-smmu-v2 variant that has different clocks and power requirements. Took some reference from the exynos runtime patches [1]. With conditional runtime pm now, we avoid touching dev->power.lock in fastpaths for smmu implementations that don't need to do anything useful with pm_runtime. This lets us to use the much-argued pm_runtime_get_sync/put_sync() calls in map/unmap callbacks so that the clients do not have to worry about handling any of the arm-smmu's power. Previous version of this patch series is @ [5]. [v9] * Removed 'rpm_supported' flag, instead checking on pm_domain to enable runtime pm. * Creating device link only when the runtime pm is enabled, as we don't need a device link besides managing the power dependency between supplier and consumer devices. * Introducing a patch to add device_link_find() API that finds and existing link between supplier and consumer devices. Also, made necessary change to device_link_add() to use this API. * arm_smmu_remove_device() now uses this device_link_find() to find the device link between smmu device and the master device, and then delete this link. * Dropped the destroy_domain_context() fix [8] as it was rather, introducing catastrophically bad problem by destroying 'good dev's domain context. * Added 'Reviwed-by' tag for Tomasz's review. [v8] * Major change - - Added a flag 'rpm_supported' which each platform that supports runtime pm, can enable, and we enable runtime_pm over arm-smmu only when this flag is set. - Adding the conditional pm_runtime_get/put() calls to .map, .unmap and .attach_dev ops. - Dropped the patch [6] that exported pm_runtim_get/put_suupliers(), and also dropped the user driver patch [7] for these APIs. * Clock code further cleanup - doing only clk_bulk_enable() and clk_bulk_disable() in runtime pm callbacks. We shouldn't be taking a slow path (clk_prepare/unprepare()) from these runtime pm callbacks. Thereby, moved clk_bulk_prepare() to arm_smmu_device_probe(), and clk_bulk_unprepare() to arm_smmu_device_remove(). - clk data filling to a common method arm_smmu_fill_clk_data() that fills the clock ids and number of clocks. * Addressed other nits and comments - device_link_add() error path fixed. - Fix for checking negative error value from pm_runtime_get_sync(). - Documentation redo. * Added another patch fixing the error path in arm_smmu_attach_dev() to destroy allocated domain context. [v7] * Addressed review comments given by Robin Murphy - - Added device_link_del() in .remove_device path. - Error path cleanup in arm_smmu_add_device(). - Added pm_runtime_get/put_sync() in .remove path, and replaced pm_runtime_force_suspend() with pm_runtime_disable(). - clk_names cleanup in arm_smmu_init_clks() * Added 'Reviewed-by' given by Rob H. [V6] * Added Ack given by Rafael to first patch in the series. * Addressed Rob Herring's comment for adding soc specific compatible string as well besides 'qcom,smmu-v2'. [V5] * Dropped runtime pm calls from "arm_smmu_unmap" op as discussed over the list [3] for the last patch series. * Added a patch to export pm_runtime_get/put_suppliers() APIs to the series as agreed with Rafael [4]. * Added the related patch for msm drm iommu layer to use pm_runtime_get/put_suppliers() APIs in msm_mmu_funcs. * Dropped arm-mmu500 clock patch since that would break existing platforms. * Changed compatible 'qcom,msm8996-smmu-v2' to 'qcom,smmu-v2' to reflect the IP version rather than the platform on which it is used. The same IP is used across multiple platforms including msm8996, and sdm845 etc. * Using clock bulk APIs to handle the clocks available to the IP as suggested by Stephen Boyd. * The first patch in v4 version of the patch-series: ("iommu/arm-smmu: Fix the error path in arm_smmu_add_device") has already made it to mainline. [V4] * Reworked the clock handling part. We now take clock names as data in the driver for supported compatible versions, and loop over them to get, enable, and disable the clocks. * Using qcom,msm8996 based compatibles for bindings instead of a generic qcom compatible. * Refactor MMU500 patch to just add the necessary clock names data and corresponding bindings. * Added the pm_runtime_get/put() calls in .unmap iommu op (fix added by Stanimir on top of previous patch version. * Added a patch to fix error path in arm_smmu_add_device() * Removed patch 3/5 of V3 patch series that added qcom,smmu-v2 bindings. [V3] * Reworked the patches to keep the clocks init/enabling function separately for each compatible. * Added clocks bindings for MMU40x/500. * Added a new compatible for qcom,smmu-v2 implementation and the clock bindings for the same. * Rebased on top of 4.11-rc1 [V2] * Split the patches little differently. * Addressed comments. * Removed the patch #4 [2] from previous post for arm-smmu context save restore. Planning to post this separately after reworking/addressing Robin's feedback. * Reversed the sequence to disable clocks than enabling. This was required for those cases where the clocks are populated in a dependent order from DT. [1] https://lkml.org/lkml/2016/10/20/70 [2] https://patchwork.kernel.org/patch/9389717/ [3] https://patchwork.kernel.org/patch/10204925/ [4] https://patchwork.kernel.org/patch/10102445/ [5] https://lkml.org/lkml/2018/3/2/325 [6] https://patchwork.kernel.org/patch/10204945/ [7] https://patchwork.kernel.org/patch/10204925/ [8] https://patchwork.kernel.org/patch/10254105/ Sricharan R (3): iommu/arm-smmu: Add pm_runtime/sleep ops iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device iommu/arm-smmu: Add the device_link between masters and smmu Vivek Gautam (2): driver core: Find an existing link between two devices iommu/arm-smmu: Add support for qcom,smmu-v2 variant .../devicetree/bindings/iommu/arm,smmu.txt | 42 +++++ drivers/base/core.c | 30 +++- drivers/iommu/arm-smmu.c | 198 +++++++++++++++++++-- include/linux/device.h | 2 + 4 files changed, 259 insertions(+), 13 deletions(-) -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation