From patchwork Fri Oct 28 19:12:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp998793wru; Fri, 28 Oct 2022 12:15:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qbWr9AnIFOrL2oAHuliJkSjPQ5HpeH5YHfB1GWy/mJLzz5CphyCvuXUyNr1jOM31erk4O X-Received: by 2002:a17:907:2c72:b0:7a4:a4b4:9fcb with SMTP id ib18-20020a1709072c7200b007a4a4b49fcbmr773240ejc.403.1666984514994; Fri, 28 Oct 2022 12:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666984514; cv=none; d=google.com; s=arc-20160816; b=kKwfPRBvokKEs90dlFuDYKeqAAk2GyKoK6QOK7Y1rHY4aRWhcxVgtxCvKsp8ZsZ71l Nw7E8nT3qsbnd3x0yAHUAupX01DUaeQ0smiZ0v3utvyd4w+cVDn2iOMNiu7zbs6x19Rj 2dS6ry+FspYHKwc7kK5FW7jMR4vZd44HLQeIW1SOzR4UAgy3AMgAMFukBEfYvrAqLybh 3ZMqD3mGVuzaNzu+6+eAgF7WOurKuIXuL5xyK0tlT4LB2eYchCuE3VVb98LyCyU787pW FZvL413b4CSXYlNXEW8Rfua3nDmuf9zj6rXsazC/wocJBaCJKQsesFxmoLsJsq9A4pqB cPcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KPukQ/yCudN3mqPZzaxRUNn/wYyZYIm9PajEvh4bGro=; b=Cg5GuK9Wo4ZCCJPFMDg85S3Sg7nh5F8LmbxAK994jF6T8idCtTV+r0PuIDDAEVYw/2 eZWDmRKUdBgGvD4qSXAM/q8yU4ykF0D61e5/DILXAA/YMEL3f2xtJg3sNMa/cja1RUHE hyB0wCV8IqDo6DzXboPHf7PYl4XBvne6tn8el0duyPE8W1/RGGhREHJd6T9N9Yd7mvR1 c3f8i8sJwibfA+jdnSrlMoYm/uq+rYKIn/DsuiYCyHC/dpR5J2dNFZxORa4ipmr0tzxZ RED+k6cLzDdf77KqfzbHzmaWFqmrSBdSl1v2dJYrKwIL9tRKaNttQcFm5sxjqqmnXa1d aVJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lFTIh99o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q29-20020a50cc9d000000b00461b0b4f1afsi4535999edi.288.2022.10.28.12.14.51; Fri, 28 Oct 2022 12:15:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lFTIh99o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbiJ1TMw (ORCPT + 99 others); Fri, 28 Oct 2022 15:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbiJ1TMu (ORCPT ); Fri, 28 Oct 2022 15:12:50 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EDE422BC86 for ; Fri, 28 Oct 2022 12:12:49 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id f27so15200487eje.1 for ; Fri, 28 Oct 2022 12:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KPukQ/yCudN3mqPZzaxRUNn/wYyZYIm9PajEvh4bGro=; b=lFTIh99owmh/k1Uys/CzuTK6ZozjQkmrkSRPYw/izZPPV1+ekj/xUZq+xdZIuzBSEi Hu2MNhvE7/5GWe4M8T1ALVbA94OsV/nyapNTmItil0ZsWAVMW/J1VoNCQ0ecUo62zGVe bVJb/7j6Y2x7lIr0mbOeB1HEYozSsBjYy+TsN12tYb4CciaQgrovy2v1b9ko7ngZ78Us D5Be1E/jXuXPzcUlN8p2PDqXjp7m0sHYU7zrIWZX/sEk0LA1PBInO9VeUD7dojL8YN4x WzeLw1IDjKaLdGPuqIh9RcDlMiPGdtrqOCfLZ5N4sPFu2Ky0NG7BCx3gq/ENFOtgAuy4 /cYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KPukQ/yCudN3mqPZzaxRUNn/wYyZYIm9PajEvh4bGro=; b=XYkIEQXOVCSh4ZJpY/N5qW5Ybi4aa6rw755BV9h+eRJdYPrtNLR+iE7T4D/Y+R0Fwc 4yWaXjKgYIajxI/DJK0Wh/wO5JR9ZH1iPFl1aJ2G+v5LeZV7JHK78WJqnwkZfp2aHL8K xm8jlIWgi7waeM/CvEa+LKlBGp/QCfFZyBuvBcNwsxlXgio6ylJSb5iMXNFH0o5v2UNG EzHnBiqz67wRJZHgeWQFa0GB39QWaTDubfGWpQqh3MQGDP7apowgfnqbp7RnS/7/2W1K vAs7Zowt6RTLNmOnZXYLrQL/RQtjDhUxOFXifRAVSGPy9LJIWKPTnlrhabtTEdHawaJO 4cqQ== X-Gm-Message-State: ACrzQf2s0B5iogBVEjuRiMPqWoB9fa0qc/akt2flBmRXHt1OSqylDfrs s2aAA3mUcH37POgY68OS0ES+RQ== X-Received: by 2002:a17:907:7fac:b0:7a1:cace:1352 with SMTP id qk44-20020a1709077fac00b007a1cace1352mr804100ejc.6.1666984367966; Fri, 28 Oct 2022 12:12:47 -0700 (PDT) Received: from localhost (cgw.msart-bajzova4.ke.cust.o2bs.sk. [90.176.4.227]) by smtp.gmail.com with ESMTPSA id f1-20020a05640214c100b004623028c594sm3105183edx.49.2022.10.28.12.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 12:12:47 -0700 (PDT) From: Sam Protsenko To: Marek Szyprowski , Krzysztof Kozlowski Cc: Joerg Roedel , Will Deacon , Robin Murphy , Sumit Semwal , Alim Akhtar , Janghyuck Kim , Cho KyongHo , Daniel Mentz , David Virag , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/4] iommu: Export iommu_group_default_domain() API Date: Fri, 28 Oct 2022 21:12:40 +0200 Message-Id: <20221028191243.31721-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028191243.31721-1-semen.protsenko@linaro.org> References: <20221028191243.31721-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747959954559721776?= X-GMAIL-MSGID: =?utf-8?q?1747959954559721776?= iommu_group_default_domain() may be needed for module users. E.g. exynos-iommu driver is using it right now, and it's going to be converted to a module soon. Signed-off-by: Sam Protsenko --- drivers/iommu/iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 65a3b3d886dc..257143116185 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1650,6 +1650,7 @@ struct iommu_domain *iommu_group_default_domain(struct iommu_group *group) { return group->default_domain; } +EXPORT_SYMBOL_GPL(iommu_group_default_domain); static int probe_iommu_group(struct device *dev, void *data) { From patchwork Fri Oct 28 19:12:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp998800wru; Fri, 28 Oct 2022 12:15:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OagLTlL5Ww/5DHQF2RBDuD69nSBFmR81mAAmhj5rU1jRNVvIegjykfu3acdRekOZ/5nnn X-Received: by 2002:a17:907:86a1:b0:7ac:c5c3:9c80 with SMTP id qa33-20020a17090786a100b007acc5c39c80mr798986ejc.37.1666984515412; Fri, 28 Oct 2022 12:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666984515; cv=none; d=google.com; s=arc-20160816; b=zxUlspfJhbFO3W0e3GrT9QP2vSOAFFZoiUCbC918pUGDL+gzYsA5SDQJhfljjFp/Dk kC3puxwWD4AIgIfcD+2zs28+lLEa8iPWGM4b/hqaTCAJLK2yz955aG1YgkEDQ4TkHQip hW/lnJGYDGlC6vSlXPtxK5Lofoja2MFB9BerlkAD62fIEvtPccx6zmDH2YDIEo1ObNiv BxRPX/8zta8lMUx5w7RCz6euABJRr3k0XBtqcnNTKe8+Xownat7FQ2McF0XsfSZYpppF vsM7P0LjUjxF4zxb4oQeFjyhNHONe7IxwWB4IDFFOVoNT5hA94wzPr8E2oZvEIq5xsfH vKXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qUVwjtsAbEyzghccJECNwNsjlSoqmLTE2vHEiHldKUM=; b=q4D8c5czxhgsCePpkZ2VTxCO1/e791eNL/A4nEzA61xUwmnFUdenETZnPe3C4LHXUI x/J20SJAFCLm5NHcDkbc1eXG3A8UM25dbMgu0Pr88Pt6511dZRmNaD2NB9M7qgHRyS2D wJ2oKQxfevPUnV6h7/3ijQ/5ynboSfjIaoHyJJtvhykpL/72Ry8M2uOouPFm+baj1HSg bhgBU4HTcIJ0x0JXNRwSbrO/sfVqMly4W7gs0YrQRiwQBt8yNabw8XLpr6YyyRFQfuz2 oIGaNA/IJ+YgSqLs8IVlUXFV0KnmHdezly9Nu/2THqyaTzvuKIW5Yl8kg9Y3bdgdFShL da5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CkF81J/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v12-20020a50d08c000000b0046196240a07si4655503edd.262.2022.10.28.12.14.51; Fri, 28 Oct 2022 12:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CkF81J/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbiJ1TM6 (ORCPT + 99 others); Fri, 28 Oct 2022 15:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbiJ1TMw (ORCPT ); Fri, 28 Oct 2022 15:12:52 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A86236412 for ; Fri, 28 Oct 2022 12:12:51 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id i21so9211163edj.10 for ; Fri, 28 Oct 2022 12:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qUVwjtsAbEyzghccJECNwNsjlSoqmLTE2vHEiHldKUM=; b=CkF81J/bLhvEkbgXDZGNJrKhZjbpw+En5vy4szWyGlma2xmTKHj5xj9sZzF5Q8OWsc X/636m+maiTax3O8F/vnzePPJ+ep/UPQtYyXQRhxy6oRL6BaETpoXRxf1ljWNYZh6CFK 2wAcy6JjIS5d4JaN4blaIfzXY3ksGwPhPrE44iAXEbyBqBdiN7EXrHJE2AoMGpw++KaB ATi151tirBbCWy7f+OYD6hoPFbYlqeZBf02NlIlvuyWBxXIZXdrJzn/df1+qIyPZGP8+ pgMCUhO/un3a41nf6CmoyGdHEpDTI6gAQY9WE+vGWvxYZs1bZScdTCWZPL4EIgdetta/ kW3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qUVwjtsAbEyzghccJECNwNsjlSoqmLTE2vHEiHldKUM=; b=KspzyQCycXMTVMF09nOTtZWfE2FIBqCS+w7N+5QX9D752pl5cJEBVhxPfZafncPDb3 +Sent+7GHSqwmVcdPq8jLucFwEyly+SmrDKTpEbUY8KE4Wje8q+wNoav0ZBfhz+YN2Ke 5XxKUPRiWvha5n/r56On+nXnazI4Q3/XKC4OUPJnnpyX4y3YKOYrw/cQGnPuaTZ/WS8N 0incKRX+vj6Ptns/GAGbUyTVND1UhDbJoZUIj9rCxtZ5FL0mBpHZLo4XCZDxLFbrnKD2 JtYgDUoARIfzl1XijmZXJSHYWTV8J4mkft0wmN/GZ2xoNvR1+W8TMo+YrkM2CPgUVEgL HrzQ== X-Gm-Message-State: ACrzQf1I37uC44+3AVZOnPSlMSdMihFEjzd9eqRoJ5qUcsn1fhScbHp0 T5v1DozAZUuViIMO+ZtgdC7KSw== X-Received: by 2002:a05:6402:847:b0:453:943b:bf4 with SMTP id b7-20020a056402084700b00453943b0bf4mr886550edz.301.1666984369908; Fri, 28 Oct 2022 12:12:49 -0700 (PDT) Received: from localhost (cgw.msart-bajzova4.ke.cust.o2bs.sk. [90.176.4.227]) by smtp.gmail.com with ESMTPSA id ky20-20020a170907779400b00770812e2394sm2512302ejc.160.2022.10.28.12.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 12:12:49 -0700 (PDT) From: Sam Protsenko To: Marek Szyprowski , Krzysztof Kozlowski Cc: Joerg Roedel , Will Deacon , Robin Murphy , Sumit Semwal , Alim Akhtar , Janghyuck Kim , Cho KyongHo , Daniel Mentz , David Virag , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 2/4] iommu/exynos: Fix retval on getting clocks in probe Date: Fri, 28 Oct 2022 21:12:41 +0200 Message-Id: <20221028191243.31721-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028191243.31721-1-semen.protsenko@linaro.org> References: <20221028191243.31721-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747959955111445521?= X-GMAIL-MSGID: =?utf-8?q?1747959955111445521?= checkpatch reports next warning for clock getting code in probe function: WARNING: ENOSYS means 'invalid syscall nr' and nothing else Replace it with -ENOINT to make checkpatch happy. Signed-off-by: Sam Protsenko --- drivers/iommu/exynos-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 45fd4850bacb..0d150b383d04 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -689,7 +689,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) if (!data->clk && (!data->aclk || !data->pclk)) { dev_err(dev, "Failed to get device clock(s)!\n"); - return -ENOSYS; + return -ENOENT; } data->clk_master = devm_clk_get(dev, "master"); From patchwork Fri Oct 28 19:12:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp999819wru; Fri, 28 Oct 2022 12:18:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/XIoGS3i6T5CZDPw4kKIftObjdMcJlH+rSozXNkdVo1ahfxc7cOyvTr6Gwef0E1weIVBc X-Received: by 2002:a17:906:8a47:b0:7a5:8160:19a6 with SMTP id gx7-20020a1709068a4700b007a5816019a6mr764578ejc.477.1666984680175; Fri, 28 Oct 2022 12:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666984680; cv=none; d=google.com; s=arc-20160816; b=teqjS8fqnHF0RPxwANSFj58hXWtY1JFQhlm361SsJmBLF32FGxsizUIWAonRmkF2zf RvWaY2ZdmAUP7Uvu9+5KHcYcKTtdzPoMrgHjR0+e7Sq0ksLRe82CcyBfQNwuR+MoXPdo FIYBVbquEKg3rz6MIGHchwZZ7lidL7+qSUOE3XC5sGBF7vkz3LSXulb1orYZCISGTg/i P9jVXxQuE6SmdBTKYTRROaNtnKima0mKSrQC8xwg1t6tEJn2LcP5mn74lljZIFtnp0Uu t+EOAiU6xOnE+fJORWLXeHnqHpb9dS3bQXyjMTG7P19nwwuLRGlh4fu9yTwcHXwZUGoo j4NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ce4G8W5n1Lw9GJ2OPzfRvhL8Ar7JfIK4yfZO67gLs8o=; b=qzUaJP1UH+V9w5IHYfPFr1kSMXl7otscpAkWPEEw1vUJWMbdfwzXzdVxTSQ+x6ZfuO RLS9Nk7Fd/EsReT9e9MH+49R8KmF+DXejKuf9h0ukF+/dM9P4VqVHBL60j9TdELlxLOP jNi+Cwae8+Dqw9d7oV1Pf25XgPSF6yTMaSBLEvN8CqSFWOJz/5e7pjhiyBPGEjDm2kRO GhY+Og/RrQ+9G/1q0hcan2ooNrdCj17eGbZO4cSjBWJp1A8/aYae44tG/HenM7N3kfNX pQsnE73jHfCN63NjjENL0ubUF8o08ay/ZI7UZUfU+KJ1kFh+vXCyKC4/xOsWXc7MJyRo eXAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=USP77o4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne7-20020a1709077b8700b0078e1e77f443si669592ejc.418.2022.10.28.12.17.35; Fri, 28 Oct 2022 12:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=USP77o4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbiJ1TND (ORCPT + 99 others); Fri, 28 Oct 2022 15:13:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbiJ1TM4 (ORCPT ); Fri, 28 Oct 2022 15:12:56 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3645A2339A9 for ; Fri, 28 Oct 2022 12:12:53 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id z18so4225732edb.9 for ; Fri, 28 Oct 2022 12:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ce4G8W5n1Lw9GJ2OPzfRvhL8Ar7JfIK4yfZO67gLs8o=; b=USP77o4Kj2PXkea5iju4USuaykmQfPyYjmvznDQakbS8TtPG6SAAgBqdEnSwNoevF2 9/MX/qCCFNYzLoU8S55oAFU4v3FXisMLnhwxhZE34gQSNi7Nh5ffwJNiNHW+ZGnIwjdt 5aVCxJdIEFHlacrIJJ0tIfaoOAbetXlbZmi9sRAWGTjVXLt7Az796qbPtToLaUDVkK0O uRUMhOePJ0xuK4nt1CshdgJXZHiYpRUWgiAI1FtQw+k/U4IGZD92SPs+gtu30naDO3hJ vk/pVENy7WDuEPyvq5+PPbKqwzI+wI0tCiZ76IYjhi46RsCLGdKsqCyoOTDVEdSPN7Sa HeAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ce4G8W5n1Lw9GJ2OPzfRvhL8Ar7JfIK4yfZO67gLs8o=; b=nEcKT7hu2cR+7Dg6kxeOvMMhhI08Zu0WejndkfUnLmVQOuGl3rdkMN24PZvuP05D73 cyzzavuW7rhHoIPcSOF2PvGBEmXmQrS13ouVcUDJ71OAAg3DBui9ILRhEQUUdvGgQ9Vp HuoAVOjta1R9lQl04GiuRnJ/sV0KSLabG0VH9/fZFnKHu79dLAS7FdIWAPzHcGGW6sEq RhBJvhdC0z/MJn5IJI9ZbeJqYSqwDc77klRHzzq+gQumA/NDOlasKXmk2IyPrC/ej1t0 VBq6qi9TEJSAbUAkQy4duGghycXC0XEvzpOLNe3M1Qx0XKVMlLyicM5Z9pZj1JHd9kdj RQCA== X-Gm-Message-State: ACrzQf3rjnUAFDGbvd7Xuc+SAYxNY+e7hHQ/8ho7CJRMdc8dNo9qqbNi hZ0lsUYhjQqb1mIig2gu0zMwyg== X-Received: by 2002:a05:6402:448c:b0:457:52eb:b57e with SMTP id er12-20020a056402448c00b0045752ebb57emr948141edb.178.1666984371738; Fri, 28 Oct 2022 12:12:51 -0700 (PDT) Received: from localhost (cgw.msart-bajzova4.ke.cust.o2bs.sk. [90.176.4.227]) by smtp.gmail.com with ESMTPSA id fx1-20020a170906b74100b007a7f9b6318asm2569764ejb.50.2022.10.28.12.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 12:12:51 -0700 (PDT) From: Sam Protsenko To: Marek Szyprowski , Krzysztof Kozlowski Cc: Joerg Roedel , Will Deacon , Robin Murphy , Sumit Semwal , Alim Akhtar , Janghyuck Kim , Cho KyongHo , Daniel Mentz , David Virag , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 3/4] iommu/exynos: Modularize the driver Date: Fri, 28 Oct 2022 21:12:42 +0200 Message-Id: <20221028191243.31721-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028191243.31721-1-semen.protsenko@linaro.org> References: <20221028191243.31721-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747960127988103721?= X-GMAIL-MSGID: =?utf-8?q?1747960127988103721?= Rework the driver so it can be built as a loadable module. That can be useful as not all ARM64 platforms need it. And that's ok for it to be a module because it's not a critical driver (platform can work when it's disabled). Also add the shutdown driver method, while at it. That was inspired by other IOMMU drivers, and can be useful e.g. for performing a kexec. See commit 1a4e90f25b2c ("iommu/rockchip: Perform a reset on shutdown") for example. Remove method and module exit function are not implemented, as the removal of IOMMUs cannot be done reliably. As Robin Murphy mentioned in [1]: ...it's better not to even pretend that removing an IOMMU's driver while other drivers are using it (usually via DMA ops without even realising) is going to have anything other than catastrophic results. [1] https://lore.kernel.org/lkml/20220702213724.3949-2-semen.protsenko@linaro.org/T/#md7e1e3f5b2c9e7fa5bc28fe33e818b6aa4a7237c Signed-off-by: Sam Protsenko --- drivers/iommu/Kconfig | 2 +- drivers/iommu/exynos-iommu.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index dc5f7a156ff5..6f7055606679 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -259,7 +259,7 @@ config TEGRA_IOMMU_SMMU SoCs (Tegra30 up to Tegra210). config EXYNOS_IOMMU - bool "Exynos IOMMU Support" + tristate "Exynos IOMMU Support" depends on ARCH_EXYNOS || COMPILE_TEST depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes select IOMMU_API diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 0d150b383d04..57492db877e2 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -752,6 +753,16 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) return ret; } +static void exynos_sysmmu_shutdown(struct platform_device *pdev) +{ + struct sysmmu_drvdata *data = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + int irq = platform_get_irq(pdev, 0); + + devm_free_irq(dev, irq, data); + pm_runtime_force_suspend(dev); +} + static int __maybe_unused exynos_sysmmu_suspend(struct device *dev) { struct sysmmu_drvdata *data = dev_get_drvdata(dev); @@ -799,8 +810,9 @@ static const struct of_device_id sysmmu_of_match[] = { { }, }; -static struct platform_driver exynos_sysmmu_driver __refdata = { +static struct platform_driver exynos_sysmmu_driver = { .probe = exynos_sysmmu_probe, + .shutdown = exynos_sysmmu_shutdown, .driver = { .name = "exynos-sysmmu", .of_match_table = sysmmu_of_match, @@ -1404,6 +1416,7 @@ static const struct iommu_ops exynos_iommu_ops = { .release_device = exynos_iommu_release_device, .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, .of_xlate = exynos_iommu_of_xlate, + .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = exynos_iommu_attach_device, .detach_dev = exynos_iommu_detach_device, @@ -1454,3 +1467,6 @@ static int __init exynos_iommu_init(void) return ret; } core_initcall(exynos_iommu_init); + +MODULE_DESCRIPTION("IOMMU driver for Exynos SoCs"); +MODULE_LICENSE("GPL"); From patchwork Fri Oct 28 19:12:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp999821wru; Fri, 28 Oct 2022 12:18:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+30v2SPK55ExWKjtBs3xqNLZZWqZUQ4Lq06qA/JVab+NWbrXFOKtIVAKrFQmXboGsC9ht X-Received: by 2002:a05:6402:2b8d:b0:43a:5410:a9fc with SMTP id fj13-20020a0564022b8d00b0043a5410a9fcmr927998edb.99.1666984680315; Fri, 28 Oct 2022 12:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666984680; cv=none; d=google.com; s=arc-20160816; b=FqOk+NnZb7ruS1o9YNJZvgKJUEXW8ctse9uM3NeaHABi9YoSHq0TDPL5UmVp3DGE2I cvBOZJ/vszcr614mZWvlJ/0YR4S1DW/sCZXNGGiQO5Y0fMzkcYrFoQXYd4jviOBR5r32 FDcfzqpXSSsgKIle6IMMnSuqJtMa5B3j+u8mp/AEQ1MSh7Z2PNp6+g+31BeRY8ARuXjX OZXhc6fgzZ7Nf/2FKDiXWslSXvyhzzs4oOMpnNp7Ggm9S4mWd7hiI9dgiUzkoJTNTn0L 2XzKUkszmLCtNklIvDt0vEJ35XrCck6sQA4vgF4sK0rsvuA5X4O4B5h040mMGWBZwGUD EXIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=deMSZFUhvNmRdIfYG/C3RyBQaijBl5jkuXDMUwHOSfU=; b=wJcrbDheaLh9CSzS4rt7Bp8htRJNYqqCJnseEW+RHGpgee+4CUwpvl73hWsB+/AIA5 7o4uGFIfcPz9/4aZtmFg8G3PSTdBEZg0+lJNyBZ01iW3ynZMj1WMr/Vy12/Rz/cgOMIX s0lVbglWkdvdxTES5kA7o9+3Ke7ZPXmFlXl15nBxC1d2dH8+AV6NA8nppLWdevyup22K SXcWXBUG4cIRvSRsRu9JvJMRt96kYavNW+WQ3zNgh9UHSwBy8S54XekrDWX3ONqgMOci WQdEoD+4Rpj004U4taWNYwGLvJDnHeGdMSfL2iKvCj3xYpnpTID1t9TY80rhRBdekNHo 5h1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ITbfN5eF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq34-20020a1709073f2200b00787c0e9818csi1098589ejc.568.2022.10.28.12.17.36; Fri, 28 Oct 2022 12:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ITbfN5eF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbiJ1TNJ (ORCPT + 99 others); Fri, 28 Oct 2022 15:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbiJ1TM7 (ORCPT ); Fri, 28 Oct 2022 15:12:59 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2630623923E for ; Fri, 28 Oct 2022 12:12:55 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id a67so9192535edf.12 for ; Fri, 28 Oct 2022 12:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=deMSZFUhvNmRdIfYG/C3RyBQaijBl5jkuXDMUwHOSfU=; b=ITbfN5eFzSlarpfm6uqKJEMWgyggUQN+lNoa9zCXhXHPcYfNQJ2H4hx+xTBeYE/llo EdEPh1b27nTt6KvLrJ/pXVkD/pE6Yz54gTQr4bhyvozC0Npne1qN92uZnXET0cx4JVOV OIf32eGS4HV6oBvFTlBRqHsc1vSKR4Yndk7FovaFMDVlH9jKv407c77vFEGoKLKx3Lpx 00aMv/M7su9Eomf1x27yzLxJ55SMvdXcI4yW8UlWN/xobQg71hnNUCLuWRFSUVrw6eCy XpaKyIlbOpZ7lYMhXVK8NXHed8YPZKN5BmVRib+GQqe8JN35zRS6UFEVsrCGmh/Hne4d RvzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=deMSZFUhvNmRdIfYG/C3RyBQaijBl5jkuXDMUwHOSfU=; b=JuminPC/brhJoqvi24KqGiU4Ii6GFOYdJQ1DO3AYqiLv7QFNeCjeu5TFo403zuypaw VsnHRVIT0V1nIFy4g7qpSvfBL0LPI5WgbMWbx5DnIe5EKURzpSKitSZnIb6r6v1DdIn0 3LmOmZUTYbzaq3sOWAf4VVwFHEGGEcxnAKxzEc28F9DJ7xKL8AFVu2wKSVKCsaOIZ8tB MlQZDhT5YTqQ9sVoUnXjHXHsmGgeqjcs02eghWTC/m0pOx87snK8Ixc/IB6lM8WUNpr/ fBB8ICN1AnJ9mHiLlIje9h6zavTNzoM/5DWW8/x+ANUvh9JJeIZpQyojXtuhaFAkk8pX carg== X-Gm-Message-State: ACrzQf0Xo9PKfuyXotl5JM/APN6FezJHM0N+jqBRdz9ouUWCuQQQVHk6 1bjP9m7VyQx+TlkNvvlkOgBXXw== X-Received: by 2002:a05:6402:430a:b0:462:2e05:30b5 with SMTP id m10-20020a056402430a00b004622e0530b5mr920629edc.246.1666984373603; Fri, 28 Oct 2022 12:12:53 -0700 (PDT) Received: from localhost (cgw.msart-bajzova4.ke.cust.o2bs.sk. [90.176.4.227]) by smtp.gmail.com with ESMTPSA id kz2-20020a17090777c200b0079dbf06d558sm2487737ejc.184.2022.10.28.12.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 12:12:53 -0700 (PDT) From: Sam Protsenko To: Marek Szyprowski , Krzysztof Kozlowski Cc: Joerg Roedel , Will Deacon , Robin Murphy , Sumit Semwal , Alim Akhtar , Janghyuck Kim , Cho KyongHo , Daniel Mentz , David Virag , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 4/4] iommu/exynos: Rearrange the platform driver code Date: Fri, 28 Oct 2022 21:12:43 +0200 Message-Id: <20221028191243.31721-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028191243.31721-1-semen.protsenko@linaro.org> References: <20221028191243.31721-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747960127815920596?= X-GMAIL-MSGID: =?utf-8?q?1747960127815920596?= Move the platform_driver code to the bottom of the driver, as it's a canonical form for that. No functional change. Signed-off-by: Sam Protsenko --- drivers/iommu/exynos-iommu.c | 359 +++++++++++++++++------------------ 1 file changed, 179 insertions(+), 180 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 57492db877e2..af1c8ddcf5e4 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -641,186 +641,6 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data, spin_unlock_irqrestore(&data->lock, flags); } -static const struct iommu_ops exynos_iommu_ops; - -static int exynos_sysmmu_probe(struct platform_device *pdev) -{ - int irq, ret; - struct device *dev = &pdev->dev; - struct sysmmu_drvdata *data; - struct resource *res; - - data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - data->sfrbase = devm_ioremap_resource(dev, res); - if (IS_ERR(data->sfrbase)) - return PTR_ERR(data->sfrbase); - - irq = platform_get_irq(pdev, 0); - if (irq <= 0) - return irq; - - ret = devm_request_irq(dev, irq, exynos_sysmmu_irq, 0, - dev_name(dev), data); - if (ret) { - dev_err(dev, "Unabled to register handler of irq %d\n", irq); - return ret; - } - - data->clk = devm_clk_get(dev, "sysmmu"); - if (PTR_ERR(data->clk) == -ENOENT) - data->clk = NULL; - else if (IS_ERR(data->clk)) - return PTR_ERR(data->clk); - - data->aclk = devm_clk_get(dev, "aclk"); - if (PTR_ERR(data->aclk) == -ENOENT) - data->aclk = NULL; - else if (IS_ERR(data->aclk)) - return PTR_ERR(data->aclk); - - data->pclk = devm_clk_get(dev, "pclk"); - if (PTR_ERR(data->pclk) == -ENOENT) - data->pclk = NULL; - else if (IS_ERR(data->pclk)) - return PTR_ERR(data->pclk); - - if (!data->clk && (!data->aclk || !data->pclk)) { - dev_err(dev, "Failed to get device clock(s)!\n"); - return -ENOENT; - } - - data->clk_master = devm_clk_get(dev, "master"); - if (PTR_ERR(data->clk_master) == -ENOENT) - data->clk_master = NULL; - else if (IS_ERR(data->clk_master)) - return PTR_ERR(data->clk_master); - - data->sysmmu = dev; - spin_lock_init(&data->lock); - - __sysmmu_get_version(data); - - ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL, - dev_name(data->sysmmu)); - if (ret) - return ret; - - ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev); - if (ret) - goto err_iommu_register; - - platform_set_drvdata(pdev, data); - - if (PG_ENT_SHIFT < 0) { - if (MMU_MAJ_VER(data->version) < 5) { - PG_ENT_SHIFT = SYSMMU_PG_ENT_SHIFT; - LV1_PROT = SYSMMU_LV1_PROT; - LV2_PROT = SYSMMU_LV2_PROT; - } else { - PG_ENT_SHIFT = SYSMMU_V5_PG_ENT_SHIFT; - LV1_PROT = SYSMMU_V5_LV1_PROT; - LV2_PROT = SYSMMU_V5_LV2_PROT; - } - } - - if (MMU_MAJ_VER(data->version) >= 5) { - ret = dma_set_mask(dev, DMA_BIT_MASK(36)); - if (ret) { - dev_err(dev, "Unable to set DMA mask: %d\n", ret); - goto err_dma_set_mask; - } - } - - /* - * use the first registered sysmmu device for performing - * dma mapping operations on iommu page tables (cpu cache flush) - */ - if (!dma_dev) - dma_dev = &pdev->dev; - - pm_runtime_enable(dev); - - return 0; - -err_dma_set_mask: - iommu_device_unregister(&data->iommu); -err_iommu_register: - iommu_device_sysfs_remove(&data->iommu); - return ret; -} - -static void exynos_sysmmu_shutdown(struct platform_device *pdev) -{ - struct sysmmu_drvdata *data = platform_get_drvdata(pdev); - struct device *dev = &pdev->dev; - int irq = platform_get_irq(pdev, 0); - - devm_free_irq(dev, irq, data); - pm_runtime_force_suspend(dev); -} - -static int __maybe_unused exynos_sysmmu_suspend(struct device *dev) -{ - struct sysmmu_drvdata *data = dev_get_drvdata(dev); - struct device *master = data->master; - - if (master) { - struct exynos_iommu_owner *owner = dev_iommu_priv_get(master); - - mutex_lock(&owner->rpm_lock); - if (data->domain) { - dev_dbg(data->sysmmu, "saving state\n"); - __sysmmu_disable(data); - } - mutex_unlock(&owner->rpm_lock); - } - return 0; -} - -static int __maybe_unused exynos_sysmmu_resume(struct device *dev) -{ - struct sysmmu_drvdata *data = dev_get_drvdata(dev); - struct device *master = data->master; - - if (master) { - struct exynos_iommu_owner *owner = dev_iommu_priv_get(master); - - mutex_lock(&owner->rpm_lock); - if (data->domain) { - dev_dbg(data->sysmmu, "restoring state\n"); - __sysmmu_enable(data); - } - mutex_unlock(&owner->rpm_lock); - } - return 0; -} - -static const struct dev_pm_ops sysmmu_pm_ops = { - SET_RUNTIME_PM_OPS(exynos_sysmmu_suspend, exynos_sysmmu_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) -}; - -static const struct of_device_id sysmmu_of_match[] = { - { .compatible = "samsung,exynos-sysmmu", }, - { }, -}; - -static struct platform_driver exynos_sysmmu_driver = { - .probe = exynos_sysmmu_probe, - .shutdown = exynos_sysmmu_shutdown, - .driver = { - .name = "exynos-sysmmu", - .of_match_table = sysmmu_of_match, - .pm = &sysmmu_pm_ops, - .suppress_bind_attrs = true, - } -}; - static inline void exynos_iommu_set_pte(sysmmu_pte_t *ent, sysmmu_pte_t val) { dma_sync_single_for_cpu(dma_dev, virt_to_phys(ent), sizeof(*ent), @@ -1427,6 +1247,184 @@ static const struct iommu_ops exynos_iommu_ops = { } }; +static int exynos_sysmmu_probe(struct platform_device *pdev) +{ + int irq, ret; + struct device *dev = &pdev->dev; + struct sysmmu_drvdata *data; + struct resource *res; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + data->sfrbase = devm_ioremap_resource(dev, res); + if (IS_ERR(data->sfrbase)) + return PTR_ERR(data->sfrbase); + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) + return irq; + + ret = devm_request_irq(dev, irq, exynos_sysmmu_irq, 0, + dev_name(dev), data); + if (ret) { + dev_err(dev, "Unabled to register handler of irq %d\n", irq); + return ret; + } + + data->clk = devm_clk_get(dev, "sysmmu"); + if (PTR_ERR(data->clk) == -ENOENT) + data->clk = NULL; + else if (IS_ERR(data->clk)) + return PTR_ERR(data->clk); + + data->aclk = devm_clk_get(dev, "aclk"); + if (PTR_ERR(data->aclk) == -ENOENT) + data->aclk = NULL; + else if (IS_ERR(data->aclk)) + return PTR_ERR(data->aclk); + + data->pclk = devm_clk_get(dev, "pclk"); + if (PTR_ERR(data->pclk) == -ENOENT) + data->pclk = NULL; + else if (IS_ERR(data->pclk)) + return PTR_ERR(data->pclk); + + if (!data->clk && (!data->aclk || !data->pclk)) { + dev_err(dev, "Failed to get device clock(s)!\n"); + return -ENOENT; + } + + data->clk_master = devm_clk_get(dev, "master"); + if (PTR_ERR(data->clk_master) == -ENOENT) + data->clk_master = NULL; + else if (IS_ERR(data->clk_master)) + return PTR_ERR(data->clk_master); + + data->sysmmu = dev; + spin_lock_init(&data->lock); + + __sysmmu_get_version(data); + + ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL, + dev_name(data->sysmmu)); + if (ret) + return ret; + + ret = iommu_device_register(&data->iommu, &exynos_iommu_ops, dev); + if (ret) + goto err_iommu_register; + + platform_set_drvdata(pdev, data); + + if (PG_ENT_SHIFT < 0) { + if (MMU_MAJ_VER(data->version) < 5) { + PG_ENT_SHIFT = SYSMMU_PG_ENT_SHIFT; + LV1_PROT = SYSMMU_LV1_PROT; + LV2_PROT = SYSMMU_LV2_PROT; + } else { + PG_ENT_SHIFT = SYSMMU_V5_PG_ENT_SHIFT; + LV1_PROT = SYSMMU_V5_LV1_PROT; + LV2_PROT = SYSMMU_V5_LV2_PROT; + } + } + + if (MMU_MAJ_VER(data->version) >= 5) { + ret = dma_set_mask(dev, DMA_BIT_MASK(36)); + if (ret) { + dev_err(dev, "Unable to set DMA mask: %d\n", ret); + goto err_dma_set_mask; + } + } + + /* + * use the first registered sysmmu device for performing + * dma mapping operations on iommu page tables (cpu cache flush) + */ + if (!dma_dev) + dma_dev = &pdev->dev; + + pm_runtime_enable(dev); + + return 0; + +err_dma_set_mask: + iommu_device_unregister(&data->iommu); +err_iommu_register: + iommu_device_sysfs_remove(&data->iommu); + return ret; +} + +static void exynos_sysmmu_shutdown(struct platform_device *pdev) +{ + struct sysmmu_drvdata *data = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + int irq = platform_get_irq(pdev, 0); + + devm_free_irq(dev, irq, data); + pm_runtime_force_suspend(dev); +} + +static int __maybe_unused exynos_sysmmu_suspend(struct device *dev) +{ + struct sysmmu_drvdata *data = dev_get_drvdata(dev); + struct device *master = data->master; + + if (master) { + struct exynos_iommu_owner *owner = dev_iommu_priv_get(master); + + mutex_lock(&owner->rpm_lock); + if (data->domain) { + dev_dbg(data->sysmmu, "saving state\n"); + __sysmmu_disable(data); + } + mutex_unlock(&owner->rpm_lock); + } + return 0; +} + +static int __maybe_unused exynos_sysmmu_resume(struct device *dev) +{ + struct sysmmu_drvdata *data = dev_get_drvdata(dev); + struct device *master = data->master; + + if (master) { + struct exynos_iommu_owner *owner = dev_iommu_priv_get(master); + + mutex_lock(&owner->rpm_lock); + if (data->domain) { + dev_dbg(data->sysmmu, "restoring state\n"); + __sysmmu_enable(data); + } + mutex_unlock(&owner->rpm_lock); + } + return 0; +} + +static const struct dev_pm_ops sysmmu_pm_ops = { + SET_RUNTIME_PM_OPS(exynos_sysmmu_suspend, exynos_sysmmu_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +}; + +static const struct of_device_id sysmmu_of_match[] = { + { .compatible = "samsung,exynos-sysmmu", }, + { }, +}; + +static struct platform_driver exynos_sysmmu_driver = { + .probe = exynos_sysmmu_probe, + .shutdown = exynos_sysmmu_shutdown, + .driver = { + .name = "exynos-sysmmu", + .of_match_table = sysmmu_of_match, + .pm = &sysmmu_pm_ops, + .suppress_bind_attrs = true, + } +}; + static int __init exynos_iommu_init(void) { struct device_node *np; @@ -1460,6 +1458,7 @@ static int __init exynos_iommu_init(void) } return 0; + err_zero_lv2: platform_driver_unregister(&exynos_sysmmu_driver); err_reg_driver: