From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 C5EE93F54B8 for ; Wed, 6 May 2026 09:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778061410; cv=none; b=ku+IisKGk43JJDkI82/oLQi+jS+BGsAN65JizrMTI84RoLsB9dn4Pkm8kSIialZyeX+6VztiL6a3zBAGSmviHRkjOH67CUbrsnvLqNUl2CQRzY8n0W/OPM/Gq6C70zSOkAf3gonMd4Lyy0K2cxgYE+7IQ2JYeYMIpmPnKm+4Yqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778061410; c=relaxed/simple; bh=hatrkSn5Z6/BHN4SB6+bdCIaRWu9LOqpRgkzA91XysA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hriv/2YqJjUlwN4SR2GnAVNpq4E39zrvFAz4C2sJNrBYBCIauY80mrEFlmB92jP3RuY5zYdotTLGqxTlSfKJ1HgU6VuSnTPveSOBBHv8ZTF0uUl6r5aqN5ykEC21R5rkg1n3PtLKj3KcLAy0oHCFFL82U0KT5RCjb/KAGeX8r5Y= 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=T7JWNvzu; arc=none smtp.client-ip=209.85.221.50 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="T7JWNvzu" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-44985f4ab0fso2919532f8f.0 for ; Wed, 06 May 2026 02:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1778061393; x=1778666193; 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=GCpEK+1e4PN546tNNVMgEraFuXI3jgId2T+tlphvHrE=; b=T7JWNvzuVdhOhSH5y/Td16i3/ZiOMdC9M4Z0GzpVxMp56x6nh3E5O8VnD/fsH/SDbH MX7qMxQhPHBl6YRZo1LmWovFSbxPHD3dyoTdc/f1BQS7ZJI2gCQyS/tUhx0GHvO5bzrb LH8pm86MURZVIzNTNc9aejnoSVMUORo3tlmhHinT9sIjTDtGl6zPszIC4hRUxonufxkq eAvXKQRVupe0H6wxC2uPFQ4Y3qGgxbXvK5DuOaUDxoJlv6qpIHqBE+RFRV914aAJKvPS Lrvn7Lqin7c+MSIQrtitVA5QJYmR9+MuxRQtG6UsAbv9w3iMnT7udq0ZuGQxc1LQpfis HN2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778061393; x=1778666193; 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=GCpEK+1e4PN546tNNVMgEraFuXI3jgId2T+tlphvHrE=; b=tC3IdTlwFOFW6GNMrw+RX9tnTwoAgQAoPbfDvoMxWHf4Jbed1727qtd0/vxFj7towJ DPoWLWh1MAXi3lKfpaUHMSojGjUgFTyVmvJF3lugLvYwErDzAP9B4hbgPRr5ATiSFedm mD5UyEQBKZVN9dobrTAy/MsuSmPhs59CWmC9J6P1xFg1EIga4AMxJOc2Z51UwdGF9lDZ T+O9ChaxEJrCHkMsYXOS/XKn9qLBxEPJQbMuVAlDGOmlWCYHuVppXLX/zuPG5dSg944v SBTOo6/a+2VBRbni/5a4sNxyMmOIUWbrQajV0dsY59El/7Q1Ah4tnXNu+8zD1IKnRJmr f9Dg== X-Forwarded-Encrypted: i=1; AFNElJ+RYojaS4Fs6SQeVTrCZBuJys/gWPxN89RLqO++0tPaQjX7L94Ii9XOd6qeC1wJ/js7Mkt6ltvDgGNAJbE=@vger.kernel.org X-Gm-Message-State: AOJu0YyF1JeQE7VZNBvsVj06KUM17pcBKeYnzg/j4Kp+O0X2xWD02cW0 8hPPpBsnvwX47jxCB/PV/bUstfqZkvbqbOFFmA2pwUbrITqy4oLv3ZT5Ki4LPLHDQgk= X-Gm-Gg: AeBDievUEntYMKnkcIh5/ljtb416sHi+ogAYoY5hyxvqzbtjMtEVkhXMklp2u7j9KT/ aWXcpUUNhclTfm3/dwsos9E7PwQ9yvdo5of8ocr54ZvbPvCN9prMwpR6C0dMKLbr2blSToLWvU4 1Lbig/VeWXIIBJ0Ewo5gp4Gk5nDpAGvHAoGRlV+h+VI6bE4z7oI4F/0g9xcBK+UgPTKb96f33CB fenMEQWJzV+kQ0quC35z0F6CNfC5KlNInRT2S0mlPH/1WDhzhIFcJO5Fg5kMKguSCyiC9jc0YLs vfjJcKs4z5OcYQVe1ZbwCf+x0rPw7PY+16M2n1N32TRr/vcbn41OFmkW10ywJleUF4V3p1JFrfK yp1F3STronYIxeaACRA0zor8wEPT8+DolC8g+/azjVl8TuB5VUn/EWR6tkg3boSOI5BDd8dWC8C kdGTMH4Gk= X-Received: by 2002:a05:6000:2088:b0:43d:75ec:26e7 with SMTP id ffacd0b85a97d-4515d5c6c7bmr4597539f8f.33.1778061393031; Wed, 06 May 2026 02:56:33 -0700 (PDT) Received: from ziepe.ca ([213.147.98.98]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45055960811sm11821992f8f.27.2026.05.06.02.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 02:56:32 -0700 (PDT) Received: from jgg by jggl with local (Exim 4.95) (envelope-from ) id 1wKYzX-0001qR-KO; Wed, 06 May 2026 06:56:31 -0300 Date: Wed, 6 May 2026 06:56:31 -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 Tue, May 05, 2026 at 04:48:08PM +0000, Mostafa Saleh wrote: > 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 Less keen on this, it would need more usages to justify it > What do you think? I was thinking more like #define arm_smmu arm_pkvm_smmu Before the pkvm compile of the shared code. How does pkvm compilation work anyhow? Is it all rolled into a unique link, or do you have to worry about symbol conflicts with the main kernel? Jason