From patchwork Wed Oct 13 06:50:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 1540249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=eJkQhEgg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HTjpw65RCz9sR4 for ; Wed, 13 Oct 2021 17:50:48 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1maY64-0006KO-7P; Wed, 13 Oct 2021 06:50:40 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1maY5m-00067J-Vq for kernel-team@lists.ubuntu.com; Wed, 13 Oct 2021 06:50:23 +0000 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 705B140011 for ; Wed, 13 Oct 2021 06:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1634107821; bh=6ojjTsJukJTNjk+779DoKbF9ezOqHTH5Dh9AgbWZpPI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=eJkQhEgg6lj1ssaBt4dKYHLgWO+DyoSnimqgdy57WcLUgo8MFMsEacW9v/s50eEyG mu2ANjtrgJO6CfHJxR2zirJx2L37PHTMsrFEP3mdxXioDvTSFiom/98XPBKlDmbVSn /7Uxu0qui1G+TDCKY4peBfsfUTDi5FzZs9F9PSY0zzM3I8D2GkNcTFsoWu5iy4d3o1 ovn83vCKgABzI9pBQ+CNesAcW2HsjqTyEwa25BQv7E4PKvroiTcwRvgQg/sfv1+UP1 KS+SoHB05u5XUEtOj7S0wE+2WcdC1ouYg0FEqfy8/aIKEFeWQUN2uX4lPEdkZ/C6eA JtDNeE69htlVw== Received: by mail-qv1-f72.google.com with SMTP id gs5-20020a056214226500b00382f5609124so1766151qvb.8 for ; Tue, 12 Oct 2021 23:50:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6ojjTsJukJTNjk+779DoKbF9ezOqHTH5Dh9AgbWZpPI=; b=lDkXbhm+jEQfPeGzYIEdriP4Tb2hdgvR+Jr/mlIusXlIDqbZc577Yj3nPmTUG8c06w p6YMqZrpIjqAHq/XZ2EoeORZgnvsPL2/BeTNKDpKmxmkjpF2ansDK8lkiy8KSrcWhBPJ d8o16OMtlYY70iz7dY4K4nvBXHmrQ44/cPGp390m2FHN0IeDtCRmdx0MC0PoeaV4LgBX ZpD4DzjwL7ywqnkDOPmwjflfF+oCdLMcJ2HW2Kbk628AbBJejwwytZXB4UIARmYELrq2 KnQ4MZlww30s/QIBE6ZxhSFXOS9N9cYK6d5uof/lFWIy33owVJxDypCY9SrI82wur43E N4Rg== X-Gm-Message-State: AOAM530OSLmIMIwsqJUK3Um5BiXXXAHUsTpK+fjhjQmbRRjUqMQaLuzv MT6Cff9JOiYRc28PL2Y772oIO/93un3Qym+GgsWd+XtkUssnqMZjWBUKth6DCHBlpRPmKV4I6rv Ul14/UkgIjmtQlEx3kT2MPcziypNA2F/OLpSXtTjm8Q== X-Received: by 2002:a05:622a:51:: with SMTP id y17mr26488133qtw.149.1634107820552; Tue, 12 Oct 2021 23:50:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww24EVUAI9zMINxn1WUVhF557pc0ImIYqkNZM5/luzR6JfiCXyoJDCDZkTg4hGW/QqDJywlA== X-Received: by 2002:a05:622a:51:: with SMTP id y17mr26488117qtw.149.1634107820184; Tue, 12 Oct 2021 23:50:20 -0700 (PDT) Received: from kbuntu2.fuzzbuzz.org (dhcp-24-53-240-12.cable.user.start.ca. [24.53.240.12]) by smtp.gmail.com with ESMTPSA id t19sm5727298qtn.26.2021.10.12.23.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 23:50:19 -0700 (PDT) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [PATCH 10/13] nvme-pci: set min_align_mask Date: Wed, 13 Oct 2021 02:50:04 -0400 Message-Id: <20211013065007.1302-11-khalid.elmously@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211013065007.1302-1-khalid.elmously@canonical.com> References: <20211013065007.1302-1-khalid.elmously@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jianxiong Gao BugLink: https://bugs.launchpad.net/bugs/1943902 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 (backported from commit 3d2d861eb03e8ee96dc430a54361c900cbe28afd) [ kmously: added definitions for NVME_NVME_CTRL_PAGE_SHIFT and NVME_CTRL_PAGE_SIZE from 6c3c05b087ada8947cd31895f67e43307044 ] Signed-off-by: Khalid Elmously --- drivers/nvme/host/pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index af516c35afe6f..414df0e0786d0 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2631,6 +2631,15 @@ static void nvme_reset_work(struct work_struct *work) */ dma_set_max_seg_size(dev->dev, 0xffffffff); + /* + * LP #1943902 + * The following 2 defines are from 6c3c05b087ada8947cd31895f67e433070446234 + * in Linux 5.12 and not intended to be changed. + */ + #define NVME_CTRL_PAGE_SHIFT 12 + #define NVME_CTRL_PAGE_SIZE (1 << NVME_CTRL_PAGE_SHIFT) + dma_set_min_align_mask(dev->dev, NVME_CTRL_PAGE_SIZE - 1); + mutex_unlock(&dev->shutdown_lock); /*