From patchwork Wed Apr 17 20:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13633821 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E03D3B1AC for ; Wed, 17 Apr 2024 20:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713384429; cv=none; b=Vs3lQ9wZC8rTBEjLk0aUoFqqy6byqwFqnrzdNnFKWR4NXfx+ZBSYO/rQFQ6pHH+3oH78RBQABCoXHUqd08YDDV0RZo+sez1BjjPhmDRGvAshAC/eA2tBCLegIZJ3t0CU/CPb0psXaD9QJ767lKPYCpi/ZWPNBhhFwpd6HOpvIr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713384429; c=relaxed/simple; bh=K0ao8Vo7sPBfbnwTda3s2I9W96Cl7inckQMbp1qX6wI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b216gee6/VcEf1qREQ10uRkFAeJhtZupc3LQzKBypqk8XHp7d2XWo76LUro65cSOFP9Qq2ju3WjRPo2ODfAFEBBIWMf/KTO/L1h8RoO62TYSBqgJ9+ZpYqYUWMMHe/m390AMHosvEt9Lh0hKctXo0hvSmXn2eaAB9qFwzCD0zkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=KTTx1rE/; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KTTx1rE/" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-518a3e0d2ecso57373e87.3 for ; Wed, 17 Apr 2024 13:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713384425; x=1713989225; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=D/wLorb8s/wxRn0nx2P3JnCqrMElCXyUmbwHbfSHp1A=; b=KTTx1rE/e0/MJ9ANl1oSARbwv8W7ncBoeGOJX7bNn12ZxzKuQRNcDekxBHw29w6cc9 YSvzksw11PSlkWLKe010gnfmXoiTNoy0pd9mvKlmb0IeTZVyGN/nnVYkcdGKHwho41on 4kh2fb2Ra8tQfS46BLOPAQOXVe9mT6OTaRKBJqWDP3XhmlK9ZImcE3uotU670nUb72EW CNZKM09h4ySvcSc/muU3IXDW8j1gQqLIM+waStnMb9I5lA/0dIu5LFzJQe8NzXD0xXcO g8a83vWH402yIyJ/igUeXrDzZFE2WjssOLqIbuVpTjZbQW6Vs8tWDjOFLJaYwRYX6Pt2 ld2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713384425; x=1713989225; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D/wLorb8s/wxRn0nx2P3JnCqrMElCXyUmbwHbfSHp1A=; b=aeGMhiwi7YwwgJmRa/X7HlLTbqeBNnNHHcM+oe8oWMpL9t02s2OIr/Pjh7zIh0cmHz fDr4Xfq0nh89+6X93G8vNR+NxhdXQf+MF+GS7SgGz4eCniEnfhrFe5NmLt+fhMiv2uk3 ZmFBm/XK16wAB5soQz3PcpWrJLTgP4dnRaa6k3UQa9AkN8lCBmmFJ8/28mfResuS1JvL vdp73QVcz9OhP3MpVQ4tuJbDSfFmxuJcyNzjJa8yEFI96hSiwdm/XgQAVMSqVO/DUXPn r4Vllw6pj523IDU3sl1yJyq8e/d4+VdOGlDVvBWve+tJmXX0BRjvzFXM/ETn+ZHY4uVA iBmQ== X-Forwarded-Encrypted: i=1; AJvYcCWikptIUtMxIYU4uGNVrncFyVQTmU+ZKGiBp5FIjdINMvtyC3/rv2S7lg5gLwXwiZ9dj0T1B5+HqAnI5D2n4vws0Z+MS1FKoSPnJBUVbg== X-Gm-Message-State: AOJu0Yw9KDAS4WSAuEeKnUKmhM71j5Qr2kMzy13ipSPMbMQ2ctwrrBEU kCKjGVjfBDZHmSOO5hNft0TFPdnpZfDQ0MQbowpeZRmqfwykgy+cs7E3gRW3HBw= X-Google-Smtp-Source: AGHT+IFhc+YiEEchmcEnwplLOB4LzpFRorv1csY8s/d98HoFZzUavjGEBrTgxsRrSSINY1ECFOPWKQ== X-Received: by 2002:a19:770b:0:b0:518:9ce1:a5bb with SMTP id s11-20020a19770b000000b005189ce1a5bbmr221524lfc.54.1713384425537; Wed, 17 Apr 2024 13:07:05 -0700 (PDT) Received: from [192.168.45.55] (078088045141.garwolin.vectranet.pl. [78.88.45.141]) by smtp.gmail.com with ESMTPSA id l1-20020a17090615c100b00a524e3f2f9esm6128057ejd.98.2024.04.17.13.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 13:07:04 -0700 (PDT) From: Konrad Dybcio Date: Wed, 17 Apr 2024 22:06:59 +0200 Subject: [PATCH 1/2] iommu/qcom: Remove useless forward definition Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240416-topic-qcom_iommu-v1-1-fabe55b3b7b3@linaro.org> References: <20240416-topic-qcom_iommu-v1-0-fabe55b3b7b3@linaro.org> In-Reply-To: <20240416-topic-qcom_iommu-v1-0-fabe55b3b7b3@linaro.org> To: Rob Clark , Will Deacon , Robin Murphy , Joerg Roedel Cc: iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stephan Gerhold , Marijn Suijten , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713384421; l=1236; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=K0ao8Vo7sPBfbnwTda3s2I9W96Cl7inckQMbp1qX6wI=; b=6cYUGa8Goag8a2aUNA1eqwMKeX2FK4TOEyCqJmO8C5udyr+6wz+22OMrZWc39n6z6JZ4MLaC1 WxHuDRgmVY8DzAUtW9uZqmUkiiUQkzrtSPCIaYsmHLZi8HP7Tni0oxk X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Simply move code around. Signed-off-by: Konrad Dybcio Reviewed-by: Bjorn Andersson --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index e079bb7a993e..3dca9293c509 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -41,7 +41,14 @@ enum qcom_iommu_clk { CLK_NUM, }; -struct qcom_iommu_ctx; +struct qcom_iommu_ctx { + struct device *dev; + void __iomem *base; + bool secure_init; + bool secured_ctx; + u8 asid; /* asid and ctx bank # are 1:1 */ + struct iommu_domain *domain; +}; struct qcom_iommu_dev { /* IOMMU core code handle */ @@ -54,15 +61,6 @@ struct qcom_iommu_dev { struct qcom_iommu_ctx *ctxs[]; /* indexed by asid */ }; -struct qcom_iommu_ctx { - struct device *dev; - void __iomem *base; - bool secure_init; - bool secured_ctx; - u8 asid; /* asid and ctx bank # are 1:1 */ - struct iommu_domain *domain; -}; - struct qcom_iommu_domain { struct io_pgtable_ops *pgtbl_ops; spinlock_t pgtbl_lock; From patchwork Wed Apr 17 20:07:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13633822 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 617343D54C for ; Wed, 17 Apr 2024 20:07:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713384431; cv=none; b=TVSwQfGjhoM8CKQlBVMDwQJFXZgKXJovH/8BGcdSq/C7/3Exv4j0bxtkG5iTCIO1vsaNNUoQ+30Wg5w6nBLw70RcumjuovLOm6LJoXSXP/eAmN/R5KBCyJdMbEf95F0b2ztTAsZ24zLPtaR7AcGY1Ht0C2UT3yugOhBxUMqMUE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713384431; c=relaxed/simple; bh=3mbMg2ivwWNTK3xsS4wYTiDYZ0KlaU3IbtBCWSlfYEw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FUm+8/vp3J7SgKW4TLBuGSZLkFsD3EtQJmIL02ctV0B4s+ZcAhgADeTbFPi6hkWbfdOwHlk8XdE74aLcNfjm35Sva/j96ZdSCitr5ADw+Rx5Lc55YkvUdrdz0QDcJtvTDt3QpPe0vbjIJEfOcJfrC17xpLzGf35tFBM9G7NqF1Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oDhNh59G; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oDhNh59G" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a5557e3ebcaso28314466b.1 for ; Wed, 17 Apr 2024 13:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713384428; x=1713989228; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=t9Kjw76bMPVOsbjzjb0d38GfEfCd3+VQVKqEmN50hoY=; b=oDhNh59G9haBJapsG7yKtWT+6abGBRxj6ibLg/dbbX5dngcNzjvMNoNCb2CyVs41D8 cxaKO68doWsXy9Mr1jSms845vXpBXORnvkadhn420KbX0ihRh3+ohoh423RvWvDYEmzP MF3eIDxx6KJZ3J3AL95KysEjbceqxsqMPyOZz/pH4j35lumSi6aCk/FUmunhMrzG4AQU khJ62GAGcG9YQ0CNREz9IVTEhHECUj9q0xnsxqQmUg85R+Pm03DOXeFgPxbMrtFKX4Zc KSCztb7ATzqf7Kzek389Oq6GHZR+ijjFT8jTnfmVbZ6w6Y7zGXizfzkWzE44CUWCIOAi X7jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713384428; x=1713989228; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t9Kjw76bMPVOsbjzjb0d38GfEfCd3+VQVKqEmN50hoY=; b=Nlx0djxDoChw+UJzV4pJ3JTJyuJtsZyqEAYaogS8G9o9bzO3pqeHwRu/k0yMBQH2Np b/SloymQuNFpMrO83BANUNxP1PeAjhnKN0xWX33HRZPEPnWUWntm7bv2dWQNFHPM4V/n p55x3Wr0kcUCq4rJJFNb4YriYGiH4DU9t3Qpoi6GWeroio6MV3RXTtu6ZqiXycZwNdWj MOvry8yZ11d9UNl6vHnJc/jXWz5Yu8RN5urhUK2TYBIzXAgGOJWWi8aMQO2+eJorMlbF MhQBJf+/XfBvjLjoD151VKRPJil5cilXuQo06W3J+Vnq9QM9m2DImdR2XAD8VcejHo9c ZEuQ== X-Forwarded-Encrypted: i=1; AJvYcCW+CNTXoyuzYA6OVEkXu5Cnnk+SA3R6V6UolzMxSHeLBcfFRvMxf+CLwFx4SbySY1Y+eYiGyBOyRHUlz5m1WqQq0j4UnwagDaMffJEFuQ== X-Gm-Message-State: AOJu0Yz5rHPZuzgZxGs0EqZgkS8+4DzvmdNJiiTPVo6LuLOpVodRIVMa r+5d5YyoaS5iZJykNFLtDKwoeTRT601xyQ/IYfcgKD3D+3WAl9+e58Yfeo8NE3B1+AQrXglY8mh d X-Google-Smtp-Source: AGHT+IF6lNe7FJxy2kYSpHWMMUEGZhhuFhiDyuheXUBZhHBVpx+1Ckk0HCLalQKp09AtJ/CUpiDCaw== X-Received: by 2002:a17:906:c812:b0:a52:a25:2077 with SMTP id cx18-20020a170906c81200b00a520a252077mr148120ejb.14.1713384427698; Wed, 17 Apr 2024 13:07:07 -0700 (PDT) Received: from [192.168.45.55] (078088045141.garwolin.vectranet.pl. [78.88.45.141]) by smtp.gmail.com with ESMTPSA id l1-20020a17090615c100b00a524e3f2f9esm6128057ejd.98.2024.04.17.13.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 13:07:06 -0700 (PDT) From: Konrad Dybcio Date: Wed, 17 Apr 2024 22:07:00 +0200 Subject: [PATCH 2/2] iommu/qcom: Always consume all clocks Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240416-topic-qcom_iommu-v1-2-fabe55b3b7b3@linaro.org> References: <20240416-topic-qcom_iommu-v1-0-fabe55b3b7b3@linaro.org> In-Reply-To: <20240416-topic-qcom_iommu-v1-0-fabe55b3b7b3@linaro.org> To: Rob Clark , Will Deacon , Robin Murphy , Joerg Roedel Cc: iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stephan Gerhold , Marijn Suijten , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713384421; l=3042; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=3mbMg2ivwWNTK3xsS4wYTiDYZ0KlaU3IbtBCWSlfYEw=; b=vMKT1TBfwDN6a7yS7Xa9gR7+R8/09NZEgAT7cVeFCam7yhXFkvI+O3+YWOJ91TNYJjTsArd92 T3eW7mR8qIWCZp6oPYrDTvlNFLA5FPFMjMh/2H2oX1NZ647vny1akj5 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Some platforms provide more clocks than others, we already have the DT schema to ensure sanity here plus these clocks simply need to be on. Use devm_clk_bulk_get_all and get rid of some boilerplate. Signed-off-by: Konrad Dybcio Reviewed-by: Bjorn Andersson --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 38 +++++++-------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 3dca9293c509..ace69030a422 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -34,13 +34,6 @@ #define SMMU_INTR_SEL_NS 0x2000 -enum qcom_iommu_clk { - CLK_IFACE, - CLK_BUS, - CLK_TBU, - CLK_NUM, -}; - struct qcom_iommu_ctx { struct device *dev; void __iomem *base; @@ -54,7 +47,8 @@ struct qcom_iommu_dev { /* IOMMU core code handle */ struct iommu_device iommu; struct device *dev; - struct clk_bulk_data clks[CLK_NUM]; + struct clk_bulk_data *clks; + int num_clks; void __iomem *local_base; u32 sec_id; u8 max_asid; @@ -781,7 +775,6 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) struct qcom_iommu_dev *qcom_iommu; struct device *dev = &pdev->dev; struct resource *res; - struct clk *clk; int ret, max_asid = 0; /* find the max asid (which is 1:1 to ctx bank idx), so we know how @@ -804,26 +797,11 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) return PTR_ERR(qcom_iommu->local_base); } - clk = devm_clk_get(dev, "iface"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get iface clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_IFACE].clk = clk; - - clk = devm_clk_get(dev, "bus"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get bus clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_BUS].clk = clk; + ret = devm_clk_bulk_get_all(dev, &qcom_iommu->clks); + if (ret <= 0) + return dev_err_probe(dev, ret, "Couldn't get clocks\n"); - clk = devm_clk_get_optional(dev, "tbu"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get tbu clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_TBU].clk = clk; + qcom_iommu->num_clks = ret; if (of_property_read_u32(dev->of_node, "qcom,iommu-secure-id", &qcom_iommu->sec_id)) { @@ -891,7 +869,7 @@ static int __maybe_unused qcom_iommu_resume(struct device *dev) struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); int ret; - ret = clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks); + ret = clk_bulk_prepare_enable(qcom_iommu->num_clks, qcom_iommu->clks); if (ret < 0) return ret; @@ -905,7 +883,7 @@ static int __maybe_unused qcom_iommu_suspend(struct device *dev) { struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); - clk_bulk_disable_unprepare(CLK_NUM, qcom_iommu->clks); + clk_bulk_disable_unprepare(qcom_iommu->num_clks, qcom_iommu->clks); return 0; }