From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 87D733B1EEE for ; Wed, 26 Aug 2026 09:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787737468; cv=none; b=TOszMfHmy9LQKos67W31ZYK0FRC3Ck4sJ0B8jaJhA+cQj2OWhTQrGju4baxHCT3I9uy+n8PJMVtopN/WpU4wXZyxy4E7UWg9MFxSnozdUwtuv+IGGmJkm4O0nEZr6VWfv+lS8gMWZhPGWMrHk33nsV4kU/4nTpuOTr6HUfi2Op0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787737468; c=relaxed/simple; bh=9GuDmecgyVvxCQJOyCXGHOjgfhqUN7ivkB/e7B/dl2g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sIoHftEXumsccOPAuONlbrRqKG6/1kpA14JFmmoFtevCtgJiq2YmhqtMdS6gbHwOnnuaLsjkZv0w6EuZQGxmXhDuuEJReK/9jJGvK9OWpU10Y234erpL70oThb/gcU3AbM/G9gsJr4YNL0l5Y/XmoCJwdfLWFbh/HNpSDf/OJhI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lGllCmuq; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lGllCmuq" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-499b1409a75so35845e9.1 for ; Wed, 26 Aug 2026 02:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787737465; x=1788342265; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=DCpGxFqreLjSVtJ1Gq5kxQUJHIsXo7AfwLCjemfnd9c=; b=lGllCmuqf8RHVOFUa6O0AmF6kr1RNeZsxEqHKsC3s8MGV6Pc4GaS1dnfHN+xxLvfa6 bSYsDEpcpDDCPaw/FNpgGVS+3wqBP0uYIxZcYsTCy12tkTSYkvJbZBE2uNCLr3ziBM9k fNrFh+9TTCPIGpcFTcu06toThBwiZwQjPwwGnNaLYHE3sT1ZoN0RbY8Qlt5iuZJM0auF sRk1jSJCzaj1qcu1GnzY7bz/mZoirAxu3i6RQk/kNyGfHzNrqsJwKt+3Jl6lgqEsAxCf hVEl8nqrUbEmxO4fGz07T72hD3vHR8dryMOW8Eh2tPOvsj/wwuLA4sKqvAeOM2irYW9e fbyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787737465; x=1788342265; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DCpGxFqreLjSVtJ1Gq5kxQUJHIsXo7AfwLCjemfnd9c=; b=CJLVGkGiG4TE2HODxjxKYXGC7a4wgOy0vk8zybONaXySBn9DW7dMXWYONn1vtz+gb9 +y/gkD4Yhf21+HoVRL645qDy7p9pRjhVp+R6qpwZivFxuI695+i8ZdEwmnoXCfu3E3sh aVImdHLMMP+AJ21dAyCpdN0rTo4zfsx4KoInyGODslmYq15NRbUxKxB5By44udLDlgxB XiEhvfyhyZqq6TLaOIzDxvNVfDc8O2S5Y+rhZme2uIGK4I+5qwyYOtryPucLaMuWsKSF BvsYeAXHpMqe/scLDudgCSpAhFpHzAUw4miFYn0fiQ2kHEp/vUoiQnJLNDvx1G2t5fW5 mrHQ== X-Forwarded-Encrypted: i=1; AHgh+Rra9G7oz4crPSj3k4/kqszt2vIY+o+mbCyNMcK4wBoeIu297njYJ3c1GmZ1njKl0jEjv6kZFi1Zq1zxX9U=@vger.kernel.org X-Gm-Message-State: AFuF++ko6odVbw6TIPYvGSP4GP6W1ewxi22yVO6qGsg+nDYab9UbNe9+ PPKvEkrZnulE3wVPV0eu+yHKgP+t8HDidqefCqJJPur83k1SZjYeO/zuDBWx3aaNlS/WxQ3hg3b 5MN138Q== X-Gm-Gg: AR+sD10KuJjcTBAgNn1x2wBGofZUvZqyUmI/9DMkdXM3iVPK3mw8/HNZmiuddtt6Qn6 Q1YeCvRlmGhVVf6Acg9Zl1u/THwLFX2LCjIXnQXP3Qk7js8xhLg3Ao/dN7YQ48SQAQN4VQMIhK/ QCfo7ZKJ2+aKxeheCzWEivl4Ne5+1q+16tosIm9DuTFce3IKnj+a19K6wLe5gO20yikUA4OLhua tLMnZyNWXW2rIzBZEUyGNw2C+MakzhsaSQXx/aik0b8UxuXv8SCTDTaQaFT7wQ3XUj64s6TkgLh aKBRVr4ZdvGqylX5cfDY2eXyVPSdiKT3/0u3YGsXn2/Wble7HxO9lFmu/Q490245kFV3lw5o4ks AM/vbWgZ9MlFBFz47MCkM44EQXQJ6a4EkEwwnjOb5lKr0S5fCqF5LCEhVA8sWdlCqvoss6zP3MV boTGw/yxvQBOpQYf5jZxUvrbgp7j0/cdUBMU5FA7gyaSvrfSOPD4mOEGcn5RNE8i9IWwqU7mAy/ bNV3QDI/97MOuzenmoGs5EsqEtJVw== X-Received: by 2002:a05:600c:6085:b0:48a:623c:8859 with SMTP id 5b1f17b1804b1-499dda23078mr651695e9.7.1787737464409; Wed, 26 Aug 2026 02:44:24 -0700 (PDT) Received: from google.com (250.192.189.35.bc.googleusercontent.com. [35.189.192.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499dca8c75csm20805035e9.2.2026.08.26.02.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 02:44:23 -0700 (PDT) Date: Wed, 26 Aug 2026 09:44:20 +0000 From: Mostafa Saleh To: Jason Gunthorpe Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, joro@8bytes.org, jgg@ziepe.ca, mark.rutland@arm.com, qperret@google.com, tabba@google.com, vdonnefort@google.com, sebastianene@google.com, keirf@google.com Subject: Re: [PATCH v7 05/24] iommu/arm-smmu-v3: Move IDR parsing to common functions Message-ID: References: <20260715115906.2664882-1-smostafa@google.com> <20260715115906.2664882-6-smostafa@google.com> <178769159057.3356902.8176677714818911833.b4-review@b4> 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=us-ascii Content-Disposition: inline In-Reply-To: <178769159057.3356902.8176677714818911833.b4-review@b4> On Tue, Aug 25, 2026 at 05:59:50PM -0300, Jason Gunthorpe wrote: > > [ ... 21 lines skipped ... ] > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-common-lib.c > > @@ -0,0 +1,184 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (C) 2015 ARM Limited > > + * > > + * Author: Will Deacon > > + * Arm SMMUv3 driver functions shared with hypervisor. > > + */ > > + > > +#include "arm-smmu-v3.h" > > +#include > > + > > +#include > > + > > +u32 smmu_idr0_features(u32 reg) > > +{ > > I think you should do more to make this shared C file usable by both > compiles with more of the infrastructure available. > > For instance, something like this at the top: > > #ifdef __KVM_NVHE_HYPERVISOR__ > #include "pkvm/arm_smmu_v3.h" > #define arm_smmu_device hyp_arm_smmu_v3_device > #else > #include "arm-smmu-v3.h" > #endif > > (heh you used _ and the driver uses - in file names) Yes, that's a bit ugly, I can rename it to arm-smmu-v3-hyp.h > > Then the existing code using 'arm_smmu_device' just works fine since > the hyp version has the same structure members. Now just move the code > as-is. > > Otherwise we still have alot of cut and paste duplication: > > reg = readl_relaxed(smmu->base + ARM_SMMU_IDR0); > > smmu->features |= smmu_idr0_features(reg); > if (!(smmu->features & (ARM_SMMU_FEAT_TT_LE | ARM_SMMU_FEAT_TT_BE))) { > dev_err(smmu->dev, "unknown/unsupported TT endianness!\n"); > return -ENXIO; > } > > vs > > reg = readl_relaxed(smmu->base + ARM_SMMU_IDR0); > > smmu->features |= smmu_idr0_features(reg); > if (!(smmu->features & (ARM_SMMU_FEAT_TT_LE | ARM_SMMU_FEAT_TT_BE))) > return -ENXIO; I am not sure I get this, the only difference is the printk? We can do more with that, but as discussed last time, I am worried that re-defining structs using macros just makes things harder for maintenance and more fragile to changes, causing build failures, and mismatch in types between the 2 structs. I can experiment with that when working on the next version and see if the there is significant benefits. Thanks, Mostafa > > Then you can put the prior patches tlbi stuff here instead of the > header file, which is important because after I get the CONT and > errata stuff worked in it becomes really quite big. > > -- > Jason