From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96542448B87 for ; Tue, 11 Aug 2026 13:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786455480; cv=none; b=t/khtGXXbmXO7YV18nazjlYeQ+//G1B5PY19VWnV9MKvaMPL//y+Mv8r1WoZtIVHBstifbWvhUYPAMrj+ueebiHJQ51MfzL4yyxtDnAx9ys8eOvwFoAjkM1DhQqbtUk+/6txv2bAzgqYu5AlZYzjAYXiHDcluqTaap5qAXJVpIY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786455480; c=relaxed/simple; bh=zaBYwdzqKnPLChk0jQdmpN+Gtk81dvYuluYIJGNKYNY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CAyTyD1D8cms8DW0HZFtv8a4JB5GrFNz790G2qwaQR843y+3UfN3Um8lBCu21AS1PeV0mz0hW/hZj/nQUYTEyxtp3DU7TT5X1gktvCedhs3o5Sj+bc7GXFe8JGMbSmrUhU69kRvS0sFBWLW1ajVWGGGp5BPmxRjkjvK5Tsi3t94= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=PDczr3y4; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=OEeBB52K; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="PDczr3y4"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="OEeBB52K" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67BDWaDt453540 for ; Tue, 11 Aug 2026 13:37:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= I4kViRm3sAJ0GJ6v9v6dra4X1/iqxcX9YHvXUBsWd+A=; b=PDczr3y4UfA6V3mF PFx885SU/ZyYi5BkDXvlppu8bxwdcpIIj2sMwbaDr6hf932H6gUKX47rljXynaZy QazBr6mWnvLB7KUIBkTH5MFalUFpCfBTIPA+n45GvRd0JhZb8fFL1W6mrgotaQ8w t45NZ3x8Oe39x53+cI2LrAEoWD3/6Dsmi0NP447K1F2G9I5CmPvsl5+zmn+D469A 9ADWL1QZdL+B37znuAySs4iKw5bo/DrJOyFeFQK13z4N0T5JA7+Uc8AOuiDNY9fb yCGoW/E2LdaEcTU334w9+4TjZx0LxYA18/1GdmJsuEaW78eGqJGv8nWQffBsSHm3 iKkB2w== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g049kg5gn-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 11 Aug 2026 13:37:43 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-392cf18db8eso1818940a91.3 for ; Tue, 11 Aug 2026 06:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1786455463; x=1787060263; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=I4kViRm3sAJ0GJ6v9v6dra4X1/iqxcX9YHvXUBsWd+A=; b=OEeBB52KG+l5HFVfhX67guZkfavmFau1XmXLCJFqLXuYa3+Erk1e9KCxJGOn5m5uro B2M1iLzcrQJlK402KI+TukNa8w2MCl5o1+WXSLLm2BNfs4aCu0kNFclivKy4Pqyfu4Po hFuSvZLL43TeGoBMyOiSp1JsZYI6qJyVPu/8pHoYQO4pmNvdtCOEfaLfUzZBr92eVW0d Nv42002bSsR9URlDMN7ToZzV+6UoJxE4GRF9/60f5u4OJtzOrGKanONwnw12494wTSY2 WOs6SNJAdAyO62QZJ1TDDvM/Pe56RaUljNBo8iBatU1PeIpVaOm4B1wwH7NF/LeW4HbG 3RXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786455463; x=1787060263; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=I4kViRm3sAJ0GJ6v9v6dra4X1/iqxcX9YHvXUBsWd+A=; b=Icz6U+eoLOmRLrRvxGIf0+oW4KV9BU9m8DN4VwZ+oEu2OFiDVwN9YGepmpzMAAzxl3 PqtD8z7sW8TJVnS8Ee9/Pe5STZzr+Jr1rBZ/l32p7N88JrU3/mjpAFsdq3RkEeOiRDHx JOsFeNYJNRM+eM+AHYQQl33U2D9/N0PF0Ig8ykGTkBxHf5K4+08MtNMlG7d215J8UtAH BlKuA1J5koeEOkWEvX6rnp1f2SxoOEV1oAdkwIjiVvRET7Z9MqDlxjmNTp6O7qpMJs8L Jor9Pw1s5m+RP10iQ7QQyWklUt/i31Sij1CUUIQ65BKpCDRqBEwhmWfipcQsDYCWSeWu QLLQ== X-Forwarded-Encrypted: i=1; AHgh+RomjPXIF7Mr3S5NKt4dFZgsBymH5cewFB6puxCf5KPtvAWF6Pq+OHjEQ/gDMw1kI82dRXBiBDgJr8LyZFs=@vger.kernel.org X-Gm-Message-State: AOJu0Ywt0Ugabof7eBdqmkgfYX4ON9zvnvEtAabVaeAASn2n7orgjs0g ORmknBBjl/T02Hvd7jwyuOq/tatIVQUUJghtGJsRkkAwxJvnPmd/8AGLcIVn/pALiOugYkObQkQ Df84YveYt04xaCriyUxDI2TmAF3SCCZCojM+76MhUwk13C21ZprJl25CVhpnx440raFE= X-Gm-Gg: AR+sD12YjM1ayFztcDxHTdO8UVfrZQcRDETFXhuDvxxp0Pb69XYVFMu38ZpxUy/BrSq iJpWi/usqowGcfjQBMA2uBn9i/Thx5FUC66fzlcsvVW2ims8yTFpeU9BnNaRlBJvJoH2QlaIOtn 4HR7nMpjuRpFd9V1umLnn/KZXSfX5mtJ/iCHwS4qgnmJ4apsmSMEbzPjdLDsc4Q7rprNJiM7BgB glKKjHPJtALBX688Q/RLR0j8gpY3S0TxHerk/yihHhXoyWehlkXU29z2JLQVu9hEoNRwzzNOFoZ 6d1MKxZia1d/yh24xhXxSKDoF/LgDew/CJs3DBBjx1TbWHT+ZnL9Bh0CjmRSPKJq68MvM/Yzdp0 SwfZNrb7Q4RN5BfuUj4Jj/8dRqKQYGzj0iF6tJJHdI50IJb5iNsJ2bZJX X-Received: by 2002:a17:90a:d44f:b0:37f:ed7e:7e42 with SMTP id 98e67ed59e1d1-392ec56723cmr3832007a91.14.1786455462835; Tue, 11 Aug 2026 06:37:42 -0700 (PDT) X-Received: by 2002:a17:90a:d44f:b0:37f:ed7e:7e42 with SMTP id 98e67ed59e1d1-392ec56723cmr3831909a91.14.1786455462239; Tue, 11 Aug 2026 06:37:42 -0700 (PDT) Received: from yli42-gv.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d315f4819dsm8360885ad.37.2026.08.11.06.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2026 06:37:41 -0700 (PDT) From: Yin Li Date: Tue, 11 Aug 2026 21:30:43 +0800 Subject: [PATCH RFC 14/15] arm_mpam: Support MSC accessibility derivation from RIS nodes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260811-mpam-resctrl-dt-knp-support-v1-14-ea6397bead59@oss.qualcomm.com> References: <20260811-mpam-resctrl-dt-knp-support-v1-0-ea6397bead59@oss.qualcomm.com> In-Reply-To: <20260811-mpam-resctrl-dt-knp-support-v1-0-ea6397bead59@oss.qualcomm.com> To: "Rafael J. Wysocki" , Shanker Donthineni , Conor Dooley , Fenghua Yu , Krzysztof Kozlowski , Rob Herring , Reinette Chatre , Konrad Dybcio , James Morse , Ben Horgan , Bjorn Andersson , Danilo Krummrich , Greg Kroah-Hartman Cc: linux-arm-msm@vger.kernel.org, ganapatrao.kulkarni@oss.qualcomm.com, trilok.soni@oss.qualcomm.com, devicetree@vger.kernel.org, driver-core@lists.linux.dev, Srivathsa L Rao , Huang Yiwei , aiqun.yu@oss.qualcomm.com, linux-kernel@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786455330; l=6269; i=yin.li@oss.qualcomm.com; s=20260811; h=from:subject:message-id; bh=zaBYwdzqKnPLChk0jQdmpN+Gtk81dvYuluYIJGNKYNY=; b=CV39+MeRob0ID7MiE7jf2uDLS4vl9pceQh1lYO3+4YumI0OMEhNB+kgFUsxGLLVZH/eFQ8uUZ TwwYwdYH1sRDRup6i6/E7LtiBUJ6IfZkeWEDOEDdh9iGFcT/tsNokle X-Developer-Key: i=yin.li@oss.qualcomm.com; a=ed25519; pk=e/2LM97aSWGBMrxY240URBi9Zi8/kL5hXgB+VHkYvW0= X-Proofpoint-ORIG-GUID: Lvbn1oeCUC5YyHENNvwL0tqUamGb9ZAv X-Authority-Analysis: v=2.4 cv=IO4yzAvG c=1 sm=1 tr=0 ts=6a7b25a7 cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=DmVZOekaPyhSFRrspXcA:9 a=QEXdDO2ut3YA:10 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDExNCBTYWx0ZWRfX+BBSWx0W1pld nAz5kk5PK9lecdLRn+B3wiFJLxmaWApqm9WwEmi4EzWSi9UpXo8FPVtTra78a1tmtmi2P/Yik64 Qvu5jpRC0pYBA6bBgFAb+XFgEaNYbmByrjDFtl8Fad+H9D5AjpyQTETkXkqLS+9JjYUN3Z6ucfu Pt0lsiC9Zan0RLUCkveQM6i4gKlwwlk+frwuXPKSNvoTCTKS4jpSmK4b+uY+Mv+FBOUb3W5PHhf d3JuCGn61cV8BVGTh89MskZ2q1/h4TNO4CmQzhgivcKS1r/p9POr9edWzi/GmiMR9qCrYf4rV41 rzYhZh+MJHO8RLTILZhmPvKS3wfPbubwR2QPrEbwx77RVdavpvPuz8gbD/K7JnNqT8RhX20pFhA Q2MTXR5oFGZkota90Zdi8W5Ni1P7msAPpJ1EChWHYVGcrXx4ZwcAooU2YOlhAiFVyqTRfhCJJJq w8gKxpYaDkvU3IvfMWA== X-Proofpoint-GUID: Lvbn1oeCUC5YyHENNvwL0tqUamGb9ZAv X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDExNCBTYWx0ZWRfXxoU4/epf+r7R hwJh8AQXHPn/ASyxCsVaM71C+k3zacpcWWzsqftFI7h2znmok/FZtrEeweasF8sLOnGrubkJWtG ipkzU/HQytJtveAun3ocqjbGqs+IoGs= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-11_03,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110114 The DT accessibility derivation only handled MSCs whose parent node is a cache or memory device. When the MSC is placed under a generic container (e.g. directly under /soc), the parent gives no affinity hint and there is no fallback. Add a per-RIS fallback path for when the parent node is not a recognised cache or memory device. For each available RIS child node, affinity is resolved in two steps: first from an explicit 'cpus' phandle-array on the RIS node, then from the 'arm,mpam-device' phandle. The final accessibility mask is the union of all RIS masks; if any RIS fails to resolve, the mask is cleared and the MSC fails to probe rather than come up with a partial affinity. Factor the DT-specific logic into mpam_dt_update_msc_accessibility() so that update_msc_accessibility() dispatches cleanly between ACPI and DT paths. Co-developed-by: Huang Yiwei Signed-off-by: Huang Yiwei Signed-off-by: Yin Li --- drivers/resctrl/mpam_devices.c | 146 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 15 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index d8856864e89a..d0462239deeb 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -2156,6 +2156,136 @@ static int mpam_msc_setup_error_irq(struct mpam_msc *msc) return 0; } +/* + * Resolve a RIS to its CPU affinity from its 'cpus' phandle-array. + * Returns -ENODEV when 'cpus' is absent (the caller may use another source), + * -EINVAL when any phandle is invalid, or 0 on full success. + */ +static int get_cpumask_from_ris_cpus(struct device_node *ris_np, + cpumask_t *affinity) +{ + int i, cpu_phandle_count; + + cpu_phandle_count = of_count_phandle_with_args(ris_np, "cpus", NULL); + if (cpu_phandle_count <= 0) + return -ENODEV; + + for (i = 0; i < cpu_phandle_count; i++) { + struct device_node *phandle_np __free(device_node) = + of_parse_phandle(ris_np, "cpus", i); + int cpu, matched = -1; + + if (phandle_np) { + for_each_possible_cpu(cpu) { + struct device_node *cpu_node __free(device_node) = + of_get_cpu_node(cpu, NULL); + + if (phandle_np == cpu_node) { + matched = cpu; + break; + } + } + } + + if (matched < 0) { + pr_warn("MPAM: RIS %pOF cpus[%d] (%pOF) is not a possible CPU\n", + ris_np, i, phandle_np); + return -EINVAL; + } + + cpumask_set_cpu(matched, affinity); + } + + return 0; +} + +/* + * Resolve a RIS to its CPU affinity from its 'arm,mpam-device' phandle. + * Returns -EINVAL when 'arm,mpam-device' is absent or the phandle is invalid. + * 0 on full success. + */ +static int get_cpumask_from_ris_phandle(struct device_node *ris, + cpumask_t *affinity) +{ + struct device_node *mpam_device __free(device_node) = + of_parse_phandle(ris, "arm,mpam-device", 0); + + if (!mpam_device) { + pr_warn("MPAM: RIS %pOF has neither 'cpus' nor 'arm,mpam-device'\n", + ris); + return -EINVAL; + } + + if (of_device_is_compatible(mpam_device, "cache")) + return get_cpumask_from_cache(mpam_device, affinity); + + if (of_device_is_compatible(mpam_device, "memory")) { + cpumask_or(affinity, affinity, cpu_possible_mask); + return 0; + } + + return -EINVAL; +} + +static int get_cpumask_from_ris(struct device_node *ris, cpumask_t *affinity) +{ + int err; + + err = get_cpumask_from_ris_cpus(ris, affinity); + if (err != -ENODEV) + return err; + + return get_cpumask_from_ris_phandle(ris, affinity); +} + +/* + * Returns -ENODEV when the parent is just a container (not a recognised device), + * so the caller falls back to the per-RIS description. + */ +static int get_cpumask_from_parent(struct mpam_msc *msc, cpumask_t *affinity) +{ + struct device_node *parent __free(device_node) = + of_get_parent(msc->pdev->dev.of_node); + + if (parent == of_root) { + cpumask_copy(affinity, cpu_possible_mask); + return 0; + } + + if (of_device_is_compatible(parent, "cache")) + return get_cpumask_from_cache(parent, affinity); + + if (of_device_is_compatible(parent, "memory")) { + cpumask_copy(affinity, cpu_possible_mask); + return 0; + } + + return -ENODEV; +} + +/* + * An MSC's CPU affinity is described either by its parent node or, when the + * parent is just a container, per-RIS inside the MSC. In the per-RIS case the + * accessibility is the union of the RIS affinities: every RIS must resolve, so + * a single failure clears the mask and stops and the MSC fails to probe rather + * than come up with a partial affinity. + */ +static void mpam_dt_update_msc_accessibility(struct mpam_msc *msc) +{ + cpumask_t *affinity = &msc->accessibility; + + cpumask_clear(affinity); + + if (get_cpumask_from_parent(msc, affinity) == -ENODEV) { + for_each_available_child_of_node_scoped(msc->pdev->dev.of_node, ris) { + if (get_cpumask_from_ris(ris, affinity)) { + cpumask_clear(affinity); + break; + } + } + } +} + /* * An MSC can control traffic from a set of CPUs, but may only be accessible * from a (hopefully wider) set of CPUs. The common reason for this is power @@ -2165,8 +2295,6 @@ static int mpam_msc_setup_error_irq(struct mpam_msc *msc) */ static void update_msc_accessibility(struct mpam_msc *msc) { - struct device *dev = &msc->pdev->dev; - struct device_node *parent; u32 affinity_id; int err; @@ -2182,19 +2310,7 @@ static void update_msc_accessibility(struct mpam_msc *msc) return; } - /* Where an MSC can be accessed from depends on the path to of_node. */ - parent = of_get_parent(msc->pdev->dev.of_node); - if (parent == of_root) { - cpumask_copy(&msc->accessibility, cpu_possible_mask); - } else { - if (of_device_is_compatible(parent, "cache")) - get_cpumask_from_cache(parent, &msc->accessibility); - else if (of_device_is_compatible(parent, "memory")) - cpumask_copy(&msc->accessibility, cpu_possible_mask); - else - dev_err_once(dev, "Cannot determine accessibility of MSC.\n"); - } - of_node_put(parent); + mpam_dt_update_msc_accessibility(msc); } /* -- 2.34.1