Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2880410pxv; Mon, 12 Jul 2021 04:16:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaZ2QsgTT2Bv2il7nTFgolmJgtK/8iGZie3JZl9O/HzWWRDOjy3ix0kFIgCyijvfnPI9Dv X-Received: by 2002:aa7:cf8b:: with SMTP id z11mr10014486edx.54.1626088613283; Mon, 12 Jul 2021 04:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626088613; cv=none; d=google.com; s=arc-20160816; b=DMkZl6D1tEHIYgijKsIpkJ3Wtqz7gySgi9gMMErpDA1r0pap61h2zND0dAr4Kkx9/f D3N8504iYDXOmO4jWSuMEvIcYLnVxSwg79DSZToUb0EHT1v4s10MQiwxmoqP8sZK54QE Ww7cLL2IhazgEJPGIXxqf8AbbUNyDYpFoUS05PKHJ3Zp6Z5xkxp8FDJBcoPJpG8zXgPq jYHClDmuKLLMRtdRB/FU3eaiZ8XXaaru0etn75FaDWnaRI3hnaxuPc3hZCBl/uwrVx19 dTIPWdWqauYdHPVybsoVAeLAOoDa0vXScSC377rI/RR9Eea0IM3o+AddhjL3r/x3unns 3YWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature:dkim-signature; bh=7XyyQqaPm43E+iSA6HEfleHFR36OXWaTALDg2LKUkgk=; b=t0bD1mKbYu5W+2n73wEx/DW2Td6amPZrZwLIFP2houQEanhVwRxpvth3zsQQRaFxF9 dcyDu5v7dyu97AaO3OQZyOstBbyHo7jiXfUet9RVsMsxvwMM0oEq1c8BgojFLWcGeK6s JxcV9MjcjnWkSatJ5Q70aZnMRBkUKntH+yrsDnIoHxCAIqfg6/TuuihJ79PpB9qWBUWU l0/GgC2gTf0tBVj8oPi3NC608yrdXFAkZ8mjwhRcG7OXt77g7pmHT9Ud9iW4PapxvJkS hKd7tBX9hxbX0gZSkMuBPKA3GePDI3rP7n6lcF+dswtmXDvyEFmbDs+eQeOLpUTgJ4Vl gQ1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=xwjCPhQd; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ouodfEze; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx28si16276594ejc.43.2021.07.12.04.16.30; Mon, 12 Jul 2021 04:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=xwjCPhQd; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ouodfEze; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235383AbhGLLFg (ORCPT + 99 others); Mon, 12 Jul 2021 07:05:36 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:35873 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234923AbhGLLFf (ORCPT ); Mon, 12 Jul 2021 07:05:35 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 91254580AF9; Mon, 12 Jul 2021 07:02:46 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute1.internal (MEProxy); Mon, 12 Jul 2021 07:02:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=mime-version:message-id:in-reply-to:references:date:from:to :cc:subject:content-type; s=fm1; bh=7XyyQqaPm43E+iSA6HEfleHFR36O XWaTALDg2LKUkgk=; b=xwjCPhQd0xWBFg4xsAE2OGMHZIACEIN1AJC4/+P1tGFa zFL9zncOUF+88bPV4qC+v3E7iAk/B35NTHUyEOSkRgG7DSSWNVNPahmq1x1xIyt8 4izt0VYsxKGG+T46UjGfpIaKfZZ8Es+pEE3BrhqUGS7NrwHItHj7ziHDqLCk5yO5 BX+j+ak2TQILZEpGSnmaTz8D8iZNqvD9hKOGjsXr++0eL8e/9vH9MZhsMLb6F3Lm b1N5B6ApWbQAr81c0TUy+atLA/e2NCg0RhEgz+5avim4jRUbr/EbCUjk7N5e5VHr LbbySTBnDLc9v/AOt3UjWzA4FeKCRsE0CDoOLA5yng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=7XyyQq aPm43E+iSA6HEfleHFR36OXWaTALDg2LKUkgk=; b=ouodfEzeihWXi3YKhCGJZb 3fslL+cRjTPE3SGqWePpDDraM1i8uBW7MNNt9ObldK51+CKThOEA+xoBsIwyrEOz rjcnOgpxvNKQlv3ZRKmqJFQk48dBEDdlzgnevSfYpdfNy6aEMRDbWeKHZsSjAQ6s zzOs35CsOfDIQkV0yIVkYU8lancSJLXt1Ih04iiN0+jJUGDELJWZBt2U3SEPFpVo CPYkW1LNkeKgY7ToNMwfWrbrZ7m+FSW29OqJsbsh/fVculWVsWOuhOxU/YTQEct2 twiAkhSj+LxuB5iSs4FrpVv5wg5e+fzmMcb2oa8D/lNbjtCQkPA9oAJmqPF1Zu5Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddvgdeffecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfufhvvghn ucfrvghtvghrfdcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrth htvghrnhepgfeigeeiffeuhfettdejgfetjeetfeelfefgfefgvddvtdfghfffudehvdef keffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsh hvvghnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id D489951C0060; Mon, 12 Jul 2021 07:02:44 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-531-g1160beca77-fm-20210705.001-g1160beca Mime-Version: 1.0 Message-Id: <16ffb4ec-86a4-4300-b175-5d7a1fcbf994@www.fastmail.com> In-Reply-To: References: <20210627143405.77298-1-sven@svenpeter.dev> <20210627143405.77298-4-sven@svenpeter.dev> Date: Mon, 12 Jul 2021 13:02:24 +0200 From: "Sven Peter" To: "Alyssa Rosenzweig" Cc: "Will Deacon" , "Robin Murphy" , "Joerg Roedel" , "Arnd Bergmann" , devicetree@vger.kernel.org, "Hector Martin" , linux-kernel@vger.kernel.org, "Marc Zyngier" , "Mohamed Mediouni" , "Stan Skowronek" , linux-arm-kernel@lists.infradead.org, "Mark Kettenis" , "Petr Mladek via iommu" , "Alexander Graf" , "Alyssa Rosenzweig" , "Rob Herring" , "Rouven Czerwinski" Subject: Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Jun 30, 2021, at 15:49, Alyssa Rosenzweig wrote: > Looks really good! Just a few minor comments. With them addressed, > > Reviewed-by: Alyssa Rosenzweig Thanks! > > > + Say Y here if you are using an Apple SoC with a DART IOMMU. > > Nit: Do we need to spell out "with a DART IOMMU"? Don't all the apple > socs need DART? Good point, I'll remove it. > > > +/* > > + * This structure is used to identify a single stream attached to a domain. > > + * It's used as a list inside that domain to be able to attach multiple > > + * streams to a single domain. Since multiple devices can use a single stream > > + * it additionally keeps track of how many devices are represented by this > > + * stream. Once that number reaches zero it is detached from the IOMMU domain > > + * and all translations from this stream are disabled. > > + * > > + * @dart: DART instance to which this stream belongs > > + * @sid: stream id within the DART instance > > + * @num_devices: count of devices attached to this stream > > + * @stream_head: list head for the next stream > > + */ > > +struct apple_dart_stream { > > + struct apple_dart *dart; > > + u32 sid; > > + > > + u32 num_devices; > > + > > + struct list_head stream_head; > > +}; > > It wasn't obvious to me why we can get away without reference counting. > Looking ahead it looks like we assert locks in each case. Maybe add > that to the comment? Sure, I'll add that to the comment. > > ``` > > +static void apple_dart_hw_set_ttbr(struct apple_dart *dart, u16 sid, u16 idx, > > + phys_addr_t paddr) > > +{ > > + writel(DART_TTBR_VALID | (paddr >> DART_TTBR_SHIFT), > > + dart->regs + DART_TTBR(sid, idx)); > > +} > ``` > > Should we be checking alignment here? Something like > > BUG_ON(paddr & ((1 << DART_TTBR_SHIFT) - 1)); > Sure, right now paddr will always be aligned but adding that BUG_ON doesn't hurt :) Best, Sven