From patchwork Fri Aug 25 21:35:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 717872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CD98C7EE2C for ; Fri, 25 Aug 2023 21:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231281AbjHYVgI (ORCPT ); Fri, 25 Aug 2023 17:36:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbjHYVf6 (ORCPT ); Fri, 25 Aug 2023 17:35:58 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7528610C7 for ; Fri, 25 Aug 2023 14:35:55 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5007f3d3235so2079502e87.2 for ; Fri, 25 Aug 2023 14:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692999354; x=1693604154; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tp7LgFPLpnIkw2JmjBzO/9511opzQR/ho3jSDUkitEI=; b=WQzBx3wDBZP8lOmUkvk09NRwHzHkybbed0St4r0VsMFSTBNaXFRuqJnmJG2ve4fBaM i7v8KgtCZfjOMfSn5VzRTx/g/dO1IvY6NcuEI9adeVnsYSlqTK2wOdbCJZe3sAxDZPuL z12qzuZ+Wkak33cJKUPvW61kxALAGfd044oeOr8BuUT6/gJI/B43THKdbIncm+dIGWxw YPmV7vzvPNiw0qExibgYK8yk+tOqzyNIza9HFrR50HbGz3iRYWdPxNl5BijUV9aRMG+k /elYaOPEC/yAWIYwm21KnGXCRfDe9t1ETVqe2tpdgEyaSoCRh6yTdalKwy9PP7aALXeT 98dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692999354; x=1693604154; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tp7LgFPLpnIkw2JmjBzO/9511opzQR/ho3jSDUkitEI=; b=Lef1xTQlGQooa+AlqbtLquWvh/hW1cs5O5YVT+baLHuNAKwHCzLSbF/3Rxpe0CjJFK lLFVOEDj6aS5BGN5kyvvY+InO9nkW996cYZWlr6Fvv1DAB4HWXXEciXncMbaouBvzFA2 IR4uDiO8SkqQzlMRl9HyJicv82mGtTB38jwcrwEZqOGFTeOrCyTuSIw9NfexMgqkSGIc Zr433kWl1znx4328FOzqreIenHQ0d2XYGroD1HyJRs9QYuKGYJFdLQqDVcwW4s90Krjh vcHYa7sDH4eQpQIuTfxBy8Gxb1X8i6gQieltpBqgbkeYeKsU6xlFv8RteQL8Y3RVvTjq YRKQ== X-Gm-Message-State: AOJu0YxKxGX7vmc31Ue4OquA6+lCleMWvy8EuQIWO8tceZq21gN3wBpE sy27LJKosPFWjAv5Aa222Lsv6+4ZJ8qTpiFVg40= X-Google-Smtp-Source: AGHT+IHRhrWqUyLoNkeL82+BnNr9H5EuJ2/70xPuM2P3fuBxElC8Ed3FFrgvWr8P8/qR2fBbcIzOkg== X-Received: by 2002:a05:6512:b05:b0:500:9026:a290 with SMTP id w5-20020a0565120b0500b005009026a290mr9955891lfu.9.1692999353563; Fri, 25 Aug 2023 14:35:53 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id b11-20020ac25e8b000000b004fe47879d93sm429947lfq.106.2023.08.25.14.35.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 14:35:53 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Thomas Gleixner , Marc Zyngier Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong Subject: [PATCH 1/2] irqchip/qcom-pdc: don't read version register if it is not available Date: Sat, 26 Aug 2023 00:35:51 +0300 Message-Id: <20230825213552.1646321-1-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Qualcomm SM8150 the PDC resource has size 0x400. When PDC driver tries to read the version register (0x1000), it reads past the end of this resource, causing kernel crash. Check the size of PDC resource before reading the PDC_VERSION register. Fixes: bc82cc42644b ("irqchip/qcom-pdc: Add support for v3.2 HW") Signed-off-by: Dmitry Baryshkov --- drivers/irqchip/qcom-pdc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index 9bb6951257c2..431b213b5abb 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -324,6 +324,7 @@ static int pdc_setup_pin_mapping(struct device_node *np) static int qcom_pdc_init(struct device_node *node, struct device_node *parent) { struct irq_domain *parent_domain, *pdc_domain; + struct resource res; int ret; pdc_base = of_iomap(node, 0); @@ -332,7 +333,14 @@ static int qcom_pdc_init(struct device_node *node, struct device_node *parent) return -ENXIO; } - pdc_version = pdc_reg_read(PDC_VERSION, 0); + if (of_address_to_resource(node, 0, &res)) + return -EINVAL; + + /* compat with old sm8150 DT which had very small region for PDC */ + if (resource_size(&res) > PDC_VERSION) + pdc_version = pdc_reg_read(PDC_VERSION, 0); + else + pdc_version = 0; parent_domain = irq_find_host(parent); if (!parent_domain) { From patchwork Fri Aug 25 21:35:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 716916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0804EE49B3 for ; Fri, 25 Aug 2023 21:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231444AbjHYVgJ (ORCPT ); Fri, 25 Aug 2023 17:36:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231459AbjHYVf6 (ORCPT ); Fri, 25 Aug 2023 17:35:58 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1EDF26A3 for ; Fri, 25 Aug 2023 14:35:55 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50091b91a83so2034465e87.3 for ; Fri, 25 Aug 2023 14:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692999354; x=1693604154; 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=26pn9YzS7LvfeqGbIW61UxU0+DuPD7DZQB8eW2hvtKM=; b=iRZHAwuYmQrr2Z9IY1xwMbg7LDWbfh57GpHGdctJ99CsrEOYfRXwatyk3ENJVb/SHr gQOWY6xTPMcGxLRtvhfzGNIbHipYLey+GtcXsyM0sTHKfqxUZvZUhG3KbYUH9nkbK1Tf SfjlMWtWMrbEpV7clPV2r8MeSIfHsler/9YgUjpofV+PNw3J1972VLYROFCQWIznjPpr 1MEjccQ301aAehtFHdAhJwJEdRBNKE20cioxw/P9FqEm0t2F330ot2noOGsUwRXJFtsi 0YNn8xm/KVAApZsO8T2SzYm8hzwNhb2L5g9EFABIKrkfpBoQQRShRnRq17p1XJSXU5XV sHMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692999354; x=1693604154; 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=26pn9YzS7LvfeqGbIW61UxU0+DuPD7DZQB8eW2hvtKM=; b=Ta7zuapJVm6N5WnDCTML/q87Iv/10YGPkAqZ/uO34Tc4Q5lZf0givNalptpvPqtPo7 DOmV/uL1a8QeqIXT8ASpMzNOqc+daSolfz8FBOEgQKY7852jsqL4VL8pABEXHvUOGcig WoclGcCXeKzrJnH9GOFshqB1+BEVe2I1eCV1UCi8tR6ja0IapFMjlYvFH2xvRFWI5jdd o88HfkioyvKQzFSiWKby6ZIR4QdBQMnQV1N6fr/1hLrioWHC5mXWos3UKY1K94q+k/01 6+RXgcefJklCVMHSUyC1Nm+1waXaydkFvOqlXvBRxZX9Pn3+EYMF5V/T4EcgyRCTc+aT 4ppw== X-Gm-Message-State: AOJu0YxhmbFY2futYdu6W2zbo+fovLL0Mw/nsJThXERP2FwR2VKmzAVd fXJnn9QmazKmZS2XHnQ/yiwAmA== X-Google-Smtp-Source: AGHT+IHYYIxBsOIv5/RRxtju53Lr3ztpX2Sm8pNCjTOn2ZEVtwAf/RRNnNGa6RyqUvaP5vH7AmVOow== X-Received: by 2002:a05:6512:200d:b0:4f1:4cdc:ec03 with SMTP id a13-20020a056512200d00b004f14cdcec03mr11823459lfb.18.1692999354319; Fri, 25 Aug 2023 14:35:54 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id b11-20020ac25e8b000000b004fe47879d93sm429947lfq.106.2023.08.25.14.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 14:35:53 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Thomas Gleixner , Marc Zyngier Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong Subject: [PATCH 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource Date: Sat, 26 Aug 2023 00:35:52 +0300 Message-Id: <20230825213552.1646321-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230825213552.1646321-1-dmitry.baryshkov@linaro.org> References: <20230825213552.1646321-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Follow the example of other platforms and extend the PDC resource region to 0x30000, so that the PDC driver can read the PDC_VERSION register. Signed-off-by: Dmitry Baryshkov Reviewed-by: Konrad Dybcio --- arch/arm64/boot/dts/qcom/sm8150.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sm8150.dtsi b/arch/arm64/boot/dts/qcom/sm8150.dtsi index 380712aee977..38c5d6dbd0d7 100644 --- a/arch/arm64/boot/dts/qcom/sm8150.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8150.dtsi @@ -3923,7 +3923,7 @@ dispcc: clock-controller@af00000 { pdc: interrupt-controller@b220000 { compatible = "qcom,sm8150-pdc", "qcom,pdc"; - reg = <0 0x0b220000 0 0x400>; + reg = <0 0x0b220000 0 0x30000>; qcom,pdc-ranges = <0 480 94>, <94 609 31>, <125 63 1>; #interrupt-cells = <2>;