From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 21B591B3942 for ; Mon, 4 Nov 2024 12:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730721693; cv=none; b=BRgUg6ShWHpOWeqwhFcj9oYyL+XSGJDIPKDNPY/gZT3/IoFA1bbW78WIxsGPivzLXT/kDLJiRm13GUdltdLosLgQk/4MZDixnZlFp15g4VI78mwHpv7m3H3JZ+y7oxrMokDm1ATjmU+Ock4BMLkRqlFuaCI3ebg+3jcnCuMW66s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730721693; c=relaxed/simple; bh=VMet+ZKZMbB9kRXIqGRAeZC8WyYNEBBksEcEjpKHNt4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lVWXyVPUHwPNCCBHr2EhTC5mh600pWAPFyIwEslXRzZcvcO/CBx0qpiscS7LiRf813WXrMm37Fo0BbGxadYYQMNSlOCL6LyKb1wSB6qgzksTueud9B6Sj2FCOs3JIUZhZm02TBs5wxZ5rK6Wu2gTFV4lPlaGnvxXXkKkaEfRNvc= 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=iUR0JKf1; arc=none smtp.client-ip=209.85.214.181 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="iUR0JKf1" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20ca03687fdso205285ad.0 for ; Mon, 04 Nov 2024 04:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730721691; x=1731326491; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=aBZ849UhGXAQ20Maj+3fLLaqA5Ylq1njMJ91T1YRFLU=; b=iUR0JKf1qjiBPD55BNhhuisXrsH422q2YgLRbJyQ2QTL/mH4n4FBm1apUZTcgL+1qn pJVgx34koXmUndJIFrhaLxN5zS5Xk/fTnd63s5SZlSPFgzH32T7M52SEZ68bp3LdgrrU KiXfEq8powI5PPMtvWUkPpnYWyIGw5guwpBb5WiGP4cJbYEaMjqzGMbQZkNsNQOunBFX fG79d5syeIEqsrupLhOW6vAUbpvl4FFsXtZQ6KD4o2pUMIR2yIgb4lhgtDpuAQog0S41 Da/gIy4fVz46OP7uazlGSreAG5W4USFgH34DLZSSNyBQOYSahhR9tKtkr00DI1wuZCRZ w+dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730721691; x=1731326491; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aBZ849UhGXAQ20Maj+3fLLaqA5Ylq1njMJ91T1YRFLU=; b=hG/GekmWeCvj48J/Qk2MYMiFEjzHHS4Jk1gxdNGXKdvNCe2QDk7scg67NkKl79IAMR TKo2qWNJ8EnWmMdrv7CUOluNcxSZNYGXc7Iu79mrBLvcmQjy9/NP7Kb3LmdMTwZsH5mu a5ORzsXfxTvtfpIBXWIe1ZrzEtNMcWjnMxlKKc1WdBq7uyxfVLzJPFKIYOoFwkk1phZb JCjwIOnZvGTaDPtAbhCPoe95GbQGrYETet7h+ho/z974923hMuvgdM7kUJ/wbRLv++77 ljxrz7h/lHMIIWJ/SjgolX52ATEe+SC3q1ZP0B7sEcnsMaKMuKSLbzfxonrG5ngxV2tk 9iJA== X-Forwarded-Encrypted: i=1; AJvYcCU3FueXMwseVRlRyJfta1g7DiiT3E9RSlliDIBuNuDFg4QyfH5zY7jrvw6zWKLHa2kwMdqEBMft9YCEj7k=@vger.kernel.org X-Gm-Message-State: AOJu0YxUQ1effstHOWaWmzlhRdOlSSiOsKQ6mbKNJdzm4mmHRw6qv467 X6JUBht2WISCrB347cRXbCLH/Rok3Y37o6gCRgaYJAFMSCaDSzsnPym8W0Kq/A== X-Gm-Gg: ASbGncv4uvY85vKI3dghT+CRQpQlUUlNMyu/Qyk/xBwvRPww+1/BxzIojpeVxOHGkdQ 8Yw28OaJ1eHqO1DlktjkXGY5L3zvOVSBLrRWXk92EF2th3QUQSgr+PblUoE5WB0rehvd3iV6VrI sNruX7RzD4g1GwTwCxF35262avBjkoj0P38SK0lJeJcLi2WazSR4xGHlBiGOR98fPTAybrRXhjD C6Dl8Vzexf4hvJMq+g3nZAshYEkovgsHFaNZoStzfZlaYxYDufpxrutDc0jnl1k1d54Iv9XDlXk AW8qSWvNulE= X-Google-Smtp-Source: AGHT+IH9N8cVhjwUeF7SpDXa4M8T9hV2JUOxyfIm3VNZdh9jllFT9vRCS00lpSDKOeoHLwlT1m6GKg== X-Received: by 2002:a17:903:1ca:b0:20c:a5fb:7a0a with SMTP id d9443c01a7336-21134d2054fmr2537175ad.19.1730721690924; Mon, 04 Nov 2024 04:01:30 -0800 (PST) Received: from google.com (146.254.240.35.bc.googleusercontent.com. [35.240.254.146]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2110572008dsm58319505ad.114.2024.11.04.04.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 04:01:30 -0800 (PST) Date: Mon, 4 Nov 2024 12:01:21 +0000 From: Pranjal Shrivastava To: Robin Murphy Cc: Arnd Bergmann , Jian Shen , Salil Mehta , Arnd Bergmann , Will Deacon , Joerg Roedel , iommu@lists.linux.dev, Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jijie Shao , Peiyang Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [net-next] net: hns3: add IOMMU_SUPPORT dependency Message-ID: References: <20241104082129.3142694-1-arnd@kernel.org> <069c9838-b781-4012-934a-d2626fa78212@arm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <069c9838-b781-4012-934a-d2626fa78212@arm.com> On Mon, Nov 04, 2024 at 10:29:28AM +0000, Robin Murphy wrote: > On 2024-11-04 8:21 am, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > The hns3 driver started filling iommu_iotlb_gather structures itself, > > which requires CONFIG_IOMMU_SUPPORT is enabled: > > > > drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function 'hns3_dma_map_sync': > > drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error: 'struct iommu_iotlb_gather' has no member named 'start' > > 395 | iotlb_gather.start = iova; > > | ^ > > drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error: 'struct iommu_iotlb_gather' has no member named 'end' > > 396 | iotlb_gather.end = iova + granule - 1; > > | ^ > > drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error: 'struct iommu_iotlb_gather' has no member named 'pgsize' > > 397 | iotlb_gather.pgsize = granule; > > | ^ > > > > Add a Kconfig dependency to make it build in random configurations. > > > > Cc: Will Deacon > > Cc: Joerg Roedel > > Cc: Robin Murphy > > Cc: iommu@lists.linux.dev > > Fixes: f2c14899caba ("net: hns3: add sync command to sync io-pgtable") > > Signed-off-by: Arnd Bergmann > > --- > > I noticed that no other driver does this, so it would be good to > > have a confirmation from the iommu maintainers that this is how > > the interface and the dependency is intended to be used. > > WTF is that patch doing!? No, random device drivers should absolutely not be > poking into IOMMU driver internals, this is egregiously wrong and the > correct action is to drop it entirely. +1. Device drivers shouldn't poke into IOMMU internals. > > Thanks, > Robin. I see that the requirement in [1] is to somehow flush / sync the iotlb right after dma mapping an address as a work around for a HW bug, right? I'd like to point out that the dma_map* API take care of this if the underlying iommu implements the `iotlb_sync_map` op (check iommu_map). Thus, in case you require it and your iommu driver does NOT support `iotlb_sync_map`, the right way would be to add this functionality to *that* iommu driver instead of letting the device driver poke into IOMMU Another thing worth noting is, we do have some quirks to address broken hardware in the iommu drivers. For example, a broken pre-fetch command for hisilicon HI161x in arm-smmu-v3 driver[2]. Such options can be added to iommu drivers after discussion with the relevant stakeholders. Thanks, Praan [1] https://lore.kernel.org/netdev/20241025092938.2912958-2-shaojijie@huawei.com/ [2] https://elixir.bootlin.com/linux/v6.11.6/source/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c#L81 > > > --- > > drivers/net/ethernet/hisilicon/Kconfig | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/net/ethernet/hisilicon/Kconfig b/drivers/net/ethernet/hisilicon/Kconfig > > index 65302c41bfb1..790efc8d2de6 100644 > > --- a/drivers/net/ethernet/hisilicon/Kconfig > > +++ b/drivers/net/ethernet/hisilicon/Kconfig > > @@ -91,6 +91,7 @@ config HNS_ENET > > config HNS3 > > tristate "Hisilicon Network Subsystem Support HNS3 (Framework)" > > depends on PCI > > + depends on IOMMU_SUPPORT > > select NET_DEVLINK > > select PAGE_POOL > > help > >