Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp181273rdb; Wed, 14 Feb 2024 17:36:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXRwopGGrcIMetvRkSHTm+ocsHSJsOj/wAl1Y0CN1iRkUBeVDLF2f3LnglSu+bLd5ExyqX3RAjHks9XtgIhZN6BT3P122P7XKSTosFVNw== X-Google-Smtp-Source: AGHT+IHikQDMKKSVJ3huywGdZLemu/7E2yQHod316UOO1/QKlnXc8PLkEecJ2B332ET/FMd/TQTi X-Received: by 2002:a0c:f543:0:b0:686:ab05:59fb with SMTP id p3-20020a0cf543000000b00686ab0559fbmr503257qvm.8.1707961009429; Wed, 14 Feb 2024 17:36:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707961009; cv=pass; d=google.com; s=arc-20160816; b=FqNVqaRAjRLlwYeUs323Ufi5Z9XaddOlsA27t5KtSLRaspUz1xYdhJ2RzbOjDJQYs3 X2HvLOChcqW3pf6xIA9mQz1EidzqObzzWuUJitFYn998sEht6V+JJ814GTboVD90Pxuv oHzdCJbAK3uiPd/AkMd+uiPObUuZULmz1edAxEJ3U7UPtXPZEOplK4F997Tm74uMC5EW WLgXlVfOjITLGWeSES0JkQdHAv7Cvs35rA1qmh9/ys77iKVgVcMZloMYF0LnrQ+8up2N 1fE5WFI1NilfPWWEVb/DPHODc2trobWIU8VhjW2e0r5NnVs5nZZqC/DE7mSN1l7suxAQ hfnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FMs8otkL/0Jd1KeHkEmksoEQgRdaqCRV71xQ7tvAXUg=; fh=U1yJuOqRW1SzR7s4DSMgFSez8EHrBH2KBPtdGKn14V0=; b=eTPy8V8neC4SybhGMTiYuhqzrlRGLflMOBBZfsqOu5HucljioQrp5xQ4nrzXrfLHFM Ut48vR7YmsXb36nrkMDavtcLKfxF9/DwleuVVt+9C0vux9f8snIcRwJeAIP1Mb75M3zD /ximS/tdjewGfun6RZnYZbnr9c7S70GNYs65wATndUkhVT3ctqF2/HspbTJvQIo39XQA /N+/tDLqGJ20ve2b1dDY/6qF4zswHVEdJbEJJXqGaNnTZWWAhzQBOIh2qxb7AE1JNtSN SxFuh4KuvlqbZZfr/TGxNpJjXcVx+3t2+3IxUqVBl/Pc4AiQ9xHMFiGcBAv5zWeyTJhM hvpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aIYWwiOS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-66230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66230-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q14-20020ad4574e000000b0068f0699ab3csi361437qvx.400.2024.02.14.17.36.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 17:36:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aIYWwiOS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-66230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66230-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 31A921C22457 for ; Thu, 15 Feb 2024 01:36:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3EA61870; Thu, 15 Feb 2024 01:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aIYWwiOS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E320617C9; Thu, 15 Feb 2024 01:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707961003; cv=none; b=JvYuBFAQhBS9/DUVM23XKGzPzkwaVjOe0a5UCDrtWwwv4wH2J3vjvnwL+3cxtYA+KLqoA6Sfle2hk30hDDDlZ4ijaX8m9gfCcc3pSDNShY954a5QHM2C70lXmFx2sy1EVqyaWhE6mK+msJ4W++Dsxtwxt6kArJvRuhXWrhgk/NU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707961003; c=relaxed/simple; bh=pPliZncdA3i95L/mjXLvn7u/pxryzDw1zgs434SpmLk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VkpSjjND2QuPVLbVuoFc3omdne1E6b81N98lfiWi+tJZw0heFd+cY5sn++08hh6XKRoJ8oj/okmH/usRTJU5Ja0cJexPIz3K+dHvpMdrt3PSqby+sDPkTzfjtnEyySMgriVt1Gk8KeskWE3ucAzlu7p/I6vde2OXu6BIuLVQQIY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aIYWwiOS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 874ECC433C7; Thu, 15 Feb 2024 01:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707961002; bh=pPliZncdA3i95L/mjXLvn7u/pxryzDw1zgs434SpmLk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aIYWwiOSIjt8sT6wPq0tPs6lzJB8PGB3UrjsTwGEdZ462ubWUs53385RoWRztfpKY XG0JoA3wLh4Wc2H4zDw+7lcU17Icm139JzEIuZeTUeHsi9EQ7By5RIaGxqsnfuOztl sdFmFEDfoyWQDH3HoINL7MREAW/vdjH9EpNuoWPf2ik97lqwP5/+tScSXTY71AG9RL XJNeTL/JM5u3doGRsGqGJeh25Ng2ltElGKFffdfrPxqdN0+R9yGkwPZ7INbI/CnrO4 2iltwab2NtxLSevGVysR/HLmtk8yWHBW2JrAKu7v0m3cQFn74pLaQmyF8UONu7dPj5 LiseI3mLMtenw== Date: Wed, 14 Feb 2024 18:36:38 -0700 From: Keith Busch To: Nicolin Chen Cc: sagi@grimberg.me, hch@lst.de, axboe@kernel.dk, will@kernel.org, joro@8bytes.org, robin.murphy@arm.com, jgg@nvidia.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, murphyt7@tcd.ie, baolu.lu@linux.intel.com Subject: Re: [PATCH v1 2/2] nvme-pci: Fix iommu map (via swiotlb) failures when PAGE_SIZE=64KB Message-ID: References: <60bdcc29a2bcf12c6ab95cf0ea480d67c41c51e7.1707851466.git.nicolinc@nvidia.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: On Tue, Feb 13, 2024 at 10:09:19PM -0800, Nicolin Chen wrote: > On Tue, Feb 13, 2024 at 04:31:04PM -0700, Keith Busch wrote: > > On Tue, Feb 13, 2024 at 01:53:57PM -0800, Nicolin Chen wrote: > > > @@ -2967,7 +2967,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev, > > > dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)); > > > else > > > dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); > > > - dma_set_min_align_mask(&pdev->dev, NVME_CTRL_PAGE_SIZE - 1); > > > + dma_set_min_align_mask(&pdev->dev, PAGE_SIZE - 1); > > > dma_set_max_seg_size(&pdev->dev, 0xffffffff); > > > > I recall we had to do this for POWER because they have 64k pages, but > > page aligned addresses IOMMU map to 4k, so we needed to allow the lower > > dma alignment to efficiently use it. > > Thanks for the input! > > In that case, we might have to rely on iovad->granule from the > attached iommu_domain: I explored a bit more, and there is some PPC weirdness that lead to NVME_CTRL_PAGE_SIZE, I don't find the dma min align mask used in that path. It looks like swiotlb is the only user for this, so your original patch may be just fine.