From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 692E8C07E8E for ; Wed, 24 Apr 2024 09:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rtP/1HxULT9Zz6o9Fsjv+fzEdGGhkGvTG7ELmb9WKrg=; b=CxHW1K6s414TrM rS1czqQT9OypdN+Ff5FpHec7enKfSLm+w/WHUOs0o6Quhe5C2LgVGlW38UsVtXFGvZ8O54RnUohkM IkOnxTant4kag2e/gNPiqYG8hbHc0gYeeRBI8O0oPU4X6+9R36agpy/k33i8vRU/Szmifw88amjp2 IXnycXvJhGWn22Hr3cVPVyi15zCZBwITkfuyNgKxvkFktiHax/oG7jpBkPCdAI2rtdAAVhZ2UktCN mliU3rBHEWT3RRwPLH2yyEL3ZuAuFDm9cRpCJ3wceO7NzLqeahRI9Wv31CN3iJ4ngQ4emAf+3Ghnm vafJudJmqgnx/eHeMq1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzYjY-00000003Sj5-1crJ; Wed, 24 Apr 2024 09:16:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzXZV-00000003DAH-46PS for linux-arm-kernel@bombadil.infradead.org; Wed, 24 Apr 2024 08:01:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Transfer-Encoding :Content-Type:In-Reply-To:References:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=Ps3m5+BrdzHgjKJMQhrdP1zbfeVPfcB+dQAd4yhLzng=; b=XnrsMwcYnze+1yJ0fP4PSoYYi8 X1I6qF39V7tTPxPxB2WAwr/X5NqNhdLo78Tq9q+PkEybGgImGEupsMvV/V02NN6ScsTjMn7zGgyNB aJJeMIFq1LJ+bmD2rBMhSWO4s/ILDkHW4tRaqzu6D/Pm7M1yF9Q0WuvhgsmUZYWBPfDEa0X4fg11b F2OInCmKMR9UO+rWvW+WLTsuy6+qBPBYoBPHvqApQ2lP0kprmBJlcoYG5AQVO9dePo+2DmQDWfnQ7 pKyJY66CfzeJfwIjAS72C71FJ9we5+v4UcBOVQl5HKjkLp+9lnhI+nUF0xb+QfF+s7qxwd1jyB87O /6v7oo7Q==; Received: from szxga08-in.huawei.com ([45.249.212.255]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzXZI-0000000EJts-22L2 for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2024 08:01:40 +0000 Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VPWZ44Qssz1R5S9; Wed, 24 Apr 2024 15:58:04 +0800 (CST) Received: from dggems706-chm.china.huawei.com (unknown [10.3.19.183]) by mail.maildlp.com (Postfix) with ESMTPS id 0496114040F; Wed, 24 Apr 2024 16:01:06 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 24 Apr 2024 16:01:04 +0800 Received: from lhrpeml500005.china.huawei.com ([7.191.163.240]) by lhrpeml500005.china.huawei.com ([7.191.163.240]) with mapi id 15.01.2507.035; Wed, 24 Apr 2024 09:01:02 +0100 From: Shameerali Kolothum Thodi To: Ryan Roberts , "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" CC: "joro@8bytes.org" , "jgg@nvidia.com" , "kevin.tian@intel.com" , "nicolinc@nvidia.com" , "mshavit@google.com" , "robin.murphy@arm.com" , "will@kernel.org" , "joao.m.martins@oracle.com" , jiangkunkun , zhukeqian , Linuxarm Subject: RE: [PATCH v2 1/4] iommu/arm-smmu-v3: Add feature detection for HTTU Thread-Topic: [PATCH v2 1/4] iommu/arm-smmu-v3: Add feature detection for HTTU Thread-Index: AQHaZXTEskP344GHbEaXPEKyEBg1Q7F2PPsAgAEicXA= Date: Wed, 24 Apr 2024 08:01:02 +0000 Message-ID: References: <20240222094923.33104-1-shameerali.kolothum.thodi@huawei.com> <20240222094923.33104-2-shameerali.kolothum.thodi@huawei.com> <3733929c-657e-4d24-b5e9-a5d946645abe@arm.com> In-Reply-To: <3733929c-657e-4d24-b5e9-a5d946645abe@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.28] MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240424_090129_533342_A35D188A X-CRM114-Status: GOOD ( 32.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, > -----Original Message----- > From: Ryan Roberts > Sent: Tuesday, April 23, 2024 3:42 PM > To: Shameerali Kolothum Thodi ; > iommu@lists.linux.dev; linux-arm-kernel@lists.infradead.org > Cc: joro@8bytes.org; jgg@nvidia.com; kevin.tian@intel.com; > nicolinc@nvidia.com; mshavit@google.com; robin.murphy@arm.com; > will@kernel.org; joao.m.martins@oracle.com; jiangkunkun > ; zhukeqian ; > Linuxarm > Subject: Re: [PATCH v2 1/4] iommu/arm-smmu-v3: Add feature detection for > HTTU > > Hi, > > I'm aiming to (slowly) get more involved with SMMU activities, although I'm > sure > it will take a while to get up to speed and provide useful input. It was > suggested that this series would be a useful starting point to dip my toe in. > Please bear with me while I ask stupid questions... Thanks for going through the series. I am planning to respin this one soon, once Jason's SMMUv3 refactor series in some good form. > > > On 22/02/2024 09:49, Shameer Kolothum wrote: > > From: Jean-Philippe Brucker > > > > If the SMMU supports it and the kernel was built with HTTU support, > > Probe support for Hardware Translation Table Update (HTTU) which is > > essentially to enable hardware update of access and dirty flags. > > > > Probe and set the smmu::features for Hardware Dirty and Hardware Access > > bits. This is in preparation, to enable it on the context descriptors of > > stage 1 format. > > > > Signed-off-by: Jean-Philippe Brucker > > Signed-off-by: Joao Martins > > Reviewed-by: Jason Gunthorpe > > Signed-off-by: Shameer Kolothum > > > Except for the nit (feel free to ignore it), LGTM! > > Reviewed-by: Ryan Roberts > > > > --- > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 32 > +++++++++++++++++++++ > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 ++++ > > 2 files changed, 37 insertions(+) > > > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > index 0606166a8781..bd30739e3588 100644 > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > @@ -4196,6 +4196,28 @@ static void arm_smmu_device_iidr_probe(struct > arm_smmu_device *smmu) > > } > > } > > > > +static void arm_smmu_get_httu(struct arm_smmu_device *smmu, u32 > reg) > > +{ > > + u32 fw_features = smmu->features & (ARM_SMMU_FEAT_HA | > ARM_SMMU_FEAT_HD); > > + u32 features = 0; > > + > > + switch (FIELD_GET(IDR0_HTTU, reg)) { > > + case IDR0_HTTU_ACCESS_DIRTY: > > + features |= ARM_SMMU_FEAT_HD; > > + fallthrough; > > + case IDR0_HTTU_ACCESS: > > + features |= ARM_SMMU_FEAT_HA; > > + } > > + > > + if (smmu->dev->of_node) > > + smmu->features |= features; > > + else if (features != fw_features) > > + /* ACPI IORT sets the HTTU bits */ > > + dev_warn(smmu->dev, > > + "IDR0.HTTU overridden by FW configuration > (0x%x)\n", > > + fw_features); > > +} > > + > > static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) > > { > > u32 reg; > > @@ -4256,6 +4278,8 @@ static int arm_smmu_device_hw_probe(struct > arm_smmu_device *smmu) > > smmu->features |= ARM_SMMU_FEAT_E2H; > > } > > > > + arm_smmu_get_httu(smmu, reg); > > + > > /* > > * The coherency feature as set by FW is used in preference to the ID > > * register, but warn on mismatch. > > @@ -4448,6 +4472,14 @@ static int arm_smmu_device_acpi_probe(struct > platform_device *pdev, > > if (iort_smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE) > > smmu->features |= ARM_SMMU_FEAT_COHERENCY; > > > > + switch (FIELD_GET(ACPI_IORT_SMMU_V3_HTTU_OVERRIDE, > iort_smmu->flags)) { > > + case IDR0_HTTU_ACCESS_DIRTY: > > + smmu->features |= ARM_SMMU_FEAT_HD; > > + fallthrough; > > + case IDR0_HTTU_ACCESS: > > + smmu->features |= ARM_SMMU_FEAT_HA; > > + } > > + > > return 0; > > } > > #else > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > > index 45bcd72fcda4..5e51a6c1d55f 100644 > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > > @@ -33,6 +33,9 @@ > > #define IDR0_ASID16 (1 << 12) > > #define IDR0_ATS (1 << 10) > > #define IDR0_HYP (1 << 9) > > +#define IDR0_HTTU GENMASK(7, 6) > > +#define IDR0_HTTU_ACCESS 1 > > +#define IDR0_HTTU_ACCESS_DIRTY 2 > > #define IDR0_COHACC (1 << 4) > > #define IDR0_TTF GENMASK(3, 2) > > #define IDR0_TTF_AARCH64 2 > > @@ -668,6 +671,8 @@ struct arm_smmu_device { > > #define ARM_SMMU_FEAT_SVA (1 << 17) > > #define ARM_SMMU_FEAT_E2H (1 << 18) > > #define ARM_SMMU_FEAT_NESTING (1 << 19) > > +#define ARM_SMMU_FEAT_HA (1 << 20) > > +#define ARM_SMMU_FEAT_HD (1 << 21) > > nit: HA and HD are a bit opaque, at least to me. I guess they are HW Access > and > HW Dirty? Perhaps ARM_SMMU_FEAT_HW_ACCESS and > ARM_SMMU_FEAT_HW_DIRTY are more > expressive? Nothing against it. Just that _HW_ is not used in driver anywhere(AFAICS) and HA/HD are used in the specification. How about we rename to ARM_SMMU_FEAT_HTTU_HA and ARM_SMMU_FEAT_HTTU_HA? Thanks, Shameer > > > u32 features; > > > > #define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0) > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel