From patchwork Tue Apr 6 20:43:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianxiong Gao X-Patchwork-Id: 416385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54A0AC433ED for ; Tue, 6 Apr 2021 20:44:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34362613D3 for ; Tue, 6 Apr 2021 20:44:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237959AbhDFUof (ORCPT ); Tue, 6 Apr 2021 16:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245587AbhDFUof (ORCPT ); Tue, 6 Apr 2021 16:44:35 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75E8C061756 for ; Tue, 6 Apr 2021 13:44:26 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id x11so13350115qki.22 for ; Tue, 06 Apr 2021 13:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rePpgg0NtSFQvI03Pc8QaLoe8pSD5aFacV3/oLpjZHQ=; b=FX3QcbUXsZ59fiysV19KfwNB413SDl/OlsR+WLyXtn9ZBiHJPKMd2bENepGaL4VSKb jutDqNThkQVO6KaxOF8ybJymqywdem5D2Cz9e6rrNrHaUvoWfpvYK+8T0sgVYVHk4W2s 99n5ikrVe3rB3KDJeJPsvbVkj+opdgteG2liTJhJDwyQaiOlM7rzoAW9Mm1+q9Q+mwEJ BDhHXCqC4NT6vT9V+qOES9V5ti5Vn3k5CogfAw0DbIiNc73UvTP2IKZ1o3gST/siXb5C RIepwGyHeczFiFWECoCETLUUd2ei33/nFPwBBNXnY4FEKsy416Bo6jdzma22sNxYIdQy 33vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=rePpgg0NtSFQvI03Pc8QaLoe8pSD5aFacV3/oLpjZHQ=; b=dS7ElxqN6Peerrn1OdvBAA/hN02tIjM876K9aJ7g2SH+Cxxi/5leljHahWyiPKfC9u loj1BHAHc8knbn4DdWeeaC7/g138tiOH7UGWDT2VmTIyleTK/xhcVzbzmF+VSzfeLAIf llgHuZdRf/BqUIbUgDOmsH755rl+AeVih2aKf7hNDh2v5Pg9WAs7hn7S4DqYHzNKDVhq nd677PP5d1JkalrYABN6hgOP/bO9xUli6JnwcY9WgHx0jF9tEqRh7CKaQLa3+WVTcI3x 4q1amQeT1JbDrxbG3Yaw2d4TWurEtYZcC7haiwWBsWY+/wUgvbgivF3Azyrl0yEaLY5g d/XA== X-Gm-Message-State: AOAM533USzvT+z2mG1dxrGzdb1CPgsfb4vTmwYC8Qn38pU56IC4MTHPh /Ia6xmz4nso0Cbx1FF9XlS+XrrfZwP6uzCXbTnJsbsu06llw2nSyGNoOB7P0pUw4hgngkoZEtzM KyiUv0Up9WyxllG8+wlhFV0sSUOP/DovDGUaJm/d1FJ63UUZcm5b/LLtfihE= X-Google-Smtp-Source: ABdhPJxmNHKj0YsagYpo3qjbBR8hT+Z9H+94vNmOc6KtrwrB13ZpYlcu/Qp6o3GX/MPrUzlm8axQT+6Sfw== X-Received: from jxgao-snp.c.googlers.com ([fda3:e722:ac3:10:7f:e700:c0a8:1373]) (user=jxgao job=sendgmr) by 2002:a0c:ee81:: with SMTP id u1mr20076365qvr.14.1617741866073; Tue, 06 Apr 2021 13:44:26 -0700 (PDT) Date: Tue, 6 Apr 2021 20:43:27 +0000 In-Reply-To: <20210406204326.1932888-1-jxgao@google.com> Message-Id: <20210406204326.1932888-9-jxgao@google.com> Mime-Version: 1.0 References: <20210406204326.1932888-1-jxgao@google.com> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog Subject: [PATCH V2 v5.4 8/8] nvme-pci: set min_align_mask From: Jianxiong Gao To: stable@vger.kernel.org Cc: Jianxiong Gao , Christoph Hellwig , Konrad Rzeszutek Wilk Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Christoph Hellwig 'commit 3d2d861eb03e ("nvme-pci: set min_align_mask")' The PRP addressing scheme requires all PRP entries except for the first one to have a zero offset into the NVMe controller pages (which can be different from the Linux PAGE_SIZE). Use the min_align_mask device parameter to ensure that swiotlb does not change the address of the buffer modulo the device page size to ensure that the PRPs won't be malformed. Signed-off-by: Jianxiong Gao Signed-off-by: Christoph Hellwig Tested-by: Jianxiong Gao Signed-off-by: Konrad Rzeszutek Wilk --- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 869f462e6b6e..087ae2b2a853 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2576,6 +2576,7 @@ 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, dev->ctrl.page_size - 1); mutex_unlock(&dev->shutdown_lock);