From nobody Mon Nov 25 08:04:07 2024 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 9A6821E0B7C; Mon, 28 Oct 2024 21:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151326; cv=none; b=uIxYfO0EKSgXfLvQ2G6C8ltd8NJPkxK+hrQM1zZneTwqdMihEFttpYhfvwM4iat2RlB4W0yL+QV7azunn/RmUvHZBfWiYnLUggzE87LpL+tZvvKPkOF1u3bWGvdVPEqiiBNoign0ikMoCFRNSMzpLStHsUYLYTptBrYKBIZLWSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151326; c=relaxed/simple; bh=7uXbqAU2Rs+FdAUI0yMJyvdaxWyQLWN4ppo3xQU6jME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VdT9kyu0489heUd4s/GlaNY6nDvgxrIjvkNq0h29r6n3lMfsPpDqssuhnt2S+a54Bek0Nq7wF5Frf/ttWtylQgSl8ClqHMUsnn3MfGr2fNDGw1q1wN1k9eD2lzmlz0NibzpVq1tsx3lFsXo3i2PN6kEU+2+NZzJFwoQMkiIyTqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VB2LS+XT; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VB2LS+XT" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2e56df894d4so3797777a91.3; Mon, 28 Oct 2024 14:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730151324; x=1730756124; darn=vger.kernel.org; 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=m061Pyg3UwMZEnlvYwP1sOYnaFDaV5Le181aUe2JWFs=; b=VB2LS+XTjryCjKvZh5lj9Fv3uhuKi5QcNfbMZJh+jmBvKEaBfnxMuALD35n2NUYL3O EDl2Y03OSzCtFm8G0gO5dDUfo8hu4tG0ewNGeFvAOU6D0ve4JUyN9zMaD/mpttirmpxZ L/mo9CxKtYzm2glM0hs5Ccxdrop4aHlmp+F0C9cn6m1WM4HN76Gt1NKe0gSGlDLtDyhI eBMFhmWKkL+pg+0VzxWsgEJIKAm/8aPp6ETSdOI+WW5KIu4M2oPf/dtYGiP3glxKhTm3 gqBQnjUYRc4nDw8tbl5z7MeN3XOkOCLdybY6BhI6HlOc+73aBVmhrNB+Avr4UMNTLrZU oe3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730151324; x=1730756124; 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=m061Pyg3UwMZEnlvYwP1sOYnaFDaV5Le181aUe2JWFs=; b=Hspff4bNac8jEC28G7uzFzh65Fq79TAI6+LnLUItujeE0uBI/0Ghd1x/wTX/tOZhAm 8zKxifvdzD80KgKhMFBeyT3X5ZIAgKiCpzkA3KXZlx0v7PbA+61f3h2h+yMY4A1IZRlv WTzg+SY/+cAzggAkeDX8UWFYB84oQRZoyz2Ful93+UwH1281Iz3grIFMaa2/iT+8p7ey qjeh1WBAnnkI7/zpNNY+AmZJumDV1uh84I1oOsDDKfl5AQwTktyOYL3B8UiWu264Z7Ey A/MyyxuMQE3TK66n7x4zO+rRnsYtATlHH10INtUVjZLLas5gu1y17oHyBatVaEN25pD8 cJIg== X-Forwarded-Encrypted: i=1; AJvYcCVPD6fBL8y1j0nBxa0Om12cBV+upOvdET/3SkBLWgvj0jFomM2KdCXvWY4EYxbBMsRg+Aeulnsj1ONkz7c=@vger.kernel.org X-Gm-Message-State: AOJu0YzvZbji98eb3aRvEXoRIdeXvCd5euu/QRiSB174PX8KyBjA9DwI VH6j9QxF4luqgCxADUX1/YaBIj9YwtckDvnKodmW1z0xdxvbjOor X-Google-Smtp-Source: AGHT+IFMkNPD4yFz3qyWlzboYMBT0a0xBeKCCszOPUsi1vknNqZcTwRtbyVqgGg1MSNysN4Mc2hgGA== X-Received: by 2002:a17:90a:c90b:b0:2e2:e092:5323 with SMTP id 98e67ed59e1d1-2e8f11a9716mr11015208a91.29.1730151323871; Mon, 28 Oct 2024 14:35:23 -0700 (PDT) Received: from localhost ([2a00:79e1:2e00:1301:12e9:d196:a1e9:ab67]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4c2a9dsm9890110a91.15.2024.10.28.14.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 14:35:23 -0700 (PDT) From: Rob Clark To: iommu@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Will Deacon , Robin Murphy , Mostafa Saleh , Rob Clark , Joerg Roedel , linux-arm-kernel@lists.infradead.org (moderated list:ARM SMMU DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 1/4] iommu/io-pgtable-arm: Make pgtable walker more generic Date: Mon, 28 Oct 2024 14:31:37 -0700 Message-ID: <20241028213146.238941-2-robdclark@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028213146.238941-1-robdclark@gmail.com> References: <20241028213146.238941-1-robdclark@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Rob Clark We can re-use this basic pgtable walk logic in a few places. Signed-off-by: Rob Clark --- drivers/iommu/io-pgtable-arm.c | 67 ++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 0e67f1721a3d..7e9c0f8ae138 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -749,33 +749,33 @@ static phys_addr_t arm_lpae_iova_to_phys(struct io_pg= table_ops *ops, } =20 struct io_pgtable_walk_data { - struct iommu_dirty_bitmap *dirty; + struct io_pgtable *iop; + void *data; + int (*visit)(struct io_pgtable_walk_data *walk_data, int lvl, + arm_lpae_iopte *ptep, size_t size); unsigned long flags; u64 addr; const u64 end; }; =20 -static int __arm_lpae_iopte_walk_dirty(struct arm_lpae_io_pgtable *data, - struct io_pgtable_walk_data *walk_data, - arm_lpae_iopte *ptep, - int lvl); +static int __arm_lpae_iopte_walk(struct arm_lpae_io_pgtable *data, + struct io_pgtable_walk_data *walk_data, + arm_lpae_iopte *ptep, + int lvl); =20 -static int io_pgtable_visit_dirty(struct arm_lpae_io_pgtable *data, - struct io_pgtable_walk_data *walk_data, - arm_lpae_iopte *ptep, int lvl) +static int io_pgtable_visit(struct arm_lpae_io_pgtable *data, + struct io_pgtable_walk_data *walk_data, + arm_lpae_iopte *ptep, int lvl) { struct io_pgtable *iop =3D &data->iop; arm_lpae_iopte pte =3D READ_ONCE(*ptep); =20 - if (iopte_leaf(pte, lvl, iop->fmt)) { - size_t size =3D ARM_LPAE_BLOCK_SIZE(lvl, data); + size_t size =3D ARM_LPAE_BLOCK_SIZE(lvl, data); + int ret =3D walk_data->visit(walk_data, lvl, ptep, size); + if (ret) + return ret; =20 - if (iopte_writeable_dirty(pte)) { - iommu_dirty_bitmap_record(walk_data->dirty, - walk_data->addr, size); - if (!(walk_data->flags & IOMMU_DIRTY_NO_CLEAR)) - iopte_set_writeable_clean(ptep); - } + if (iopte_leaf(pte, lvl, iop->fmt)) { walk_data->addr +=3D size; return 0; } @@ -784,13 +784,13 @@ static int io_pgtable_visit_dirty(struct arm_lpae_io_= pgtable *data, return -EINVAL; =20 ptep =3D iopte_deref(pte, data); - return __arm_lpae_iopte_walk_dirty(data, walk_data, ptep, lvl + 1); + return __arm_lpae_iopte_walk(data, walk_data, ptep, lvl + 1); } =20 -static int __arm_lpae_iopte_walk_dirty(struct arm_lpae_io_pgtable *data, - struct io_pgtable_walk_data *walk_data, - arm_lpae_iopte *ptep, - int lvl) +static int __arm_lpae_iopte_walk(struct arm_lpae_io_pgtable *data, + struct io_pgtable_walk_data *walk_data, + arm_lpae_iopte *ptep, + int lvl) { u32 idx; int max_entries, ret; @@ -805,7 +805,7 @@ static int __arm_lpae_iopte_walk_dirty(struct arm_lpae_= io_pgtable *data, =20 for (idx =3D ARM_LPAE_LVL_IDX(walk_data->addr, lvl, data); (idx < max_entries) && (walk_data->addr < walk_data->end); ++idx) { - ret =3D io_pgtable_visit_dirty(data, walk_data, ptep + idx, lvl); + ret =3D io_pgtable_visit(data, walk_data, ptep + idx, lvl); if (ret) return ret; } @@ -813,6 +813,23 @@ static int __arm_lpae_iopte_walk_dirty(struct arm_lpae= _io_pgtable *data, return 0; } =20 +static int visit_dirty(struct io_pgtable_walk_data *walk_data, int lvl, + arm_lpae_iopte *ptep, size_t size) +{ + struct iommu_dirty_bitmap *dirty =3D walk_data->data; + + if (!iopte_leaf(*ptep, lvl, walk_data->iop->fmt)) + return 0; + + if (iopte_writeable_dirty(*ptep)) { + iommu_dirty_bitmap_record(dirty, walk_data->addr, size); + if (!(walk_data->flags & IOMMU_DIRTY_NO_CLEAR)) + iopte_set_writeable_clean(ptep); + } + + return 0; +} + static int arm_lpae_read_and_clear_dirty(struct io_pgtable_ops *ops, unsigned long iova, size_t size, unsigned long flags, @@ -821,7 +838,9 @@ static int arm_lpae_read_and_clear_dirty(struct io_pgta= ble_ops *ops, struct arm_lpae_io_pgtable *data =3D io_pgtable_ops_to_data(ops); struct io_pgtable_cfg *cfg =3D &data->iop.cfg; struct io_pgtable_walk_data walk_data =3D { - .dirty =3D dirty, + .iop =3D &data->iop, + .data =3D dirty, + .visit =3D visit_dirty, .flags =3D flags, .addr =3D iova, .end =3D iova + size, @@ -836,7 +855,7 @@ static int arm_lpae_read_and_clear_dirty(struct io_pgta= ble_ops *ops, if (data->iop.fmt !=3D ARM_64_LPAE_S1) return -EINVAL; =20 - return __arm_lpae_iopte_walk_dirty(data, &walk_data, ptep, lvl); + return __arm_lpae_iopte_walk(data, &walk_data, ptep, lvl); } =20 static void arm_lpae_restrict_pgsizes(struct io_pgtable_cfg *cfg) --=20 2.47.0 From nobody Mon Nov 25 08:04:07 2024 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 B86861EE009; Mon, 28 Oct 2024 21:35:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151328; cv=none; b=Ea1axK3pI2mvwVi622GSSmott0alsD4YPd5jsjNjbNQlLVC43kHZUGw44u0Zl37NVODfZNPIPriklhhbJWbZHDQHIZsuuFLrDSizsKdzhwCcM1gkme8NbZ5cUXz3j5AUNL5zrSwtX5YV7esAKHUrHAW5GtP6Fjz0caO5JmCu7H0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151328; c=relaxed/simple; bh=+E+z/EOaiAO9EI4kie6YvvmAmAMMQ+x08UASzW5Rucg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fQWmc51mm+K+59uEmsCPB9aWlNKpH63kyJfC91R6+PowSfBCU/7uUOBmQdrNTGr8tu37Y4sYOEusZAMXnvGwHZBrseKO1jeqq7tdhe9p6PKYDNCIzry7/25fVO+egDwL9yUH59EDS4nt4VJI3s438YYzTikChHvwK2h2BhLf7ZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h/Wtp4zT; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h/Wtp4zT" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7ea16c7759cso2246541a12.1; Mon, 28 Oct 2024 14:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730151326; x=1730756126; darn=vger.kernel.org; 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=HG6V5IEjg5fR7H7zxvH/yThNTAfW1zJep5mmD3Nzp9E=; b=h/Wtp4zTxmXPlsbN54HrbExpTqRk7EQDC4jw2SL+OoVvpOqEHlT0MsQNTQhD20gqYn 0kAwp+AQ8EUukYvT5v0BLyI+eY/Tf3mUKDQa+47WTThVWEpgVRDI9T409Y+F+xD4ixoD /GrT+zo+uthxn18LITYCkpSfwFjwNF154OwppG2QjqYItgRGj5B8sGH4jS7Hd/9nwFXs M03e/F1ZJpo5MR5FvE194b+BybcLzs+OJ2cqgT7/o+OWYR8swkqvlRSI+ucX1ox0Qhwo z5sYbQxaTMbv8JQGaw3njluoOQgQd4dfvP55OoStVgNaInUAvLtyhuBbQKVc1LhplgNG wgUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730151326; x=1730756126; 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=HG6V5IEjg5fR7H7zxvH/yThNTAfW1zJep5mmD3Nzp9E=; b=SLXnkvdAsvDlumxHP3u9TRZ4csOQiAi6gcHzMB9AB0zt2GPIMW4cE/vzlrv2J+IHgK wHMZhDeHM1t1o5fJooEBvw6LLcTxykvDn5mboGiBLCX8+awAf45eGKxPxaq/gHvJqm/B relnGWUFA6TshSa3AkJY5dDriYPgSTcNX8d0WTZGxDoyD71PsThUgdvpDZrBJzCH2AvA UibS2EiCv8Q8vnQ47KSzpmKgO/rAiFUz4f3eNWoJfTFREBuMG7HNalFSg4d1BUlUozg5 Ic3GUZc3EYtQJbTrVp/x3OSBUbRCQ9jIZ/yttJCju8K/R5aflrUJcmVlhFbcxDpkPCAZ +LTA== X-Forwarded-Encrypted: i=1; AJvYcCUAWq6DBQ2HJh3xt5m05kvwcVROt+mvojrLDbGX8Zgdo6wBAZvBWO6hRCxQAQm+11N0GIYzS1Mr8ziHSgg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0Q4W4yDDlRRsjF4Eoo1YjK2ueRe9H507Y6FPwO4uaorWpjc/1 hZ7/1XQFjIsVQZjKxelzu9EpEN2eiBROgwN8DYnQBL+glN+LbdpN X-Google-Smtp-Source: AGHT+IHYfTByDMFcPygEQ50HF0A5OEX5ytobSAKHJ4GmVG1OnJTN978gymeL5m5xxwFxhYlpGaAN7A== X-Received: by 2002:a05:6a20:4499:b0:1d9:1a3b:85d4 with SMTP id adf61e73a8af0-1d9a83b5192mr14212818637.6.1730151325996; Mon, 28 Oct 2024 14:35:25 -0700 (PDT) Received: from localhost ([2a00:79e1:2e00:1301:12e9:d196:a1e9:ab67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72057931a06sm6216898b3a.55.2024.10.28.14.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 14:35:25 -0700 (PDT) From: Rob Clark To: iommu@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Will Deacon , Robin Murphy , Mostafa Saleh , Rob Clark , Joerg Roedel , linux-arm-kernel@lists.infradead.org (moderated list:ARM SMMU DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 2/4] iommu/io-pgtable-arm: Re-use the pgtable walk for iova_to_phys Date: Mon, 28 Oct 2024 14:31:38 -0700 Message-ID: <20241028213146.238941-3-robdclark@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028213146.238941-1-robdclark@gmail.com> References: <20241028213146.238941-1-robdclark@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Rob Clark Re-use the generic pgtable walk path. Signed-off-by: Rob Clark --- drivers/iommu/io-pgtable-arm.c | 74 +++++++++++++++++----------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 7e9c0f8ae138..88b128c77893 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -712,42 +712,6 @@ static size_t arm_lpae_unmap_pages(struct io_pgtable_o= ps *ops, unsigned long iov data->start_level, ptep); } =20 -static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops, - unsigned long iova) -{ - struct arm_lpae_io_pgtable *data =3D io_pgtable_ops_to_data(ops); - arm_lpae_iopte pte, *ptep =3D data->pgd; - int lvl =3D data->start_level; - - do { - /* Valid IOPTE pointer? */ - if (!ptep) - return 0; - - /* Grab the IOPTE we're interested in */ - ptep +=3D ARM_LPAE_LVL_IDX(iova, lvl, data); - pte =3D READ_ONCE(*ptep); - - /* Valid entry? */ - if (!pte) - return 0; - - /* Leaf entry? */ - if (iopte_leaf(pte, lvl, data->iop.fmt)) - goto found_translation; - - /* Take it to the next level */ - ptep =3D iopte_deref(pte, data); - } while (++lvl < ARM_LPAE_MAX_LEVELS); - - /* Ran out of page tables to walk */ - return 0; - -found_translation: - iova &=3D (ARM_LPAE_BLOCK_SIZE(lvl, data) - 1); - return iopte_to_paddr(pte, data) | iova; -} - struct io_pgtable_walk_data { struct io_pgtable *iop; void *data; @@ -763,6 +727,41 @@ static int __arm_lpae_iopte_walk(struct arm_lpae_io_pg= table *data, arm_lpae_iopte *ptep, int lvl); =20 +struct iova_to_phys_data { + arm_lpae_iopte pte; + int lvl; +}; + +static int visit_iova_to_phys(struct io_pgtable_walk_data *walk_data, int = lvl, + arm_lpae_iopte *ptep, size_t size) +{ + struct iova_to_phys_data *data =3D walk_data->data; + data->pte =3D *ptep; + data->lvl =3D lvl; + return 0; +} + +static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops, + unsigned long iova) +{ + struct arm_lpae_io_pgtable *data =3D io_pgtable_ops_to_data(ops); + struct iova_to_phys_data d; + struct io_pgtable_walk_data walk_data =3D { + .data =3D &d, + .visit =3D visit_iova_to_phys, + .addr =3D iova, + .end =3D iova + 1, + }; + int ret; + + ret =3D __arm_lpae_iopte_walk(data, &walk_data, data->pgd, data->start_le= vel); + if (ret) + return 0; + + iova &=3D (ARM_LPAE_BLOCK_SIZE(d.lvl, data) - 1); + return iopte_to_paddr(d.pte, data) | iova; +} + static int io_pgtable_visit(struct arm_lpae_io_pgtable *data, struct io_pgtable_walk_data *walk_data, arm_lpae_iopte *ptep, int lvl) @@ -780,8 +779,9 @@ static int io_pgtable_visit(struct arm_lpae_io_pgtable = *data, return 0; } =20 - if (WARN_ON(!iopte_table(pte, lvl))) + if (!iopte_table(pte, lvl)) { return -EINVAL; + } =20 ptep =3D iopte_deref(pte, data); return __arm_lpae_iopte_walk(data, walk_data, ptep, lvl + 1); --=20 2.47.0 From nobody Mon Nov 25 08:04:07 2024 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 CC5361F4267; Mon, 28 Oct 2024 21:35:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151331; cv=none; b=NF4jSQL7UQRsgo9hc9EJs+LshsSWMmQroWPz3SalbBFHwcZ7xYf8d7WYrN9C6KdU/Lktedxah59awoyulNZuEk86iU4ElGhpa1uOnbB1ZRCa0NMyqHQmuS1gHqEyH53T0tMJ5vVU60zofv/LX+9baeZGsINx/zKFrA3U4wkuPB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151331; c=relaxed/simple; bh=CC5DXv1pWsSCQKxatEBjAd9fJMcRefvmUAh3/PlXxlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PLiAmM5Oomdyft82PDnWDpWc71P3RY0rINZC5dn+BZc1AgJyHyPoA++JmSw/Tqxl3m2rflglhurXM2343+hybA+C2Byn7wkR3QNxrA0l7VMgEkV6iqKKJxXWBSIftxyiZ+PIh44gU3+NYjDaJcqQJs4VeYj5frpxyYP2oThLDLo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Azpr6Wgd; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Azpr6Wgd" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-71e625b00bcso3645926b3a.3; Mon, 28 Oct 2024 14:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730151329; x=1730756129; darn=vger.kernel.org; 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=U5JCDOT4G1vRDgamkQTQYoEg3xqOKYS4iUoOBpBdGUM=; b=Azpr6WgdJDObXRIye1to2pgHHww3FLapTjmAL9scPvfBV+xK4/whv7+mvDhtnZlgLQ JBBJZCwStKyQ7lYTc0mvPF2JlStEwJV8bRlCyu3jVFLeJuXkU0GLeX0ciAi+6Zqb7wxC paA3Cyca99gsrNVGp8PjV0gwo8m9sCxsxZpGR84AYCbNgZSiWLszi0cKzgWq9kXZykty oRuEZZALZ/GXrXBzVSr5OTzgAnpou4acQdikQ+Bwi1y83UpiwYDpIF9F3MschQH7gGu7 4JshKXvAJOjgXPyK5DTVEpQPArg8FIOvcVTFp0ugLf7X9gx/5QXIhu2DxZRegumnPG+9 tEdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730151329; x=1730756129; 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=U5JCDOT4G1vRDgamkQTQYoEg3xqOKYS4iUoOBpBdGUM=; b=A5ImeIH9Hon8AzN+BguyMqZFR35Wk2F0zSqGeUaGrjDR3kwxSWFIfMI2hEn9MMYcPO SmZwQJJDqkcrzLSMApSXrI7vho7Ya2ytH5+Lzlq2c+exAy1/miKzXyUPqjlRbF4loqMu 5uRjboscv0oXMXG43Ir+Q/JhzDmRAEBOmUOBL7gPdkATdM37FFgLcbizClksC0Wi9Jhx cf1xCpPq4QmpO8D1dG6A0Ds56+Nqv8SD1/FsuwYk0cWjDSGBQVq2PHsxUvNS+2MQo9Ds QyefP/IT5x2EMHCviM4nk7/fu92tnAc7uBPKCKLPgQ5DBXoQ7wFUfYeUAe+H0skAvsl1 sGFQ== X-Forwarded-Encrypted: i=1; AJvYcCXu6bikO/IenmqvjRtEHp/9Z2T16X/2HRUDMMOjzJqVoaczerlt7F5PitPEHQoG8vHFtamgMnQD3dKj3C0=@vger.kernel.org X-Gm-Message-State: AOJu0YxUMOLl9Cq+V3N0g8qKI3ejAXICEV0qYFfnWQ7lINuW+3PyRcSJ RW5AZPUA4TF2sBnwfM+avVyBwoUpkhdqO/e4Ml1KyVVCdXiL1aRP X-Google-Smtp-Source: AGHT+IGJ/vSmxwIqBeNVXBSzAWZP5g2tROL+0Y2wcPzndUVsioqMA6yobuvrQ/JZESgfajh0W3hfHw== X-Received: by 2002:a05:6a00:230b:b0:71e:4cff:2654 with SMTP id d2e1a72fcca58-72062f86088mr14718581b3a.6.1730151329086; Mon, 28 Oct 2024 14:35:29 -0700 (PDT) Received: from localhost ([2a00:79e1:2e00:1301:12e9:d196:a1e9:ab67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7205791e4dasm6207770b3a.25.2024.10.28.14.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 14:35:28 -0700 (PDT) From: Rob Clark To: iommu@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Will Deacon , Robin Murphy , Mostafa Saleh , Rob Clark , Joerg Roedel , Jason Gunthorpe , Vasant Hegde , Shameer Kolothum , Nicolin Chen , Joao Martins , Boris Brezillon , linux-arm-kernel@lists.infradead.org (moderated list:ARM SMMU DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 3/4] iommu/io-pgtable-arm: Add way to debug pgtable walk Date: Mon, 28 Oct 2024 14:31:39 -0700 Message-ID: <20241028213146.238941-4-robdclark@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028213146.238941-1-robdclark@gmail.com> References: <20241028213146.238941-1-robdclark@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Rob Clark Add an io-pgtable method to walk the pgtable returning the raw PTEs that would be traversed for a given iova access. Signed-off-by: Rob Clark --- drivers/iommu/io-pgtable-arm.c | 25 +++++++++++++++++++++++++ include/linux/io-pgtable.h | 15 +++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 88b128c77893..6739e1fa54ec 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -762,6 +762,30 @@ static phys_addr_t arm_lpae_iova_to_phys(struct io_pgt= able_ops *ops, return iopte_to_paddr(d.pte, data) | iova; } =20 +static int visit_pgtable_walk(struct io_pgtable_walk_data *walk_data, int = lvl, + arm_lpae_iopte *ptep, size_t size) +{ + struct arm_lpae_io_pgtable_walk_data *data =3D walk_data->data; + data->ptes[data->level++] =3D *ptep; + return 0; +} + +static int arm_lpae_pgtable_walk(struct io_pgtable_ops *ops, unsigned long= iova, + void *wd) +{ + struct arm_lpae_io_pgtable *data =3D io_pgtable_ops_to_data(ops); + struct io_pgtable_walk_data walk_data =3D { + .data =3D wd, + .visit =3D visit_pgtable_walk, + .addr =3D iova, + .end =3D iova + 1, + }; + + ((struct arm_lpae_io_pgtable_walk_data *)wd)->level =3D 0; + + return __arm_lpae_iopte_walk(data, &walk_data, data->pgd, data->start_lev= el); +} + static int io_pgtable_visit(struct arm_lpae_io_pgtable *data, struct io_pgtable_walk_data *walk_data, arm_lpae_iopte *ptep, int lvl) @@ -937,6 +961,7 @@ arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg) .unmap_pages =3D arm_lpae_unmap_pages, .iova_to_phys =3D arm_lpae_iova_to_phys, .read_and_clear_dirty =3D arm_lpae_read_and_clear_dirty, + .pgtable_walk =3D arm_lpae_pgtable_walk, }; =20 return data; diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index b1ecfc3cd5bc..d7bfbf351975 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -178,12 +178,26 @@ struct io_pgtable_cfg { }; }; =20 +/** + * struct arm_lpae_io_pgtable_walk_data - information from a pgtable walk + * + * @ptes: The recorded PTE values from the walk + * @level: The level of the last PTE + * + * @level also specifies the last valid index in @ptes + */ +struct arm_lpae_io_pgtable_walk_data { + u64 ptes[4]; + int level; +}; + /** * struct io_pgtable_ops - Page table manipulation API for IOMMU drivers. * * @map_pages: Map a physically contiguous range of pages of the same s= ize. * @unmap_pages: Unmap a range of virtually contiguous pages of the same = size. * @iova_to_phys: Translate iova to physical address. + * @pgtable_walk: (optional) Perform a page table walk for a given iova. * * These functions map directly onto the iommu_ops member functions with * the same names. @@ -197,6 +211,7 @@ struct io_pgtable_ops { struct iommu_iotlb_gather *gather); phys_addr_t (*iova_to_phys)(struct io_pgtable_ops *ops, unsigned long iova); + int (*pgtable_walk)(struct io_pgtable_ops *ops, unsigned long iova, void = *wd); int (*read_and_clear_dirty)(struct io_pgtable_ops *ops, unsigned long iova, size_t size, unsigned long flags, --=20 2.47.0 From nobody Mon Nov 25 08:04:07 2024 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 60EAC1E22E6; Mon, 28 Oct 2024 21:35:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151334; cv=none; b=vAIbrzYecnSwNXNHjQHPB4PZDJ3aGTH8QxfYKINgCyJFA85axhpauz81XiWT5kVTXW+ud1lRFXPs0f4UDV/Umv0BsxoBP74mVblSKfFE4cezyxsaiIyIUSSrUA+V8mGHQWIhDJp4s/wkuxvePx+fiGZsZqTNmcWpe8Gd8aqrAzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730151334; c=relaxed/simple; bh=1IW0rKnToNdG0cOCXnL5RIKthufJ6mM48jbncwAtXg0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MMf4ELuKrVA5TzmU5Nm6AQv0yp740JOvGenicoJN/cR9es8vDgP/TxAeSKgIWbi5wgGITbl2pAaV1gHIAyKgm+hMlncZXv0SClYRvA7rmyituNjOtgQryXN6Xu8DIrcAfXtddinPbwSR0n9esMOeVqJxyE0kyTCGJ4BsVI9zC64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LQNR6ss/; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LQNR6ss/" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7e6cbf6cd1dso3149150a12.3; Mon, 28 Oct 2024 14:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730151332; x=1730756132; darn=vger.kernel.org; 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=gbrqhR1uEL2jCJsm1D5FRoqkoaeXMdXad6AR8iv6QD0=; b=LQNR6ss/IkBPv+dPMG9UcVVSlhLy4AYtMTTnxPCtrKLK9IzX6jCdiqlD0XurvVZ7Q9 3WKLXHHmWf+bF8tEUuAHHhgtFKP8VwfHjFNmFcroYolOF4ojVFwY9aL06xALSMAvaaeG leSaZl/jXLTwAl8zWWfcZpBljbzWHUP2A4q7Afp9YRMI5sGoG8mpZu6qjkhV6Z2RMYZB mdQPnd6BtJGCIK63t+uYzHmMZYlvLx3neItkccjKgGG/KA0/U1MYI4rIWIS6p9SUvZ4e 8NRN7jwv97FLwVsiLHajVIilmwpHpPbYDzFJpaE9RrLmPaCWxUvQ23EfQuNh3JMLb10y NUcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730151332; x=1730756132; 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=gbrqhR1uEL2jCJsm1D5FRoqkoaeXMdXad6AR8iv6QD0=; b=f7N7vAjcVp3smhR9rI9IFJ4heGH1rbPiGTxlC9rJMuSzZU3ngNvM4ZrisWxCiy5ixf /4KayuZS9DUG7DC0p9FnvQeL6AaWQPTisp9vGeG0cRaCgD4r1AU847sMdc+l3KR2vgMA HyJBA5OFFThrWtPDXG8YGUt2aLJzXsNX+3zNRECaCWSl06ImSEHO4aDHwVC6Q4CClotg +A0eaSkthU6JKQMGnVkRxhHw6GC4tZiRLZ3VRRyNfIJzoK07BtkdDLqHcy18UWgBIcrq ZWsTO+hukqtXa4lccqbfjMnkuQgEbE13kr9KXoF/TBrR2+HtvW/Ko43IK/H2APVZEGCG b+dQ== X-Forwarded-Encrypted: i=1; AJvYcCWLZWTtqXPqtVenS9spdFLucNjhn948PjknLAMdO/eDnRsusEKyJMv1ZI5l4ZdJe9gd7mMc5BX/rf8FE/0=@vger.kernel.org X-Gm-Message-State: AOJu0YyG61C9DP3eDzxSlfcAFg9BlI0PXq9e3pKlP8OhmmHkTAdsn6nd X6KSFyi7RfBdqaJz5+Q9nggoswgDoNxvSF7F6FVzBczDMNVed0B3 X-Google-Smtp-Source: AGHT+IEysUgfIGuPwPInO/AIyu87V/JxR3clSt3EqLCfx1Mnrp45hMw1ac/uhNWRU3d43OIVEeYaaw== X-Received: by 2002:a17:90b:30d4:b0:2e2:ad11:bd36 with SMTP id 98e67ed59e1d1-2e8f11bf815mr11714777a91.37.1730151331703; Mon, 28 Oct 2024 14:35:31 -0700 (PDT) Received: from localhost ([2a00:79e1:2e00:1301:12e9:d196:a1e9:ab67]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e8e3555c71sm7863972a91.11.2024.10.28.14.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 14:35:31 -0700 (PDT) From: Rob Clark To: iommu@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Will Deacon , Robin Murphy , Mostafa Saleh , Rob Clark , Rob Clark , Sean Paul , Konrad Dybcio , Abhinav Kumar , Dmitry Baryshkov , Marijn Suijten , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org (open list:DRM DRIVER for Qualcomm Adreno GPUs), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 4/4] drm/msm: Extend gpu devcore dumps with pgtbl info Date: Mon, 28 Oct 2024 14:31:40 -0700 Message-ID: <20241028213146.238941-5-robdclark@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028213146.238941-1-robdclark@gmail.com> References: <20241028213146.238941-1-robdclark@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Rob Clark In the case of iova fault triggered devcore dumps, include additional debug information based on what we think is the current page tables, including the TTBR0 value (which should match what we have in adreno_smmu_fault_info unless things have gone horribly wrong), and the pagetable entries traversed in the process of resolving the faulting iova. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 10 ++++++++++ drivers/gpu/drm/msm/msm_gpu.c | 9 +++++++++ drivers/gpu/drm/msm/msm_gpu.h | 8 ++++++++ drivers/gpu/drm/msm/msm_iommu.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/msm/msm_mmu.h | 3 ++- 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/= adreno/adreno_gpu.c index 465a4cd14a43..b96ce6fed649 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -868,6 +868,16 @@ void adreno_show(struct msm_gpu *gpu, struct msm_gpu_s= tate *state, drm_printf(p, " - dir=3D%s\n", info->flags & IOMMU_FAULT_WRITE ? "WRITE= " : "READ"); drm_printf(p, " - type=3D%s\n", info->type); drm_printf(p, " - source=3D%s\n", info->block); + + /* Information extracted from what we think are the current + * pgtables. Hopefully the TTBR0 matches what we've extracted + * from the SMMU registers in smmu_info! + */ + drm_puts(p, "pgtable-fault-info:\n"); + drm_printf(p, " - ttbr0: %.16llx\n", (u64)info->pgtbl_ttbr0); + drm_printf(p, " - asid: %d\n", info->asid); + drm_printf(p, " - ptes: %.16llx %.16llx %.16llx %.16llx\n", + info->ptes[0], info->ptes[1], info->ptes[2], info->ptes[3]); } =20 drm_printf(p, "rbbm-status: 0x%08x\n", state->rbbm_status); diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 0d4a3744cfcb..82f204f3bb8f 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -281,6 +281,15 @@ static void msm_gpu_crashstate_capture(struct msm_gpu = *gpu, if (submit) { int i; =20 + if (state->fault_info.ttbr0) { + struct msm_gpu_fault_info *info =3D &state->fault_info; + struct msm_mmu *mmu =3D submit->aspace->mmu; + + msm_iommu_pagetable_params(mmu, &info->pgtbl_ttbr0, + &info->asid); + msm_iommu_pagetable_walk(mmu, info->iova, info->ptes); + } + state->bos =3D kcalloc(submit->nr_bos, sizeof(struct msm_gpu_state_bo), GFP_KERNEL); =20 diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 7cabc8480d7c..e25009150579 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -101,6 +101,14 @@ struct msm_gpu_fault_info { int flags; const char *type; const char *block; + + /* Information about what we think/expect is the current SMMU state, + * for example expected_ttbr0 should match smmu_info.ttbr0 which + * was read back from SMMU registers. + */ + phys_addr_t pgtbl_ttbr0; + u64 ptes[4]; + int asid; }; =20 /** diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iomm= u.c index 2a94e82316f9..3e692818ba1f 100644 --- a/drivers/gpu/drm/msm/msm_iommu.c +++ b/drivers/gpu/drm/msm/msm_iommu.c @@ -195,6 +195,28 @@ struct iommu_domain_geometry *msm_iommu_get_geometry(s= truct msm_mmu *mmu) return &iommu->domain->geometry; } =20 +int +msm_iommu_pagetable_walk(struct msm_mmu *mmu, unsigned long iova, uint64_t= ptes[4]) +{ + struct msm_iommu_pagetable *pagetable; + struct arm_lpae_io_pgtable_walk_data wd =3D {}; + + if (mmu->type !=3D MSM_MMU_IOMMU_PAGETABLE) + return -EINVAL; + + pagetable =3D to_pagetable(mmu); + + if (!pagetable->pgtbl_ops->pgtable_walk) + return -EINVAL; + + pagetable->pgtbl_ops->pgtable_walk(pagetable->pgtbl_ops, iova, &wd); + + for (int i =3D 0; i < ARRAY_SIZE(wd.ptes); i++) + ptes[i] =3D wd.ptes[i]; + + return 0; +} + static const struct msm_mmu_funcs pagetable_funcs =3D { .map =3D msm_iommu_pagetable_map, .unmap =3D msm_iommu_pagetable_unmap, diff --git a/drivers/gpu/drm/msm/msm_mmu.h b/drivers/gpu/drm/msm/msm_mmu.h index 88af4f490881..96e509bd96a6 100644 --- a/drivers/gpu/drm/msm/msm_mmu.h +++ b/drivers/gpu/drm/msm/msm_mmu.h @@ -53,7 +53,8 @@ static inline void msm_mmu_set_fault_handler(struct msm_m= mu *mmu, void *arg, struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent); =20 int msm_iommu_pagetable_params(struct msm_mmu *mmu, phys_addr_t *ttbr, - int *asid); + int *asid); +int msm_iommu_pagetable_walk(struct msm_mmu *mmu, unsigned long iova, uint= 64_t ptes[4]); struct iommu_domain_geometry *msm_iommu_get_geometry(struct msm_mmu *mmu); =20 #endif /* __MSM_MMU_H__ */ --=20 2.47.0