Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp311363lqb; Tue, 4 Jun 2024 12:04:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDp5LxKcmT9aVJOweuugWkwJKY5f7Tm4U1JDxpd8C9PxPID5U8nJIxb69TEj+2kmxDScrqSpLpIuteIGuTfwvUyX6BlXPIYBaW3bdF2Q== X-Google-Smtp-Source: AGHT+IHSoY6KRqqf2SEHLsxuvZU7aUGhPwTjeZ6aW9NIqcOe2EFJz05f99sFwesGZ9Uyrajqu22c X-Received: by 2002:a05:6a21:614:b0:1b2:aa82:4b34 with SMTP id adf61e73a8af0-1b2b718928bmr486504637.57.1717527862123; Tue, 04 Jun 2024 12:04:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717527862; cv=pass; d=google.com; s=arc-20160816; b=JUaRO+iDqzi449pwOuHQNhH+KV09TPGzedvn5bpxTK1MmjFiS5lTaZwwmZ2QH4HLzP ZfxciTJJ6LNVJNNbuhhXgKdUW/FqLjnZDTthvUKa/F5AgfV4nQa1KlxsMAnROSGvgiQU u72QR3PKmD/T40FzSXnwnfxgVUz/zG1Id7OrNQqBfdPxM7Djmv7jLVBj4nIeS0HYL8jN sfkfBkub5ANZoZD9RLLOsmmL1faklo5/HfNDBH60ZHUFi8u4b5TSnZG9smX2d+5awDjE Us9OmhkLf89RTlcw6ID8WzSayr1C4osHoMupTtwD+e9bUlvqzmYMwPkeujwTqExQ7Je+ mYHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Bb27sFgRlG0Tk9BuaJtsYRuhNJ3jYbY3tEhCWfnKOSg=; fh=28QgZzyhDuAd3QZOKe2JvHdEtHQx89F1rvXUa7rjccg=; b=ZPI6fWA1MRmsBCgK7/dVCu69Ofwb4yUIx7OioDAeKTM8L5qZ4STSwDXckVS9vTNpUU kP5uOPsAYdyP59xqVGmltqInVLlHL0uWVxAfbgG8osMeqBwPAh1rlx1fvVOmwCVRy6Ed qPzZRZu6Cyisw+St9KVdPS58XSlcgvuJT7P8E/yXsG8qFf9Nb3GN4MuUgxIjm8abnzwo Z3Ef+cRiJLrfxmG52+zT9tTGatYeX6wCCSokhEwTrhTzLA6w+2xBoTfkvk+AfpEYX9TI mwIoPP3+pelKKWl//GuBtDYYE+UVdrOlk3GSKsJcpUhSTuHh9vBZG8s0xlOeOFX6WAX0 zulw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MTXX0GZD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-201253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-70242e64198si1068071b3a.391.2024.06.04.12.04.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:04:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MTXX0GZD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-201253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EF834B24E74 for ; Tue, 4 Jun 2024 18:49:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE89714A4D9; Tue, 4 Jun 2024 18:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MTXX0GZD" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.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 445C218028; Tue, 4 Jun 2024 18:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717526968; cv=none; b=d9NUBy37eQGVe8wedFjhXu9/415zDsnYMoGDwDGt90/3Gf9MVEuHa2BWTh0IQ6txw444eYlgXFOeA+zBbgNazdDb0WZcV+WXBe7kUlchEQT0UAh7MCrmx9MESJOCbrNRUHEHfGCvKuMf4+7lMdY6Kj9YDmz4RaEJ6dW6R4m+Zj4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717526968; c=relaxed/simple; bh=a1zun8HL6lepv1ujLISq6+xEZ0ZnO4qy/lSJiqqhavo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CmCP2fONInsC6xeyjUvbYM397GES5HFBNZfZNii5ju16yeireA3yk8+3zBN59xxyKv7A5nFst+ATg0rVQ1n2/q3QvnFmMqrzW4Is4VqozVwc/qfVynTga+FovajDKwNJaSaIsVdhukKGv1qqODgMX6zDBvxnjUlFHa3Ss+tktZk= 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=MTXX0GZD; arc=none smtp.client-ip=209.85.208.43 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 Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-572c65cea55so230848a12.0; Tue, 04 Jun 2024 11:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717526966; x=1718131766; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Bb27sFgRlG0Tk9BuaJtsYRuhNJ3jYbY3tEhCWfnKOSg=; b=MTXX0GZDZta/N8f78Syfoxt7FmPFFY9lurDnHtuvlz/LzOtd6tMN6gLVDzfljOk6f/ tyDoYVDP6BlWYSQ/nOYEXdSwHoZJOggEFQ4QC+HuS21K96qNma8gKBABIhWwSFO5Vn7a ppM6tGmRaOPstF/qpIQn4XZQ9tIuxp0TZlQHsM9jTGJUR9hoE7+R7dVeg2yed6JLJYO9 Z98tE8K+f/ed7TUuJOb4URynwsTkFLtlV/G3R778RuWkkRE8o/MLWinPYn+t6jB41A55 YvpR4x/IO2UPEH/MeG03SqALsHofpssYp+RWLfPkhNr4RLCKNX65qbFL6Cj6jX3Q0Cyt PU+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717526966; x=1718131766; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bb27sFgRlG0Tk9BuaJtsYRuhNJ3jYbY3tEhCWfnKOSg=; b=HNGKUeRgg4tycRdoqB4dtz/VJiKkle5YLenZ1PxiCVPD+mdXng/Te4iuWxZjDnYG/S kLoGiyKwBvUaSPkM1SB4OD3SkUEyg+4aUX9JGlpt4dVCDMCuMv98rgJSHA/Oq5SKYLNU G1gAl8+/VMN3qaYGqPliqKtUMt1qXqqsDm4Ws+3HCxhXWkI12+L9SGOsiQLo3kJGOA3a 3D+fjekOCb6dyzve/ELPw08/vQrZyaVnGEgs2QihDO7b4MjoEXovSk4zydpv96IRl9wG esb65ejYmIjguxhkxxHEkLgYKT7uHD3jLJJuiRDYhWD8EXt/k0oNQVjm74NK5zztTtdG KxUg== X-Forwarded-Encrypted: i=1; AJvYcCXWO+arFEkNzPZXCESGs5SNTgxIX6M6Z0aF+hmcIRSNBWNZePWCcKN105fu4SUlTMSUiyBO95WlIbS59sYowvxna4OxDuqNkR9wL6vXEFR3HMN8TgAVP/9spp70xfzFfpGW96PsZ0nqbwyWAw== X-Gm-Message-State: AOJu0YxFCfedSqOMLWInXKDvrBZMjOO3ssgqKl1ou3oeSbTZCeVzM4X2 JCgymRaUSHrRxmOOOSxSvWtJKwahvZC5KQ/1+ZutTBnm/q0uy330BakzAlgZQ4j+tlB4NNTPUfC 3857f7tSIqparAO/qVcijCPm+rbs= X-Received: by 2002:a50:8a92:0:b0:574:ec3d:262a with SMTP id 4fb4d7f45d1cf-57a8b6a4d4emr430003a12.5.1717526965479; Tue, 04 Jun 2024 11:49:25 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240123144543.9405-1-quic_bibekkum@quicinc.com> <20240123144543.9405-4-quic_bibekkum@quicinc.com> <51b2bd40-888d-4ee4-956f-c5239c5be9e9@linaro.org> <0a867cd1-8d99-495e-ae7e-a097fc9c00e9@quicinc.com> <7140cdb8-eda4-4dcd-b5e3-c4acdd01befb@linaro.org> <9992067e-51c5-4a55-8d66-55a102a001b6@quicinc.com> In-Reply-To: <9992067e-51c5-4a55-8d66-55a102a001b6@quicinc.com> From: Rob Clark Date: Tue, 4 Jun 2024 11:49:13 -0700 Message-ID: Subject: Re: [PATCH v9 3/5] iommu/arm-smmu: introduction of ACTLR for custom prefetcher settings To: Bibek Kumar Patro Cc: Dmitry Baryshkov , Konrad Dybcio , will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, jsnitsel@redhat.com, quic_bjorande@quicinc.com, mani@kernel.org, quic_eberman@quicinc.com, robdclark@chromium.org, u.kleine-koenig@pengutronix.de, robh@kernel.org, vladimir.oltean@nxp.com, quic_pkondeti@quicinc.com, quic_molvera@quicinc.com, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 30, 2024 at 2:22=E2=80=AFAM Bibek Kumar Patro wrote: > > > > On 5/28/2024 9:38 PM, Rob Clark wrote: > > On Tue, May 28, 2024 at 6:06=E2=80=AFAM Dmitry Baryshkov > > wrote: > >> > >> On Tue, May 28, 2024 at 02:59:51PM +0200, Konrad Dybcio wrote: > >>> > >>> > >>> On 5/15/24 15:59, Bibek Kumar Patro wrote: > >>>> > >>>> > >>>> On 5/10/2024 6:32 PM, Konrad Dybcio wrote: > >>>>> On 10.05.2024 2:52 PM, Bibek Kumar Patro wrote: > >>>>>> > >>>>>> > >>>>>> On 5/1/2024 12:30 AM, Rob Clark wrote: > >>>>>>> On Tue, Jan 23, 2024 at 7:00=E2=80=AFAM Bibek Kumar Patro > >>>>>>> wrote: > >>>>>>>> > >>>>>>>> Currently in Qualcomm SoCs the default prefetch is set to 1 whi= ch allows > >>>>>>>> the TLB to fetch just the next page table. MMU-500 features ACTL= R > >>>>>>>> register which is implementation defined and is used for Qualcom= m SoCs > >>>>>>>> to have a custom prefetch setting enabling TLB to prefetch the n= ext set > >>>>>>>> of page tables accordingly allowing for faster translations. > >>>>>>>> > >>>>>>>> ACTLR value is unique for each SMR (Stream matching register) an= d stored > >>>>>>>> in a pre-populated table. This value is set to the register duri= ng > >>>>>>>> context bank initialisation. > >>>>>>>> > >>>>>>>> Signed-off-by: Bibek Kumar Patro > >>>>>>>> --- > >>>>> > >>>>> [...] > >>>>> > >>>>>>>> + > >>>>>>>> + for_each_cfg_sme(cfg, fwspec, j, idx) { > >>>>>>>> + smr =3D &smmu->smrs[idx]; > >>>>>>>> + if (smr_is_subset(smr, id, mask)) { > >>>>>>>> + arm_smmu_cb_write(smmu, cbndx, A= RM_SMMU_CB_ACTLR, > >>>>>>>> + actlrcfg[i].actl= r); > >>>>>>> > >>>>>>> So, this makes ACTLR look like kind of a FIFO. But I'm looking a= t > >>>>>>> downstream kgsl's PRR thing (which we'll need to implement vulkan > >>>>>>> sparse residency), and it appears to be wanting to set BIT(5) in = ACTLR > >>>>>>> to enable PRR. > >>>>>>> > >>>>>>> val =3D KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_ACT= LR); > >>>>>>> val |=3D FIELD_PREP(KGSL_IOMMU_ACTLR_PRR_ENABLE, 1); > >>>>>>> KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_ACTLR, val)= ; > >>>>>>> > >>>>>>> Any idea how this works? And does it need to be done before or a= fter > >>>>>>> the ACTLR programming done in this patch? > >>>>>>> > >>>>>>> BR, > >>>>>>> -R > >>>>>>> > >>>>>> > >>>>>> Hi Rob, > >>>>>> > >>>>>> Can you please help provide some more clarification on the FIFO pa= rt? By FIFO are you referring to the storing of ACTLR data in the table? > >>>>>> > >>>>>> Thanks for pointing to the downstream implementation of kgsl drive= r for > >>>>>> the PRR bit. Since kgsl driver is already handling this PRR bit's > >>>>>> setting, this makes setting the PRR BIT(5) by SMMU driver redundan= t. > >>>>> > >>>>> The kgsl driver is not present upstream. > >>>>> > >>>> > >>>> Right kgsl is not present upstream, it would be better to avoid conf= iguring the PRR bit and can be handled by kgsl directly in downstream. > >>> > >>> No! Upstream is not a dumping ground to reduce your technical debt. > >>> > >>> There is no kgsl driver upstream, so this ought to be handled here, i= n > >>> the iommu driver (as poking at hardware A from driver B is usually no= t good > >>> practice). > >> > >> I'd second the request here. If another driver has to control the > >> behaviour of another driver, please add corresponding API for that. > > > > We have adreno_smmu_priv for this purpose ;-) > > > > Thanks Rob for pointing to this private interface structure between smmu > and gpu. I think it's similar to what you're trying to implement here > https://lore.kernel.org/all/CAF6AEGtm-KweFdMFvahH1pWmpOq7dW_p0Xe_13aHGWt0= jSbg8w@mail.gmail.com/#t > I can add an api "set_actlr_prr()" with smmu_domain cookie, page pointer > as two parameters. This api then can be used by drm/msm driver to carry > out the prr implementation by simply calling this. > Would this be okay Rob,Konrad,Dmitry? > Let me know if any other suggestions you have in mind as well regarding > parameters and placement. Hey Bibek, quick question.. is ACTLR preserved across a suspend/resume cycle? Or does it need to be reprogrammed on resume? And same question for these two PRR related regs: /* Global SMMU register offsets */ #define KGSL_IOMMU_PRR_CFG_LADDR 0x6008 #define KGSL_IOMMU_PRR_CFG_UADDR 0x600c (ie. high/low 32b of the PRR page) I was starting to type up a patch to add PRR configuration, but depending on whether it interacts with suspend/resume, it might be better form arm-smmu-qcom.c to just always enable and configure PRR (including allocating a page to have an address to program into PRR_CFG_LADDR/UADDR), and instead add an interface to return the PRR page? I think there is no harm in unconditionally configuring PRR for gpu smmu. BR, -R > Thanks & regards, > Bibek > > > BR, > > -R > > > >>> > >>>> > >>>>>> Thanks for bringing up this point. > >>>>>> I will send v10 patch series removing this BIT(5) setting from the= ACTLR > >>>>>> table. > >>>>> > >>>>> I think it's generally saner to configure the SMMU from the SMMU dr= iver.. > >>>> > >>>> Yes, agree on this. But since PRR bit is not directly related to SMM= U > >>>> configuration so I think it would be better to remove this PRR bit > >>>> setting from SMMU driver based on my understanding. > >>> > >>> Why is it not related? We still don't know what it does. > >>> > >>> Konrad > >> > >> -- > >> With best wishes > >> Dmitry