Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1119827rwi; Mon, 10 Oct 2022 11:27:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hHXbYz/jsQ13/QZcZ6fxtJaFWSN4EsfMmLt9FRRUkmpLszk36OD+LuyUuJASdxKxAm/ae X-Received: by 2002:a65:6e97:0:b0:439:e6a3:9f6d with SMTP id bm23-20020a656e97000000b00439e6a39f6dmr17418585pgb.369.1665426473657; Mon, 10 Oct 2022 11:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665426473; cv=none; d=google.com; s=arc-20160816; b=D1LEGmvuLmVgcUYzFGoKawAFaNoOalwVI9Vk8o/KZrywthzGZlNe21/RqbOFUQL5O+ YercZTdfUO37EoRzvk3NQJGFxW+CEuCsBSkD8XlNUYTv8knEr85PtC1UWFvAMLD84N7f RqCd9gGBQ9sQBoXXwd9NfuHms6jvkJ3Kl/wekUPFRgAMLlSlU8BtbQUr+WS3jhmhwazN vUHiUrCZuCxf9zKw8qcW5yrppuwcVCgy2Qw4YVIzlv/3PSULsFrIVkSYUf2B6TX7bJoU AFN6t2wL+o0xGmIbUTAw6ZI6KF4oCrmMQ/Fzy6lMVRAZPeE2GR19n/zNY+67FswE9ybe 2G9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=sLlTjQcr0Op/6Zcx8OCFNh8EO9JbDZcvu4VpyKatzLc=; b=HNFdIxNaSVySKPa3iVhHAkp5N2lAzs7JIH4bewBQkaInW5UeRPPUHE0eENthpKvIaK 1msLd0bjHSdY8hHF6y9r9C0HBPh4w+hmTLkrGTP46UqzybkOv68Vo5zcaSCYzwdkZBrU SbOgFyCB6YdA82XN4HDBz/I9u6+zWSXuTmZgGfzMnn0ekm4mkl0+g/cTGzRJxPpEy+1N 7DOMXHLIMGIMg/nu6G5zX79rfWgBKSdmQzE3s/xi8mk886t2Ehusb0Jz5YNi+94BaRih 8IBARUNs/QBstmS0MCssxdvToB5nEldJoddpQG6rIeqxUHl1hNKtgT+P40z5QWlxZ79i rwwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=gNLQzTIc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 202-20020a6219d3000000b0053e7495a394si11140555pfz.141.2022.10.10.11.27.37; Mon, 10 Oct 2022 11:27:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=gNLQzTIc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiJJRzt (ORCPT + 99 others); Mon, 10 Oct 2022 13:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiJJRzr (ORCPT ); Mon, 10 Oct 2022 13:55:47 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D05FD75FE3; Mon, 10 Oct 2022 10:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1665424547; x=1696960547; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=sLlTjQcr0Op/6Zcx8OCFNh8EO9JbDZcvu4VpyKatzLc=; b=gNLQzTIcmXBUVKgcptTqVkBlmkzJduXm7h/S3zUAiI4ZeWDjp7DBGnxv dG1UVepm2MnIGerQ80YVVgw659qJ9PI+U+aTBFq9niOdWwMArhox0GwW/ K7KC9Z82Yqm8N8i5Qmf408CcF3igmxYwyV0x1NutlWFdkLnjYS4x12i1P k=; X-IronPort-AV: E=Sophos;i="5.95,173,1661817600"; d="scan'208";a="250379094" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-6fd66c4a.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 17:55:45 +0000 Received: from EX13MTAUWC002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2a-6fd66c4a.us-west-2.amazon.com (Postfix) with ESMTPS id BBF55A25CF; Mon, 10 Oct 2022 17:55:44 +0000 (UTC) Received: from EX19D002UWC004.ant.amazon.com (10.13.138.186) by EX13MTAUWC002.ant.amazon.com (10.43.162.240) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Mon, 10 Oct 2022 17:55:44 +0000 Received: from [192.168.25.29] (10.43.162.230) by EX19D002UWC004.ant.amazon.com (10.13.138.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Mon, 10 Oct 2022 17:55:43 +0000 Message-ID: Date: Mon, 10 Oct 2022 10:55:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH v2] nvme-pci: Set min align mask before calculating max_hw_sectors Content-Language: en-US From: "Bhatnagar, Rishabh" To: "linux-kernel@vger.kernel.org" , "linux-nvme@lists.infradead.org" , "stable@vger.kernel.org" CC: "hch@lst.de" , "sagi@grimberg.me" , "axboe@fb.com" , "kbusch@kernel.org" , "Bacco, Mike" , "Herrenschmidt, Benjamin" , "Park, SeongJae" References: <20220929182259.22523-1-risbhat@amazon.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.43.162.230] X-ClientProxiedBy: EX13D38UWB003.ant.amazon.com (10.43.161.178) To EX19D002UWC004.ant.amazon.com (10.13.138.186) X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/4/22 9:27 AM, Bhatnagar, Rishabh wrote: > On 9/29/22, 11:23 AM, "Rishabh Bhatnagar" wrote: > > In cases where swiotlb is enabled dma_max_mapping_size takes into > account the min align mask for the device. Right now the mask is > set after the max hw sectors are calculated which might result in > a request size that overflows the swiotlb buffer. > Set the min align mask for nvme driver before calling > dma_max_mapping_size while calculating max hw sectors. > > Fixes: 7637de311bd2 ("nvme-pci: limit max_hw_sectors based on the DMA max mapping size") > Cc: stable@vger.kernel.org > Signed-off-by: Rishabh Bhatnagar > --- > Changes in V2: > - Add Cc: tag > - Improve the commit text > - Add patch version > > Changes in V1: > - Add fixes tag > > drivers/nvme/host/pci.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 98864b853eef..30e71e41a0a2 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -2834,6 +2834,8 @@ static void nvme_reset_work(struct work_struct *work) > nvme_start_admin_queue(&dev->ctrl); > } > > + dma_set_min_align_mask(dev->dev, NVME_CTRL_PAGE_SIZE - 1); > + > /* > * Limit the max command size to prevent iod->sg allocations going > * over a single page. > @@ -2846,7 +2848,6 @@ static void nvme_reset_work(struct work_struct *work) > * Don't limit the IOMMU merged segment size. > */ > dma_set_max_seg_size(dev->dev, 0xffffffff); > - dma_set_min_align_mask(dev->dev, NVME_CTRL_PAGE_SIZE - 1); > > mutex_unlock(&dev->shutdown_lock); > > -- > 2.37.1 > > Hi. Any review on this patch would be much appreciated! Thanks Rishabh