From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 CA5B948C3FE for ; Tue, 5 May 2026 16:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777998469; cv=none; b=bE3vf4I8RwHw93SzYVCPu8KP59Izs0Xc8Mtq0PAiCCUaMa3geNDiWVa9ABFF1saWODe2KAB3BkjfrScEmi/pbeGx03tuw/BzxqsYP1VZnGZ2Q/W1QVvwEREaicwDhqVnOA4h7NueaDOCf5OuD3iPJMPsebYn4VM9anTWCfcFq8c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777998469; c=relaxed/simple; bh=ZnXDTKUdX5lnq5iIdjYvuqdBQPDY6gB1BWd6/IRhYGk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FKre4hnJDMod3CF9TUe1ELpL88i9Vbiukx+inFssOT/d50aBLvEgPwhxe/BkVwqNKS6FK4Ryx0F41dETCorE3UPnNbulWk+SpqK4b1Qk7Mnx1mSscRSRwbvWfIs8vKKUOL98UQ5tw5zZMlT0tTFCTWRhj96klo3HCtRxs2ap1tA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=Mwceaxu1; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="Mwceaxu1" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-48909558b3aso59729825e9.0 for ; Tue, 05 May 2026 09:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1777998466; x=1778603266; 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=psW2zn2RKA7mDVnr8upNFQH0mArJi5iuTG1xm14kmUs=; b=Mwceaxu1xL7fKiHSrEwCLJpiku+q95XhidwqGCFZyGcY0CNYOkGK4ynCJkfD88DmA2 JZnMSTqHr+GDzh7r+IvmcH9ya5qeL5t3PpYVRXJO+SOIYyttv9YziETxCuswrfWMVLsa rpjknYPQ6jBTlpo8D/1TS7iJZSOFvlUlbqeSCQGBKzGHOm5G3WwAc1fZ6W3PJ1U974aY 9ZiPQOULdL3cBmuatzRBaPnx962XCU1mKt3RWlR0LwJX0+R4Z1yLTedEYZTlPjCsjvCn sIlKArwpeJjOgofgWirJCscP9EutlEP7nG5YEIVDRCwEbTIUogluxQX7XYhVgmJxiknU 386A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777998466; x=1778603266; 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=psW2zn2RKA7mDVnr8upNFQH0mArJi5iuTG1xm14kmUs=; b=ltleT8V+kHE58BBHxdErIEjLd8+mp4qrW5pGrf9kwZ0oIq+Qm1MxyOQut3akHbFF1d zzQJc3nEAKOG+qpLgO88xa4BLNGYrU68DoIc7+Og+99GxhwiNmq25OVkg8Hvt/AZ8grB z5A6CPEzewHgi+X+3WtO39HKJpkjUnenvjotzDTdH/vmJ4vXYchk7eNX/lBELEIs1KDF /DkjpR93a7C7XR4exW1NIjC/5mnqb6hV57Mpex/N2nSdI2GjvJnqixolY9tKk94moLbh 4r8L21nTXFfmXMdsir7LXLq1npb9gG55kviwnbvMvNu84KUiCyxwM0HI/8YGrvQ2XSjb M1XA== X-Forwarded-Encrypted: i=1; AFNElJ8li4f3t4VvmreDpUL1dMWaS0R/o8HzSdG0QB1mUDzgD2MywVxZE/KdXhfhnv5xdDRtgCazAWjMJd63pgg=@vger.kernel.org X-Gm-Message-State: AOJu0YxmUcVBVssNw5lf0iP9TaLLY+JOl0Z1V22ms1SVbOdAW6nxuRAA L3wvTmioH34e2/yBKK3ID/J8WC49p2qmDNHig2XdhZ7iguEU8Pdw8aLw3Bktk2DpsT0= X-Gm-Gg: AeBDievB9TEGouuIB2xUscp20I6ILrQ+w9KXp1tHI8Qd6wjPy8I9wWD8xoxUbNKfbA+ 4NOFUwEgUetpVyw1uCzIAofMypt6yd/ed5VZS6+T8wfil9uP2I10tVEzflEWIvOLLajivYD2b+x K1j30V4ZnipWXum14cpUvsG6Q6VfeOK3YPDhtbZ8u8AvKBVaaNLQC1EufRB3vtGnb//T9CaWrpd CnYlZfKM2fVN/vhPZrL2GicwtXbKFZRYNEF53Whuh6NegLugk2E0p7MFqZl5cTFml/l682sKGlu sqmDsBtAhXxhwJbeU5d5KnMnXh6V/svUin8idDacjm41db2SeIUlhFGTomOhVrzNGuU50QyxJzX a0kEbOHxYtUPkBixKqyghW8hrKdp47XhnFY/zJtWrC05tFasM+x5x8Gt8Qvm6xYIytzv7ZjjnRp VLFerYeAI= X-Received: by 2002:a05:600c:3544:b0:489:1d23:4524 with SMTP id 5b1f17b1804b1-48e51a6229fmr2708455e9.5.1777998466365; Tue, 05 May 2026 09:27:46 -0700 (PDT) Received: from ziepe.ca ([213.147.98.98]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a8ebb3dc1sm381506775e9.14.2026.05.05.09.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 09:27:45 -0700 (PDT) Received: from jgg by jggl with local (Exim 4.95) (envelope-from ) id 1wKIcb-000AO7-2w; Tue, 05 May 2026 13:27:45 -0300 Date: Tue, 5 May 2026 13:27:45 -0300 From: Jason Gunthorpe To: Mostafa Saleh 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 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? Jason