From patchwork Thu Jan 25 14:37:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13530931 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 14C6E6E2BF for ; Thu, 25 Jan 2024 14:37:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193433; cv=none; b=DwHDFLU2dbW9UvC9/rKNBNffg3qvw2z+n7dY40hezJ+fcUQKX6tW49v7tpgIw2RTveTNMLTaNzdeNLudIr6UzaA3zEVgSVAW7fFA+fTr3cLS02dv8JXDc9ebM3TmeT7Sv8YULbqW0rMtLuFzMORIpvvpxG1on3FPcX+qPfVp+Rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193433; c=relaxed/simple; bh=Kek+Scrv6+UCfq5BBGg2zaWiIeeEWdDOIWCeg8Mvbsw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NMWaTvR7UuMB08ld6m+8NqgB/dtuzH76EpeuPz4yoGtX7PVc0Aq5MKIDBxXLMmBM7NIzNsUzyCI9btxUKGb8aSfRNiKR0Su83gB2mlIkWPrMnlLmRzjl3pLP884OLd4Ljiu6mR8iS+hPdSeGiTiXg5fODOiad4MVdOD5YGJ0NCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iF/8jP/0; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iF/8jP/0" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cf1524cb17so35448611fa.2 for ; Thu, 25 Jan 2024 06:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706193427; x=1706798227; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+N5XQAayZgM276rPgCazC+JMbS0uzbwzoNPf1gEMYQA=; b=iF/8jP/0rwEyRVzZBs9YGEMsuacgS8TzhhIJHX2J0dgjhGY9TyHXJ0+SdEX1xOIb8v 0VVA/Z8jWRjuoffRbDgEuSlwsLsZwykHqONywOkKTvLt7I+dulQeYVUIaxLWXSnR1z5Y 9wlDghknzk7H3+GHbAdL7JN4PmC434stLfGNQIn/fiI0bL9Y09aRf6co4zFop1MFxOZW h0vHZlbikEnNnkfErUUBiQI8UtBvLlqDmI4svhNy6FsEVOJ872vdIPoGLnHb++5L8Xth Fjjom6k7LmWaIfNlGwrP0M9Rn4GxHWtafReLczGYNT6Y4tCEmK73KLhZHOL8nGkGGryz ahRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706193427; x=1706798227; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+N5XQAayZgM276rPgCazC+JMbS0uzbwzoNPf1gEMYQA=; b=ej5Y12O1CrJIcCEouJYKpiBJO9/ko11yca4jzuA+BzPjdzsjWLddbh/F0qo6i1Pbds UzuheyXe16voivzpR5kAVy3pdqLMMvKEEAzpYNCWoR4HRop7UhGlaMTy8x/4HsH4F/zF wwRwEJf90YEgNeV7dtVd2Tj3g8mk7GttnUeGAhmIBVjwtYXUuSmbW6EkaqpQ2fVBFQNe UGr2mLD/rWrQKMLY7jw9C0pU3vXP0w5uLyCRNMHSdXbJbU88nKWBnRb3Wsu0XFjonQFd EpuqUc15Bhe98tLnieHorLDudrF2G4XLXT/yL/R7ym+NkaIuVit/w98T0yrMyEY8mTyN NhVg== X-Gm-Message-State: AOJu0YwGJrxHG9BoDk2RFv+r3LG+tEXSm6e9011KkQnyxki8RDPIXPgn TB4ZXf2u8+ypwErwr2hQn/8twk1bBGTUh6CbScnVKfis9XrjnO9I+uJDqTknY4o= X-Google-Smtp-Source: AGHT+IGs3o7wZDD6VJzuezIX0ktPG7wilQ0jcQWaR8BKd3udA01+8LyjxKr+DUfe0ol8eZ7VY2/FuA== X-Received: by 2002:a05:651c:506:b0:2cf:2a82:7871 with SMTP id o6-20020a05651c050600b002cf2a827871mr715556ljp.26.1706193427689; Thu, 25 Jan 2024 06:37:07 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id y24-20020a2e3218000000b002ce098d3f0asm292644ljy.115.2024.01.25.06.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:37:06 -0800 (PST) From: Linus Walleij Date: Thu, 25 Jan 2024 15:37:05 +0100 Subject: [PATCH 1/7] mmc: davinci_mmc: Map the virtual page for PIO Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-mmc-proper-kmap-v1-1-ba953c1ac3f9@linaro.org> References: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> In-Reply-To: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> To: Christoph Hellwig , Jens Axboe , Ming Lei , Arnd Bergmann , Ulf Hansson , Nicolas Pitre , Aaro Koskinen , Adrian Hunter , Angelo Dureghello Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-omap@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Use kmap_local_page() instead of sg_virt() to obtain a page from the scatterlist: sg_virt() will not perform bounce buffering if the page happens to be located in high memory, which the driver may or may not be using. Suggested-by: Christoph Hellwig Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/ Signed-off-by: Linus Walleij --- drivers/mmc/host/davinci_mmc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index ee3b1a4e0848..4e9f96b1caf3 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -216,7 +216,7 @@ static irqreturn_t mmc_davinci_irq(int irq, void *dev_id); static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host) { host->buffer_bytes_left = sg_dma_len(host->sg); - host->buffer = sg_virt(host->sg); + host->buffer = kmap_local_page(sg_page(host->sg)); if (host->buffer_bytes_left > host->bytes_left) host->buffer_bytes_left = host->bytes_left; } @@ -261,7 +261,13 @@ static void davinci_fifo_data_trans(struct mmc_davinci_host *host, p = p + (n & 3); } } - host->buffer = p; + + if (host->buffer_bytes_left == 0) { + kunmap_local(host->buffer); + host->buffer = NULL; + } else { + host->buffer = p; + } } static void mmc_davinci_start_command(struct mmc_davinci_host *host, From patchwork Thu Jan 25 14:37:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13530930 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 B312C6E2BD for ; Thu, 25 Jan 2024 14:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193432; cv=none; b=PTAEJecyh/C3WzMczazKum1OwXzGZUYc1RJV73aM8HwKERz78G8ShmS2IlomikQ9qH1nNfSNdxV6KCMZwEkK+ACgjlck7Ka5ORJ7UqIiqZOQ3LDBVYkqH1KZHLatjku0cUHOg5nrES+1BbOYSUU9cPR+PpJoesRnV3YwYD8EbP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193432; c=relaxed/simple; bh=GuAK1SrygrJ1Pbwv2s94cKHIzXqnBSS/RN81vD3QUOE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kG+OLO9luF/BzRYlLXF/vlZ4x8qopgA/ydGlyGQXwJmYWPpIkCPngV2G3snSsRodT+DgxrJLuTi6Ck+U97kwBqsBMbSiMYsuIS3HNzj8ihbjP2rUpr4yt7GG3kQTW+X1dHxwdWJDYT9GBvrT6+2q7GkYKUXcw3/g1QSRMysSwzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pu6svjJs; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pu6svjJs" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2cf2b218c62so22019091fa.2 for ; Thu, 25 Jan 2024 06:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706193429; x=1706798229; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+QFZ+mkC4kkjj+4EYDZYr6F/eopGpIChJZt5vmWI1II=; b=pu6svjJs3riuHSfGOJ+/eMw9uosRbEXcpJJZnsw51WpGvnVoAdrMMycQIoJvsGCkJH Ek0m4cnHYYT7zMtj8hM9t9TFS0CNHYufbF+8BiaVO+L8FxYhm3T18edmU6AgpgxG+Qeu nU7qt6CVeb/2O5CJ8T6T7jX/8trC27ycxPpPHtHhWYFZdkv81DieYDPPC2e3BhegzPW3 oMQK76/e99N6sWgZ1+XBObam9HgPvPLNPBOdsRtCl3NbVlHOYccTfl1VS209lX9pZfjF Q9+rpOA0N9gOkqfS1BxQPL/9gshnEz2/USzEIhSMP6qE1wkwXOKbL8NP3nSUv9a1zRxL YuXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706193429; x=1706798229; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+QFZ+mkC4kkjj+4EYDZYr6F/eopGpIChJZt5vmWI1II=; b=d1su/euPdGZ8LjK9gfRrIKs60eKEdCwYj/HJs8fnlX7uLLHFoPOdKKETLGpcxV9F+U rN0LJ4kv7moGBfF4OkxyhVOqtzCXa+LSw+laJxu1JGHJCAnkPkEpsgpimuw47dJUVJaM xqMPTSEVz7gLIoDioaXIIkiB1ABvRMV4I7hbJEQktLxWzmQZJNfyowp6vZ7fbUcriN0O z/qF/N6oMnUZxGW1x5Gsl3B4jCmHa6MJUw5T2FHNnyqBGzQFZVVZrHwOjvDo9P3xNkdw 0vYBbgkJo6u1XTmNj/sANRVMbzSVaYQzLplBw9CBJ5i5Kc2mQ6hgJ7nbrmUFm7zZU7N9 s9CQ== X-Gm-Message-State: AOJu0YxZ92mfvPkBQvwIz7O+CtUe9p+h3dC8GPpDP+7C+vtr8Zwgjp7o C9H98Byy5eTnqUfJA23mwglbMYr5DX7Uvu/oibY5K5xspdgQyrus0jgNTGSSrp4= X-Google-Smtp-Source: AGHT+IEjyNeOAVs0KsI2HYaw+x5O0V6Jfis1CPom+dYxNRm4InBqXYsV6heWEbkW9MhsFYXQf3dovQ== X-Received: by 2002:a2e:a7ca:0:b0:2cf:2efa:e14a with SMTP id x10-20020a2ea7ca000000b002cf2efae14amr464246ljp.6.1706193428725; Thu, 25 Jan 2024 06:37:08 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id y24-20020a2e3218000000b002ce098d3f0asm292644ljy.115.2024.01.25.06.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:37:08 -0800 (PST) From: Linus Walleij Date: Thu, 25 Jan 2024 15:37:06 +0100 Subject: [PATCH 2/7] mmc: moxart-mmc: Map the virtual page for PIO Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-mmc-proper-kmap-v1-2-ba953c1ac3f9@linaro.org> References: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> In-Reply-To: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> To: Christoph Hellwig , Jens Axboe , Ming Lei , Arnd Bergmann , Ulf Hansson , Nicolas Pitre , Aaro Koskinen , Adrian Hunter , Angelo Dureghello Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-omap@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Use kmap_local_page() instead of sg_virt() to obtain a page from the scatterlist: sg_virt() will not perform bounce buffering if the page happens to be located in high memory, which the driver may or may not be using. Suggested-by: Christoph Hellwig Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/ Signed-off-by: Linus Walleij --- drivers/mmc/host/moxart-mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c index 5cfdd3a86e54..7ccfe872415a 100644 --- a/drivers/mmc/host/moxart-mmc.c +++ b/drivers/mmc/host/moxart-mmc.c @@ -310,7 +310,7 @@ static void moxart_transfer_pio(struct moxart_host *host) if (host->data_len == data->bytes_xfered) return; - sgp = sg_virt(host->cur_sg); + sgp = kmap_local_page(sg_page(host->cur_sg)); remain = host->data_remain; if (data->flags & MMC_DATA_WRITE) { @@ -346,6 +346,7 @@ static void moxart_transfer_pio(struct moxart_host *host) } } + kunmap_local(sgp); data->bytes_xfered += host->data_remain - remain; host->data_remain = remain; From patchwork Thu Jan 25 14:37:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13530932 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 CE6426E2B9 for ; Thu, 25 Jan 2024 14:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193433; cv=none; b=b/q8xo7ppUYlhuW88l9K0BG6+7atsh+3CQ2rjm0jvp7LVcCxN2LHBhDAig8EDnewRNtbDyVWts8uCP/ITyen7zBg51pCnqfHLG9Cl7ZykevAJHtA+KvHkM3bWQRz8WWnf7fm5DjOWrORiCMVsFhePzQvTluxAkrYm9zwydLLdkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193433; c=relaxed/simple; bh=G4/hgPajp0i7ZbgcSS3IunhzrTBYec3u+HmofLpC6eA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QV1FV91mgdp4Y05XV3Si2BsQoD6518HtQxwIHMRYUUm13bxPMz0kGRvWaP1DYEIr3GQeYecQJcrl5uwPYSWOYQe6cCb9k/1y0al15B0tMNbsh9ztXko8F/ncXRJGRbXYNgv8+MlUFUDsMDDn6nA5jAeeXDzgqK7jevdSegtsxE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=XleSXefY; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XleSXefY" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2cf354613easo9705701fa.1 for ; Thu, 25 Jan 2024 06:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706193430; x=1706798230; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=f43KvRvUGeX/b0EUJRmkX0ZbThJsQoZyHADR9QN2mtQ=; b=XleSXefYnmRAn8b/0DPQu2sYAPmtMxWbaxtOg/scqryF/TV5gVCDeATbuiS+T7YfnL t1CYP5aXcROtx5v5Os2kkAy588Q8YO63STjZiZMr3JEUNBvc+3hJ3Llpj6OC1j5qcX7q fkcSCaTFOPUFePF6Z6RFbq2F34P7akWaYIczphNoLPU98A+SHz5mzy66KoqRYB1mE5D0 PxjOJbHvk8w+8ZkDdwveET0tQCU6nmVDwLBvxtDYHyC5ZCuWCUjdYFKUc19xOVJtSEBM ugnI7BeVz/7pkiUgrEL1MD9AyPtij9iYsvYQR6HjluJ5DMmyggcRlkQk50PZFkwvIH+s 6pJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706193430; x=1706798230; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f43KvRvUGeX/b0EUJRmkX0ZbThJsQoZyHADR9QN2mtQ=; b=XTjObpf4we8w7HNkAE34S6DiQjI5zA2RTpnzLL/BUB9bAvX7a/8MvzA7EtJMUMtbXT QYzibgt19XFhVBndqVuw2CvvdYfWkqaGbYxrCxm/cGDcWxLkEr9kQZjlas6E1+r7V/Q8 DiNvXwMnbrhc34siNgNOhsvkVQX6ONqUIcBRKcFaq1LjKzuIk0XcuIto0YiQ+AUGjEGv u4r6iLh4nQSfbHt8DESgRotNGsmB8sLEqcBu+66h05KKeQxJld0M6hOw1Cb2q1C+yNXM 5t+jue/QtjknhbDkWd4Qas8woC3itRReDpkDs9/7Usfls12+JlqqQEeGDcNF7UbaDK0y ScjA== X-Gm-Message-State: AOJu0YzEXeLIye7kst6mSr0be0Vidpf01XukdZmeFGhAlA6GTaKygrX6 AqDZbZHwMAgXddEOmYl4BVh1UHcGv+8EeJ1T/QA5ovPbz0p0p89icRyTYg2NoCo= X-Google-Smtp-Source: AGHT+IHlljf93ZvwCDfA3yWKFoRN5Nc0r9yERDrrItXR8g5zHO9eHlJ2iaQUkWwkQKVa4fEPwIhv+A== X-Received: by 2002:a2e:9997:0:b0:2cf:3ee1:3ec8 with SMTP id w23-20020a2e9997000000b002cf3ee13ec8mr352461lji.97.1706193430084; Thu, 25 Jan 2024 06:37:10 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id y24-20020a2e3218000000b002ce098d3f0asm292644ljy.115.2024.01.25.06.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:37:09 -0800 (PST) From: Linus Walleij Date: Thu, 25 Jan 2024 15:37:07 +0100 Subject: [PATCH 3/7] mmc: mvsdio: Map the virtual page for PIO Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-mmc-proper-kmap-v1-3-ba953c1ac3f9@linaro.org> References: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> In-Reply-To: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> To: Christoph Hellwig , Jens Axboe , Ming Lei , Arnd Bergmann , Ulf Hansson , Nicolas Pitre , Aaro Koskinen , Adrian Hunter , Angelo Dureghello Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-omap@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Use kmap_local_page() instead of sg_virt() to obtain a page from the scatterlist: sg_virt() will not perform bounce buffering if the page happens to be located in high memory, which the driver may or may not be using. Suggested-by: Christoph Hellwig Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/ Signed-off-by: Linus Walleij --- drivers/mmc/host/mvsdio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c index ca01b7d204ba..a004a523bd2a 100644 --- a/drivers/mmc/host/mvsdio.c +++ b/drivers/mmc/host/mvsdio.c @@ -115,7 +115,7 @@ static int mvsd_setup_data(struct mvsd_host *host, struct mmc_data *data) * boundary. */ host->pio_size = data->blocks * data->blksz; - host->pio_ptr = sg_virt(data->sg); + host->pio_ptr = kmap_local_page(sg_page(data->sg)); if (!nodma) dev_dbg(host->dev, "fallback to PIO for data at 0x%p size %d\n", host->pio_ptr, host->pio_size); @@ -289,6 +289,7 @@ static u32 mvsd_finish_data(struct mvsd_host *host, struct mmc_data *data, void __iomem *iobase = host->base; if (host->pio_ptr) { + kunmap_local(host->pio_ptr); host->pio_ptr = NULL; host->pio_size = 0; } else { From patchwork Thu Jan 25 14:37:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13530933 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 DDE0F6E2DA for ; Thu, 25 Jan 2024 14:37:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193434; cv=none; b=fuFI45NnV82sMOzW8lpaa65bGgkGD5xhvg1b9yE5HvNG5wa1F5CQZDohRsNeo/JNdY26ohTnxU12VqdB5KarR4YOkKqVk/WDspYkvneluIg2iSqs/4/HoeEqK8m7kOyMhiLjVnfSqKIgr8PZzwUPss3QgBE6jGUmyaLRVeVBlz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193434; c=relaxed/simple; bh=pUZtYFBBlHN8KyLIIWT/pGwPDvdvelKcOTK2YttzmRw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ELwRU76JCcRdPer0Zd4a3/jva4rsGF1YbXshDzsiEGyX39TAQJWiurZQHszxbHWAfWSbe2WnwdFTcHeecGYXGGZCWNjZBuswnJJHqXSts9HvgBNETEfSm/Zx4TrWMMKPwBIZAzqRVggPIeByPMLw/jzTT/ElL/GszRBFeMTwGCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SmtdUXOm; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SmtdUXOm" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2cddb0ee311so74251951fa.0 for ; Thu, 25 Jan 2024 06:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706193431; x=1706798231; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zyHJ1LdSzxdGYRgoY28wDm0mOxVwJzTlbadUPi2PKz8=; b=SmtdUXOmEMILtfyQWHXeo94UuVONO5iCga5GN6evKF55vH7Gk2oiKL5rQTLUBOsLyq J6+ZqsgHFyNkjuuulOdL3/klcEbijmPKlZZ5aWVsvfsk8/AP+8NSiWA4YyxJbeLU+lbz Q7wwCDaMsSdFoSEvICkpMup3LaSikNvsP7tgWWVdQU5L+LfSRWPoxkBPhOZ37T7aoUsE 5QuEhiKN9wN4iZAKsKLPtbiboxNl7O/c9SWFW6Vx/g6ZjaUBBEWgnrL1K5bU967WxTgs j8IZlCwhSHLYiajAFe13VeQZgncoIw1WnTcCyObEGgqIHI6W075sEqlidvPEb46uM+VA JrrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706193431; x=1706798231; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zyHJ1LdSzxdGYRgoY28wDm0mOxVwJzTlbadUPi2PKz8=; b=IGq/ZV5JaLJEV5RrTYN/CvQ2exp+w8+EY6YrSlPRHqpJpwWNDnmN3zgf6yczm2qwid xuQsvr/fwjRmJUbGHqc58AtJMvOfOe2R87ovzqdkFIDQ1l/G3b8cMhDnJ8aBLLnipqfH oLGZkm0M3RswRlS9I6mki+NE6rHVybfVIDzbCuJS5rkiZU2tg8qK06+5LRDca382mukk 2fTbBR1zjcVPFLANsq14f8S+RYxN3+na+oQvfWTWcK8O5fgsrwLK90uzCER6QWWuVwZe 2MYMiQVaZDz7+IHDVzMGWCOVoYkMxtIQet2n/AGW+iuxIWcWWhAnL+Mlzqrja0LCgJ5Q wDKQ== X-Gm-Message-State: AOJu0YzuVpKa8pph/7R7rSNc3xWtd5hbJoLdYzV7yL/HgN8o0KU3lkFw esL6EKYMqIHiiEFETjU5BC+Pc4oe+GgHRD1aIpNyECadUyTJZKRAdOj4eFZPJBg= X-Google-Smtp-Source: AGHT+IFrJ8hL28N/GPgAO89+Cnk9L5mTBanlXR+Nwy7guR2IiE861T+3zzVsxJRpdO2fpqS6NSVwhg== X-Received: by 2002:a2e:9890:0:b0:2cf:34b4:63e2 with SMTP id b16-20020a2e9890000000b002cf34b463e2mr370061ljj.204.1706193431049; Thu, 25 Jan 2024 06:37:11 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id y24-20020a2e3218000000b002ce098d3f0asm292644ljy.115.2024.01.25.06.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:37:10 -0800 (PST) From: Linus Walleij Date: Thu, 25 Jan 2024 15:37:08 +0100 Subject: [PATCH 4/7] mmc: mxcmmc: Map the virtual page for PIO Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-mmc-proper-kmap-v1-4-ba953c1ac3f9@linaro.org> References: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> In-Reply-To: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> To: Christoph Hellwig , Jens Axboe , Ming Lei , Arnd Bergmann , Ulf Hansson , Nicolas Pitre , Aaro Koskinen , Adrian Hunter , Angelo Dureghello Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-omap@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Use kmap_local_page() instead of sg_virt() to obtain a page from the scatterlist: sg_virt() will not perform bounce buffering if the page happens to be located in high memory, which the driver may or may not be using. Suggested-by: Christoph Hellwig Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/ Signed-off-by: Linus Walleij --- drivers/mmc/host/mxcmmc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 5b3ab0e20505..04c0e4ea02ff 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c @@ -267,10 +267,14 @@ static inline void buffer_swap32(u32 *buf, int len) static void mxcmci_swap_buffers(struct mmc_data *data) { struct scatterlist *sg; + u32 *buf; int i; - for_each_sg(data->sg, sg, data->sg_len, i) - buffer_swap32(sg_virt(sg), sg->length); + for_each_sg(data->sg, sg, data->sg_len, i) { + buf = kmap_local_page(sg_page(sg)); + buffer_swap32(buf, sg->length); + kunmap_local(buf); + } } #else static inline void mxcmci_swap_buffers(struct mmc_data *data) {} @@ -526,10 +530,9 @@ static int mxcmci_poll_status(struct mxcmci_host *host, u32 mask) } while (1); } -static int mxcmci_pull(struct mxcmci_host *host, void *_buf, int bytes) +static int mxcmci_pull(struct mxcmci_host *host, u32 *buf, int bytes) { unsigned int stat; - u32 *buf = _buf; while (bytes > 3) { stat = mxcmci_poll_status(host, @@ -555,10 +558,9 @@ static int mxcmci_pull(struct mxcmci_host *host, void *_buf, int bytes) return 0; } -static int mxcmci_push(struct mxcmci_host *host, void *_buf, int bytes) +static int mxcmci_push(struct mxcmci_host *host, u32 *buf, int bytes) { unsigned int stat; - u32 *buf = _buf; while (bytes > 3) { stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY); @@ -588,20 +590,25 @@ static int mxcmci_transfer_data(struct mxcmci_host *host) struct mmc_data *data = host->req->data; struct scatterlist *sg; int stat, i; + u32 *buf; host->data = data; host->datasize = 0; if (data->flags & MMC_DATA_READ) { for_each_sg(data->sg, sg, data->sg_len, i) { - stat = mxcmci_pull(host, sg_virt(sg), sg->length); + buf = kmap_local_page(sg_page(sg)); + stat = mxcmci_pull(host, buf, sg->length); + kunmap_local(buf); if (stat) return stat; host->datasize += sg->length; } } else { for_each_sg(data->sg, sg, data->sg_len, i) { - stat = mxcmci_push(host, sg_virt(sg), sg->length); + buf = kmap_local_page(sg_page(sg)); + stat = mxcmci_push(host, buf, sg->length); + kunmap_local(buf); if (stat) return stat; host->datasize += sg->length; From patchwork Thu Jan 25 14:37:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13530934 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 D5DE86EB47 for ; Thu, 25 Jan 2024 14:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193435; cv=none; b=lHJdVLW2ZZ13lKi8tCYzzW4tj9EhZkAlu5gXuQRRcgGZqC4rwLjtUNqwxkCD+mJsMche1PUUzCvRDysjFuzm8cKdFTvzZbiMI7Gh7sqn4OxeTkTOR0ZHlhsnMVd9xJOr/gF8hg6BfEsSV6H2grcTr13w9jT+8eEooQNA98lBBFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193435; c=relaxed/simple; bh=0MaLjPvVAK/Cs5uLyHsHrUqQa22L5UcKTRzT/Bd+/TE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nkIwB6DGC1/Kdd53L5LBu3IJLlHgnHkn96Tp2sGv+zZxNx55kDAWpRLQ16vdhLqJjN1RbRANX9vT91eGndfGxL8jPPoe03l0Wktwv6L69ZXz2W1IL/aBz6CouspYc+VUx+6Ze71a5ZRRRB+pl1WddK/Belbui6XHsCeDms4Cgd4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=AzuRf5mY; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AzuRf5mY" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2cf338e1438so8395841fa.0 for ; Thu, 25 Jan 2024 06:37:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706193432; x=1706798232; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QMZtopgbN/6mQ0cUEkngEk6XwZC8BFLt+hjmWJEWvjI=; b=AzuRf5mYFkYYq1KgoxCGLREJC+z+q5yoKObRTy4qqG1+Ilb6SPtsJmIdCXAVW2tACu J+sHv9yPU8mIQW6MVx7BBlzIrFIYiwHTlhyHUjQ6dprMdk3Mvdo+neSOZz/Wndztfj4v fuSddKt7uXW6mqgrRGisDV5M97tqIqky7xkFVl+KMCauTrMKNholsqX106C8hAvWw6Xw tgknanGLdGIa94Lj3Hsnd7jWZPER3Zx3NV7gTXxTwm4ag2Zjn+8Htow9O9/K3D2+LDuD bT6Mclt+v/l+ky3sPPKuvT7OYJxp//CacJ7sUfxOB0TojgDB61U9li7Beb/fVQ8GtV0G gYzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706193432; x=1706798232; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QMZtopgbN/6mQ0cUEkngEk6XwZC8BFLt+hjmWJEWvjI=; b=mspVtnwOmWS21t1opzJ/MN+jVGSOLOx44Gh0Lw/77yjPhA30377eU8FBBpvOTk29u1 pkI0Q4N2roELF2fQ65CBqJ1L3P21OuuuPlMmmOveD0oYkys7LOkkcYkxx16VQ+u7WUYL oiqyg/vIF0A0mv49bxW5psLKI8Ev493vJlyf78Vk+l0p+9piMp3ec92W/R1K4qyBhV90 x9RZzIrw6TTKnooIEYMZovcuHZvc49o4ySgAQ38ZuRygc0aIlhHZp42z9pEb+R6sQmKD pY76loD62l0w+U4/lmYlB4rpCAghpmC6X4oCXRkYcIdqgqekGX7rXKkSsTu/qWB0bgPM n+Ig== X-Gm-Message-State: AOJu0Yzsdnn39B5mNhOItSqoudRMGwHmnb6A/3Q1UzgbCnUmDBhzi0yQ c/LCYVNvMOV7Qny9M4lP9DD9pj9e4lCTGrBZI8jPUUfVVwxwz5mULZ76Te3yH4o= X-Google-Smtp-Source: AGHT+IG8fvrFL4nSLXe+ci61toej0QyVWsGZLLzDkrvRpvcBhGeNxbHJDgzn0gMd+tOrjICpC3tOsw== X-Received: by 2002:a2e:bcc7:0:b0:2cc:78b7:1ef0 with SMTP id z7-20020a2ebcc7000000b002cc78b71ef0mr979999ljp.4.1706193431959; Thu, 25 Jan 2024 06:37:11 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id y24-20020a2e3218000000b002ce098d3f0asm292644ljy.115.2024.01.25.06.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:37:11 -0800 (PST) From: Linus Walleij Date: Thu, 25 Jan 2024 15:37:09 +0100 Subject: [PATCH 5/7] mmc: omap: Map the virtual page for PIO Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-mmc-proper-kmap-v1-5-ba953c1ac3f9@linaro.org> References: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> In-Reply-To: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> To: Christoph Hellwig , Jens Axboe , Ming Lei , Arnd Bergmann , Ulf Hansson , Nicolas Pitre , Aaro Koskinen , Adrian Hunter , Angelo Dureghello Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-omap@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Use kmap_local_page() instead of sg_virt() to obtain a page from the scatterlist: sg_virt() will not perform bounce buffering if the page happens to be located in high memory, which the driver may or may not be using. Suggested-by: Christoph Hellwig Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/ Signed-off-by: Linus Walleij --- drivers/mmc/host/omap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 9fb8995b43a1..3e36480b22ad 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -659,7 +659,7 @@ mmc_omap_sg_to_buf(struct mmc_omap_host *host) sg = host->data->sg + host->sg_idx; host->buffer_bytes_left = sg->length; - host->buffer = sg_virt(sg); + host->buffer = kmap_local_page(sg_page(sg)); if (host->buffer_bytes_left > host->total_bytes_left) host->buffer_bytes_left = host->total_bytes_left; } @@ -691,6 +691,11 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write) nwords = DIV_ROUND_UP(n, 2); host->buffer_bytes_left -= n; + if (host->buffer_bytes_left == 0) { + kunmap_local(host->buffer); + host->buffer = NULL; + } + host->total_bytes_left -= n; host->data->bytes_xfered += n; From patchwork Thu Jan 25 14:37:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13530936 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 87A226EB4E for ; Thu, 25 Jan 2024 14:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193437; cv=none; b=NpBw1m4vRe0mkFGgC+5IHdUqbD1F7/ZJ33teyfq90oc/bUAcMQH6cxvOxVbFIYlT4u5O0PbScycUDdJU2mcBsFau1lWWeZTyMZGjWnMrwXdNxFEnPERl6QGHHIZgkCwRcDk5PaqpeXibgTJP4vlZi3CWOv0AJ0tHPRRwVsP08Co= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193437; c=relaxed/simple; bh=Qs//UMnixr5IUp6jilmOnSE7i7QVfxi3SrizSBiLzF4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sTqJHRogkHesknbSIlgvahyX1/wMTzDY0TbysVvTMtYhJ6PPtIENGnlO1UIjQDbobxBBZl6OhewtUvpjbLh43ujpWitp6uZ5Z+I9wKL4mNylwY+qpXLBYW81FkOnCXQcUiqCM66rXYOZ7KIxmjyCT01pDpRKHMAOkNYUbAxj+P0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FgviSqIx; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FgviSqIx" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2cf338e1438so8396031fa.0 for ; Thu, 25 Jan 2024 06:37:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706193432; x=1706798232; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bJBLYCKXFwySdbkU5jNVGgegDvui0xTSvQmfM70ZSEk=; b=FgviSqIxltqJDnUcgyL4fGiH6UPmwn1BrCqJpvncZd5lLNvubQcrzIjzJLoIsODfol /bqK9UYHLbRJyzJnMiP0kBtRnXvOEvLBvjhxkO48nqp4yWkznbUDwVdq4iRLwDikOO2O eSxO5zrRWd68rPJ3CfYiYX1Q8QHn6KY2Q/bE6sKLEBQOyxh5fFQ4/lO+nYN7mj+Hl5kp 9eTwYvlgUJXEZEZGlLpB0RpJZ32AHBBN2kCYNzOvu4KBM5MoyjK8kq5EXpF0zjfFq2MT CZiyiFDPJk5pNCvUz6fkcJ0w+kS50ZpsM64xiFMCQejir7GVUsu74L62LWpu5awoamcu JfJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706193432; x=1706798232; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bJBLYCKXFwySdbkU5jNVGgegDvui0xTSvQmfM70ZSEk=; b=XCTbYXjlqi3EUODDoTA1+qdmh5fHdhkW/uPGbAR65avrRqBlsoXHHuFiH3owcUoEmh w+eru/86peNrUQkv80qgiGibWU9phD0ivqEW7Id54ojuOTu106i93qaNaPZvVq3BOrZa mKt+9lkWu1N8G8h4M0FQ/+lXdWtrT7tokxyt+wO1VNmAfBOO+fS+6KHivyhkPxFMF5H9 k+8FnUw8giG68aaOKnfHsPWTKXcFbTI5CUm9TL7LnZdZv/EqXFMcr8eesfbgkk0T6x9w hjhJGc9sJVE6Z536amFmrRP2WnExyGrfRkSwEn9j7QfxC8zhi7sVbSPbUZC3nnpqgCuN kgQw== X-Gm-Message-State: AOJu0YxmS8YVl6rNcHmuxjRvlaHhsrzqKoJepyn2sJCqDED7ruHajPcK QUEX2s3BwH2Q1+hyvayLEY4jRdXdAuvbR4fsLvyV1WSw1fq+GeokpUsu27QU9hAhKthrbJ4R/8m 1 X-Google-Smtp-Source: AGHT+IHyoh6DqOZQxyE2KVxGS/rWXgxchalYubf3yeda14PSRbE8B6cvrgMcdIMq6MgeVioRNGja3Q== X-Received: by 2002:a2e:90cb:0:b0:2cf:329c:31d3 with SMTP id o11-20020a2e90cb000000b002cf329c31d3mr596119ljg.25.1706193432776; Thu, 25 Jan 2024 06:37:12 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id y24-20020a2e3218000000b002ce098d3f0asm292644ljy.115.2024.01.25.06.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:37:12 -0800 (PST) From: Linus Walleij Date: Thu, 25 Jan 2024 15:37:10 +0100 Subject: [PATCH 6/7] mmc: sdhci-esdhc-mcf: Map the virtual page for swapping Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-mmc-proper-kmap-v1-6-ba953c1ac3f9@linaro.org> References: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> In-Reply-To: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> To: Christoph Hellwig , Jens Axboe , Ming Lei , Arnd Bergmann , Ulf Hansson , Nicolas Pitre , Aaro Koskinen , Adrian Hunter , Angelo Dureghello Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-omap@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Use kmap_local_page() instead of sg_virt() to obtain a page from the scatterlist: sg_virt() will not perform bounce buffering if the page happens to be located in high memory, which the driver may or may not be using. Suggested-by: Christoph Hellwig Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/ Signed-off-by: Linus Walleij --- drivers/mmc/host/sdhci-esdhc-mcf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-esdhc-mcf.c b/drivers/mmc/host/sdhci-esdhc-mcf.c index a07f8333cd6b..ed851afbf9bc 100644 --- a/drivers/mmc/host/sdhci-esdhc-mcf.c +++ b/drivers/mmc/host/sdhci-esdhc-mcf.c @@ -314,8 +314,9 @@ static void esdhc_mcf_request_done(struct sdhci_host *host, * transfer endiannes. A swap after the transfer is needed. */ for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i) { - buffer = (u32 *)sg_virt(sg); + buffer = kmap_local_page(sg_page(sg)); esdhc_mcf_buffer_swap32(buffer, sg->length); + kunmap_local(buffer); } exit_done: From patchwork Thu Jan 25 14:37:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13530935 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 757626E2DC for ; Thu, 25 Jan 2024 14:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193437; cv=none; b=sMOTc8evFVDi2kAgr3X5JVONJ6C+E6SLvVyQvwL4dYLZmp5a0D+nT4ak54vdP9oe4kH7ARh5s8DPPEQbjf34ZCuA3h+70x7Nv8vPB+VJN6cPCQsGQWWkWzoaKnuBcrsYVm+gYU2Oq7zf+//2QSW3rbUMdpaHmn3d0PC5OZmZvGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193437; c=relaxed/simple; bh=dUmbPvU0C8VRoo9iWbxEG6uM01EkIK75bcOiAdjB25w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nwBo+FlAOEab3aa/nY+gUb+mii2o+J4qOlQdBl+9jd0haQ4P3F9R1C3BRKrpx8lMNsz95rNiq7T+qCts+5RhPMzuYNA4kbGxLNOem2CHRJ+BNC3zXInM6/Fe8+JVcNnN37z1ds5/snmULvf0lbl+EwBSHHgKz222LK+YEDX5Ew4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SGD+fkCN; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SGD+fkCN" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2cd33336b32so91434551fa.0 for ; Thu, 25 Jan 2024 06:37:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706193433; x=1706798233; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0p/ZF4Qoyc/L5BPHTulDTqASzKK4BbFP5+9sQzchQas=; b=SGD+fkCNkm4T6il7tamKcdiyYox6b0VQ97GEy+Vea2PwX2YV8H+2S5MD92XUqO4FTS L0YVT59MZ8Tcl5jvSthxmT5ZAQg9ZPB2WalQxkUMxUspNNh7vPnj4ZTEmnjthCNPQEba iZNWa8rP7G66oEcejUqJk5TKV6hRQgdnZGwTFC+SvNrPZENEHKCNzuTA7cUqJCiVUNBM TOc+OWM1A8E/RsLwQivMRZPgNks3xylmsnrfL+9l5SgImVm3p0lMGG705MZHPg0dSMuF o+qAMw/ax098kNIJpRsWaLITgOPx8LU5n7vmuVkQ0+gPUZJvLyQ8Lo00/XY/CbV9YIf3 7uKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706193433; x=1706798233; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0p/ZF4Qoyc/L5BPHTulDTqASzKK4BbFP5+9sQzchQas=; b=lp0HYz8g201HRw2gLpul4ZG6TkPLB30H/GVtruXUUKoJ7gjgXyPwKU7EShYHAThrZn cEOQqZzj6U5C+znDH2308dMt/AXvLXbse7MZp+yC3lg2MLq7F+/8oeaNIDPJGPLub10Z GjkS1pKzYxRCbXlYPschhgl+OWLOPdOJyPMRFhnPoSgLXjpHO3zOjeipgdOPZ1A1R2VZ vkwZxA7QznCqPiGQdPrtfM2D4MJ9AULPPUa2dt/2YSBJEl/bw4QnoN2+bdnCNJipCgNk 36VItQzspdAurbyAhVHRT02lGAMl8vbAeclDBzh/AdAq+vg6QgKkA9x5YAXEvaOVFX4t FNJw== X-Gm-Message-State: AOJu0Yyu/WeVIGPbLxZjN6fTo73pHgjgfbzvy31PINyILZmrgLsAHTLX 1TdRwyWKRWuGVZ9bRheqfMdf6tKNEkiThLMARaGON0czTehtdI3qdEaq+Ys+vf+okesghMSLFwd + X-Google-Smtp-Source: AGHT+IE2j/hx+TjW/VFSr9+UBY3Hbz0FN2hxOgkz7PQpgoay1lOTJOQqMnIpUCN7BuM5xSBcSZQTKg== X-Received: by 2002:a2e:995a:0:b0:2cf:1c41:39bb with SMTP id r26-20020a2e995a000000b002cf1c4139bbmr731800ljj.69.1706193433640; Thu, 25 Jan 2024 06:37:13 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id y24-20020a2e3218000000b002ce098d3f0asm292644ljy.115.2024.01.25.06.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:37:13 -0800 (PST) From: Linus Walleij Date: Thu, 25 Jan 2024 15:37:11 +0100 Subject: [PATCH 7/7] mmc: sh_mmcif: Map the virtual page for PIO Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-mmc-proper-kmap-v1-7-ba953c1ac3f9@linaro.org> References: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> In-Reply-To: <20240125-mmc-proper-kmap-v1-0-ba953c1ac3f9@linaro.org> To: Christoph Hellwig , Jens Axboe , Ming Lei , Arnd Bergmann , Ulf Hansson , Nicolas Pitre , Aaro Koskinen , Adrian Hunter , Angelo Dureghello Cc: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-omap@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Use kmap_local_page() instead of sg_virt() to obtain a page from the scatterlist: sg_virt() will not perform bounce buffering if the page happens to be located in high memory, which the driver may or may not be using. This code is a bit asynchronous due to being called repeatedly from an interrupt handler, so it would be great if someone can test this. Suggested-by: Christoph Hellwig Link: https://lore.kernel.org/linux-mmc/20240122073423.GA25859@lst.de/ Signed-off-by: Linus Walleij --- drivers/mmc/host/sh_mmcif.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 077d711e964e..f9f56d653ff4 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -611,13 +611,27 @@ static bool sh_mmcif_next_block(struct sh_mmcif_host *host, u32 *p) if (host->sg_blkidx == data->sg->length) { host->sg_blkidx = 0; + /* Unmap previous sg and map the next one */ + if (host->pio_ptr) { + kunmap_local(host->pio_ptr); + host->pio_ptr = NULL; + } if (++host->sg_idx < data->sg_len) - host->pio_ptr = sg_virt(++data->sg); + host->pio_ptr = kmap_local_page(sg_page(++data->sg)); } else { host->pio_ptr = p; } - return host->sg_idx != data->sg_len; + /* + * We return true of there are more blocks, and false if there is no + * next block. + */ + if (host->sg_idx != data->sg_len) + return true; + /* Unmap the last buffer if any */ + if (host->pio_ptr) + kunmap_local(host->pio_ptr); + return false; } static void sh_mmcif_single_read(struct sh_mmcif_host *host, @@ -669,7 +683,7 @@ static void sh_mmcif_multi_read(struct sh_mmcif_host *host, host->wait_for = MMCIF_WAIT_FOR_MREAD; host->sg_idx = 0; host->sg_blkidx = 0; - host->pio_ptr = sg_virt(data->sg); + host->pio_ptr = kmap_local_page(sg_page(data->sg)); sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN); } @@ -749,7 +763,7 @@ static void sh_mmcif_multi_write(struct sh_mmcif_host *host, host->wait_for = MMCIF_WAIT_FOR_MWRITE; host->sg_idx = 0; host->sg_blkidx = 0; - host->pio_ptr = sg_virt(data->sg); + host->pio_ptr = kmap_local_page(sg_page(data->sg)); sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN); }