iommu/qcom: Index contexts by asid number to allow asid 0
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Thu, 22 Jun 2023 09:27:40 +0000 (11:27 +0200)
committerWill Deacon <will@kernel.org>
Wed, 9 Aug 2023 11:44:28 +0000 (12:44 +0100)
commitec5601661bfcdc206e6ceba1b97837e763dab1ba
tree1854fee46e7b0f9543528773dcbab2c114fa63f7
parent9f3fef23d9b5a858a6e6d5f478bb1b6b76265e76
iommu/qcom: Index contexts by asid number to allow asid 0

This driver was indexing the contexts by asid-1, which is probably
done under the assumption that the first ASID is always 1.
Unfortunately this is not always true: at least for MSM8956 and
MSM8976's GPU IOMMU, the gpu_user context's ASID number is zero.
To allow using a zero asid number, index the contexts by `asid`
instead of by `asid - 1`.

While at it, also enhance human readability by renaming the
`num_ctxs` member of struct qcom_iommu_dev to `max_asid`.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230622092742.74819-5-angelogioacchino.delregno@collabora.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu/qcom_iommu.c