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 8F3FD38837B for ; Sat, 18 Jul 2026 08:39:53 +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=1784363995; cv=none; b=ogMABW0fOgHH1sBdq4m/ZDcpP8mABbJgRdH1t+6Td4mYd3kcyMHMu5SPYTMFfgmljV7N8+j57VL0X7Vdlw8jWR/5gXNN/z3O9fUkJoFh6YskxIXRxnOnf3pS+31/ydyO2JoU3gkZw78OQzGfaPyD58kPYhBaaO1KIgv0vswOaG8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784363995; c=relaxed/simple; bh=wxhO085La/+XeWU00w7Xk6/Dkf9lbbQyMuWbzMBiyk0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Cn7nokSI2RoM/fkxBlCkSVCMaWizPEtTitTp9yI2WUOAqD8kNAS27XPLKq91DD42G0UeqyeUsU7yENDSrSxFokLq9Bzpd+Bm2+HZ37nM4YkQuhlb27ss1VmJDBozO0ybQvghFVCjPDqJmLXEAFvZKzfG2/2zDOocp/f2P0z4stc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reactivated.net; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=reactivated.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-47ddf7b09aaso5770073f8f.3 for ; Sat, 18 Jul 2026 01:39:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784363992; x=1784968792; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7tMDcOMCOuv2/S1kjEybtD3qi7le2Cks8fYUJXxydzs=; b=ZZNqEdza5I98iHknNpd+tCSfhZFoDGajUkvNH1aN15pO86SSJP8a81FBQ6yjG05ADt 5vfHW+xUJ4gukaE6seqLiZJK/JpZmFEsNUxIhf4cy2awsNmjsoz3OEXoNalmH84e9tRK UlOHVlEm0U9QSIDBqyTg2zuMluGQgM8kqZSX5euUMvS8SwhNhF8j988D0oJ88LjAni1/ iM5qwDRV6SFSLLYvQx378u1Ccv9mZvLwN3zWMHZEEi+e8YhEYxQPAg4TkMEJLbsIm9mV cOJYqvzNSErTiybvISfr6ab0ilI82vo05dKvDGJ3UrmTDZfvEuNtdpPK49WiYZbDqWZ2 jmkQ== X-Forwarded-Encrypted: i=1; AHgh+RpB8VrcXF/morH/E6GocMT9WqRkcIVEd5/T9wcwOF34u5ua7B7vmCZec0yNnSzBbNPtFHe+id1ENQsf4F4=@vger.kernel.org X-Gm-Message-State: AOJu0YyhRtNAENVSIxHj888k8HSGrJ22NKh5Bge07xpMZXh5A+yKElIk CcO1XkVorXQng+p7do7JasJl3H1KI8zpa/jtkEPzOKE8wKXZQUG6NklB X-Gm-Gg: AfdE7cnQfY0rVT7T7W+n7IgK1wOb3M0qsu1Fp7l7IYc5mm1iA8d4/7A1xN4W6YwsiEr hwuH0/pM3+0mZiwytClALK3ezr6EDxrLmKxrzY6yUp0ZnWgPBB/huSu62OP+mx1QETgC/d7VnHM FtriuCv0KK/zshub4mEvf6y/5l8VlhJWueE0JHhKvDc+KAS/bbkYqZ1fxLeIRDKkdw3jaNjEkqO tzqdxbPh72mjp6tgLFwjEH2bgvHBJwsISPNb9xo+Cqd734sp3jc3bGI7yTrofreqF6ZM5FymDDG GGdwpEhNLkyJ20ySUcIABWMW4WopRpzlRigjv/Cihtbxr3bfik1hwrRVImGvQ5hF9qwyEp7r31f E2CVgjFy8Sr7NYv4bVGIgvdMZD5JZeu+7nMxej7ghtDFv7Uf3vJh0L6HOC1ukU75LzJ9zJULzzH ufFbktD8oB6OVLZp6A7MrxnYYf7pi8hLzMOEl/DKNQs/kMbpsbjzTKMxmW4vTnYFRmx5dUFJAyf Q+egHEizQ== X-Received: by 2002:a5d:458c:0:b0:47f:45b1:128c with SMTP id ffacd0b85a97d-47f6233eda7mr5267829f8f.58.1784363991641; Sat, 18 Jul 2026 01:39:51 -0700 (PDT) Received: from ?IPV6:2001:8a0:d6cd:9000:86f4:4e71:9fc8:3183? ([2001:8a0:d6cd:9000:86f4:4e71:9fc8:3183]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63eddd27sm10661708f8f.28.2026.07.18.01.39.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Jul 2026 01:39:51 -0700 (PDT) Message-ID: <57f5675c-8bcd-4022-978b-9f7933bb0032@reactivated.net> Date: Sat, 18 Jul 2026 09:39:48 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/6] iommu: Add Broadcom BCM2712 IOMMU driver To: Jason Gunthorpe Cc: "Joerg Roedel (AMD)" , Will Deacon , Robin Murphy , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, nick.hollinghurst@raspberrypi.com References: <20260712-bcm2712-iommu-submit-v1-0-80e10cdde2ea@reactivated.net> <20260712-bcm2712-iommu-submit-v1-5-80e10cdde2ea@reactivated.net> <20260712221125.GD1835788@ziepe.ca> Content-Language: en-US From: Daniel Drake In-Reply-To: <20260712221125.GD1835788@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 12/07/2026 23:11, Jason Gunthorpe wrote: >> +static int bcm2712_iommu_map_pages(struct iommu_domain *domain, >> + unsigned long iova, phys_addr_t paddr, >> + size_t pgsize, size_t pgcount, int prot, >> + gfp_t gfp, size_t *mapped) >> +{ >> + struct bcm2712_iommu_domain *mydomain = to_bcm2712_domain(domain); >> + struct pt_iommu *pt = &mydomain->pt.iommu; >> + >> + return pt->ops->map_range(pt, bcm2712_iova_to_offset(mydomain, iova), >> + paddr, pgsize * pgcount, prot, gfp, mapped); >> +} > > These ops should not be present, the iommpt provides the ops directly > through a macro; > >> +static const struct iommu_ops bcm2712_iommu_ops = { >> + .identity_domain = &bcm2712_identity_domain, >> + .domain_alloc_paging = bcm2712_iommu_domain_alloc, >> + .probe_device = bcm2712_iommu_probe_device, >> + .device_group = generic_single_device_group, >> + .of_xlate = bcm2712_iommu_of_xlate, >> + .default_domain_ops = &(const struct iommu_domain_ops) { >> + .attach_dev = bcm2712_iommu_attach_dev, >> + .iotlb_sync = bcm2712_iommu_sync, >> + .iotlb_sync_map = bcm2712_iommu_sync_map, >> + .flush_iotlb_all = bcm2712_iommu_sync_all, >> + .free = bcm2712_iommu_domain_free, >> + .map_pages = bcm2712_iommu_map_pages, >> + .unmap_pages = bcm2712_iommu_unmap_pages, >> + .iova_to_phys = bcm2712_iova_to_phys, >> + }, > > Then use something like: > > IOMMU_PT_DOMAIN_OPS(bcm2712), > > To define all the page table related ops automatically. I don't think I can use that because this setup uses an IOVA aperture at base 0xA00000000, whereas generic_pt assumes it is managing a 0-indexed virtual address space. So the driver has to intercept every incoming IOVA and translate for the aperture, see how map_pages calls: static inline unsigned long bcm2712_iova_to_offset(struct bcm2712_iommu_domain *domain, unsigned long iova) { return iova - domain->mmu->aperture_start; } That's why I also set is_iommupt=false. I will add a comment to make this clear. Let me know if you see a better approach. I was wondering about making iommupt understand apertures and translate accordingly, but I imagine you would want to keep that kind of thing out of the generic fast path? Thanks for all the other feedback too - working on it! Daniel