From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.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 A981E4418E2 for ; Tue, 5 May 2026 16:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777999700; cv=none; b=bXgaN2Q4bpppOcRxLUPHWnbpUZ/mjA4JK03BMDuIr/+XJLH2WQi/MxB+7K6/9TLbORhsiaTAAGpmmR0PIZt5IArng6HsO9bkkohI72K362fb7tSyRGMqt846o2Y3rmBGrgmyM5JYypwi6zDTIeaNE/OLD1o8b8ikubVkDMyi8Xc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777999700; c=relaxed/simple; bh=HZDV9B9whj7jMOnAALU0NHlqzHm0TKcc03SszyoLCcw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GoIdBy1bDKVv0+Ip/XHh2cOyMMB2fbFMX8ys8spsIWWX4CMpUAkL1Q1eAl6Vv0/Jz0pSoNAyJdbRwnOweXnY9Itcp5zkFeODrhrG0OdrilWZUPh7H/LsuBaU3Vn9QQlmPzJQY1Z6iqDuT2rY+q6wZqOcRhL+/LulW/gq02gl3Tw= 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=cDlyWj4a; arc=none smtp.client-ip=209.85.160.170 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="cDlyWj4a" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-50e61648f10so8271cf.1 for ; Tue, 05 May 2026 09:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777999698; x=1778604498; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Vp5iopfAmcsOX6ZIRTEf038gXmebvITcztxNgxO/nOk=; b=cDlyWj4ao/4JrT226FiqFs5z2R/fdlp0v5yvB1RMsK8Ax5k4NWizf9NDoM9AZI7DuN EMFN4LHpBChC61sYllTY0Gsu6f75aMGYtJMqDCbHb8GXLLweWdJrfDJ1Q257U23Rpjgg 1LUjbPrqoKCrNhMMTtXNZ/fukz2U/2kBqQCLPqNxTXizJQ0tTP/IeYut3lQ+Mau7Q8Z4 h89i5ceHgLd6WxIwD3tWdmXbG2H3w38D2ghhw5CZNWbXgHb9DK4RLTmcdHm/Xegps8ks zXZBoeVqKzrHogpNobLiDR11XKFiI4IMkWWP1xF/70rkeCJzN1QGjb4Ukik2e5jjM+qE N2hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777999698; x=1778604498; h=in-reply-to:content-transfer-encoding:content-disposition :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; bh=Vp5iopfAmcsOX6ZIRTEf038gXmebvITcztxNgxO/nOk=; b=qIu6SgiXxU2NPGYRVTLko9IefVgbHiJLMHJvyMIBiDtkkZsuTaBsM2cVw5kguKse5q 7IQ2FlJo+HjkbdtkOzxTTjoVP76fu1NY7K6rqmjJpgTaH6/qzv15O5gEbdmDlnGUr3kA n+8DSsYNcvt2dZeJdVfGrOEQny4YSuaOtTWVEOGx/t3t2i4qwcHS5J4wjVTpFEv8M92p 4NuSC6VUsnVDVYJwqed66XV6kVxEq1Cw5aGp81BEZahw1uSJ6yZ2ESa39fMiT9GyqQvL iiL4/GMMyN0lq4draGIWoM9YvWm4SYottPvV6IMtzj4/rZK7H8mJCSm0Dik+HcbVLUFV 4riw== X-Forwarded-Encrypted: i=1; AFNElJ/Ot1KSO4l0hvIbLhiPaPRb++VWA7KRdFvBRiMLWuLM2q89uc2cePHzWQq59DOWg+IbdzzcpAQYRYF/8sU=@vger.kernel.org X-Gm-Message-State: AOJu0YxlJzW4mfdPkLbzlP0SFJGaYufy8FkKHoAEPZUMiOaGD+MPvmPW VkxQfHx5ylXh7anUFiVwc898TZTPST2mlDvybdzDcEZwBplB5dYK+7uBJTW9XvPqHA== X-Gm-Gg: AeBDiev6F+Mllt0aDn7LCfVxVK7Efez5x5JqhE8A4FvrUqWxxzKK7fzpf4WEK/KFqJZ gLYCLfsuvzSKeQPpV4u3TwE0B2qsso++/HLZ3VZZb3hYx+4UsMrvUardKNqVTuw1oolJyavx3Vh D0oiv/C5fFOtz/PPzaOlnb0mQPCYxk8qzpXLK/huMDrv0NbGtwXykSIBdnaqdBbcYQdLyH1irdV kVLLOkY8trVxYw9a0DH1s1J5959GP39cyZV96hgFzKlbyLuedmLQP3tAcH998Q6mMG2Fr7ndfNW QI3Hagm36QULN7lvNqvnOW9YQoVaIDRj4hb4J3QJCRC+9XfbybUJj73Q6/Rz2w9E0kidrj1HYZO oEvO/LnGHASnTUUMdI6nXH8IXWPTG6y5TgNTLQspQ40aPZN28NFGYAlTDEThveY/6YAkjIS5k/l a/Kv0346FBeYSBT2wFnoILn6cKVVL7K1KPsWarwfs4iuNiMby/N4uRPs4Hojuk4+Gzr1+f4foDC egjrQ== X-Received: by 2002:a05:622a:8310:b0:509:15b6:f6a0 with SMTP id d75a77b69052e-51305908cf9mr15393051cf.6.1777999697103; Tue, 05 May 2026 09:48:17 -0700 (PDT) Received: from google.com (8.181.38.34.bc.googleusercontent.com. [34.38.181.8]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8fc29c6fa7asm1340531885a.20.2026.05.05.09.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 09:48:16 -0700 (PDT) Date: Tue, 5 May 2026 16:48:08 +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, jean-philippe@linaro.org, mark.rutland@arm.com, qperret@google.com, tabba@google.com, vdonnefort@google.com, sebastianene@google.com, keirf@google.com Subject: Re: [PATCH v6 05/25] iommu/arm-smmu-v3: Move IDR parsing to common functions Message-ID: References: <20260501111928.259252-1-smostafa@google.com> <20260501111928.259252-6-smostafa@google.com> <20260501124716.GD6912@ziepe.ca> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, May 05, 2026 at 01:27:45PM -0300, Jason Gunthorpe wrote: > On Mon, May 04, 2026 at 12:16:13PM +0000, Mostafa Saleh wrote: > > On Fri, May 01, 2026 at 09:47:16AM -0300, Jason Gunthorpe wrote: > > > On Fri, May 01, 2026 at 11:19:07AM +0000, Mostafa Saleh wrote: > > > > Move parsing of IDRs to functions so that it can be re-used > > > > +unsigned long smmu_idr5_to_pgsize(u32 reg) > > > > +{ > > > > + unsigned long pgsize_bitmap = 0; > > > > + > > > > + if (reg & IDR5_GRAN64K) > > > > + pgsize_bitmap |= SZ_64K | SZ_512M; > > > > + if (reg & IDR5_GRAN16K) > > > > + pgsize_bitmap |= SZ_16K | SZ_32M; > > > > + if (reg & IDR5_GRAN4K) > > > > + pgsize_bitmap |= SZ_4K | SZ_2M | SZ_1G; > > > > + return pgsize_bitmap; > > > > +} > > > > > > I think this should include: > > > > > > > + smmu->oas = smmu_idr5_to_oas(reg); > > > > + if (smmu->oas == 52) > > > > smmu->pgsize_bitmap |= 1ULL << 42; /* 4TB */ > > > > - break; > > > > > > ie it should return the supported page sizes by inspecting all the > > > idrs and don't leave this tricky bit to be open coded.. > > > > This way was easier as each function only returns one thing, otherwise > > we have to pass stuff by address as we can’t pass the smmu struct as it > > is not shared between the drivers. > > But no strong opinion, I can change that. > > Could you share the struct? With multi-compilation you do get two > structs with the same name and different layout, it is OK? > > That would give a cleaner setup too because you can just shove all > this into a function and have it setup the same struct which is more a > copy and paste than break up into little functions? Yes, that’s possible, but I didn't want to contaminate the main struct, also we can’t compile the main one for KVM because of things such as “struct device, struct mutex...” May we can do: - struct arm_smmu_device_common: Basic stuff (ioaddress, features, oas...) - arm_smmu_device: For the main driver which inherits arm_smmu_device_common - arm_smmu_nested_device for KVM which also inherits arm_smmu_device_common What do you think? Thanks, Mostafa > > Jason