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: 766734 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 101766E2B6 for ; Thu, 25 Jan 2024 14:37:09 +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=1706193433; cv=none; b=QKs7K9TT7ExxclNwnTpQvs+iVju2v1BjU82jMQp7y3krZlLkHbOy93BZZ8v4hI4hpxPndkk0mz/wyJcwB5GArRmcI9ZJbz5Jp2WPA4m/2q5yfdlZRnCDwsB3oBzW/7VLtzDQz/Kmdeer1ns7zPbEwO9najidszWol0CNoxyzH0A= 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.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="iF/8jP/0" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2cf2adac1ccso20287121fa.3 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=X7xpflI8R9f/i+6ED574GdDnavhkbZAvm08EPgEH8vwhL7+ASOVUTCishMylHbWU7Z 3GFBsp+nYCkwbRO1SYNIn1v175dboBVFL3lq/XR+aARhK7dUudtjFcTJGnO37jnuynTe Cpz3t5IHrHUyGdJvUNqjypqu+akXAqFmvJZGoN+gwD0++61ggDEGCU3v4PaYBcjMaORp b4BLNoxmqDz9FzGJnQhOZhBJE/A/pocC3ndHbNQ7NQWkgT79fDPZP0uo+1qxDC560q64 NyAKSwETdN7MSq/zamcgh4WaxX/x5WMEnNJ/OA8qV5SAMOAGjGpBpOqtHyt9yNJWiSE7 paYw== X-Gm-Message-State: AOJu0Yw6gwLKql4Rju+U9ei0i0YRQ03OinYwO+USDAv/W6DC0M/Hw3PZ w3gGnHM8PfkcWlaua0e7vdatjvCdGAQy6C+M5/KrzkEZqTREARsfqLjsyNDTaVY= 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-omap@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: 766735 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 C80676E2C7 for ; Thu, 25 Jan 2024 14:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193432; cv=none; b=F9RSgvKhmhv60LbdTbFSaWYV82ihtrxq6o38rXtUS1Xtuzw2V8+ScA7F4bcYbBTY43H1sK36MaBaHiXzkYxE7GMaT7KmsQJ0ZEYPWYihGTPBNo55Nw/AO+iZ0cRCYMbFt54gSisbP7+Sv0qEN8GzXKy9WocPIJeIdmkt9VlBu0A= 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.182 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-f182.google.com with SMTP id 38308e7fff4ca-2cf2b218c62so22019071fa.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=G9npk694E3Cvh69abR3ZOkQaDStiDQH7mW5feWNtLwQaOnjHZnZHieavQ0gd2O2nH1 yaP3n4V0lTTIhBkQDTr+9h+vyYdDV+S9iW02hg9oWVGPsI+ll+XpKWFj7renGSdRDrjL c8rFM8LLtqhRZ8jW3xI0QXSqIOWl6hrP+LRJdSGNIRSywV2TzVJZJIPNqwtV9a1BBycG A5cFvhmGaU1EtijVyb3XSDdZQ3zOP21FFxb0WHQ24Hc3PiZIlhXVNCufEoVCFdb+S6vE LuGU/ynBc59B964++hda+LLdIEXZAbHf4ul50AQc7S2WJGLreDZ5MzhCh5G8U3Q7EMpa wznA== X-Gm-Message-State: AOJu0Yz5rzdb/NGfNOTFmOvmyx24H/uJrSPFP0xh12eIj+nH7Hywj1lu +uCJYtpJU7OQj3JgmGr/VV2zgsDwDWQyOPSidNMhcqoWiLi+KA9/YNa/Ap6jPaU= 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-omap@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: 766231 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 EEDB36E2D1 for ; Thu, 25 Jan 2024 14:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193433; cv=none; b=sP8bKxYZ/JY94BdPUuYZ045nlMPF69o6Z8qTmXeEhdYPaqA4Ady0OMlTTho8zIh3Fq8/sNNQf8rJdyBlhhYu9TrF+7PfPXyAZc0pbDvIoXmbY68EAyk9zzMs39HffJxuKsq5U8hluwIj8shlDgp/BtElEg5prBnA/KSuNHv5IrU= 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.182 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-f182.google.com with SMTP id 38308e7fff4ca-2cf35e5c2ddso7427841fa.2 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=lFUcExvW5eBvaxfqpmoVgSWbinQlk5YWuIlprmiCv3TTLBffJHajDAkGgwWunUfvxL PJ3m7rB/yUoO+CL3tOdKoU1HuifgHL3DoChHHEeWHFXKyf5fZMH1xvk1kgDty+e06jan 8eJ+Lba0YA1DNH71ptwpG6Li7N+e+8aqp6199DWYpawA9Kk388/muGgMcPO7Ak3jTVzy u6wTOcGVlbMSN8/HKfI0IZWL3WsqPuvIyZYwTDxwpPKcYxBfzquLLk+iHR4xafS/e9zq uBZZjBMNlPX+0Erl7Ik/yPPwM9hjdtRDvUNE0AhC+AbI4UCQWBvuXOIrvQaOcc2m+8T3 6PTQ== X-Gm-Message-State: AOJu0YxJWGmRVEYvYrao3YJv8ZwY9+N49OF4kZsP0LkZR6P4kjKyUUYl pGu/+jkFmzd7sp50IL6h18KJFi3eaXCllYbtB/rIqI8y5g8v+nudYI5cjtnVxM4= 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-omap@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: 766733 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 DDDC16E2C1 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=1706193435; cv=none; b=nvGtCB8BLgBRthQliXUZSJ1iG3IU2oe4LYspnK7pynagTkg1W7/SvWgEcajEKXVXpjLBzmVmDtZLku7V0FN05J3COTPyZHcqpqspvuenxUhAp1qTOXSl7sXRanf6YUkKx7rc9wIaswbiqkegM5HDCOQqEtp0f4Rh1SIcDQJx/lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193435; c=relaxed/simple; bh=pUZtYFBBlHN8KyLIIWT/pGwPDvdvelKcOTK2YttzmRw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U/B5BhD/PYAMK8sR7QKcXcOYjFfCCL0FLC3aJo0DPOPFZG0KSl4cypPxjaHocM52UqHhvwrmTHiJASPCwvIA76yAMxjaNuPth6c4y291jJpeKU5RZR0z5e0GywPT60dZwphp9UZEnDn5L8TFHSLh8FfPW8BRoREY/MuvjIRubwU= 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-2cdf69bb732so74438731fa.3 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=MvxyZdKtOwnh0qDxFTkdUGqrwcY19L5tqsa6Od75BI6oA6Xe6a61bhZf52XBCUmgVv SvTft5MV+cku5aX98pSYTSv0R3M3SSqGq5HNSUk0yBThStmQ6gmOsvd6mSqQKH+Svf9w 53wIMh+aKLU0agg9SXN7z/EGKl0g0eIA+74CLSrrofI5h4Jm/eNFgovjiNj52p6lavUm A7+nUlKE/xIRypXQ+DEIAAfQNM29uIpLWtX2oPCCiPUxf8XQwMms2Z4ols5WEUzf9mId YuvkhF3ihojeaUpwJXjHmW4Wiv4RpoQQG9mz1e9bFqn9r1/I7J/VJlyVZsvonq5sUnsg bnZQ== X-Gm-Message-State: AOJu0YwV2cF+T2occWmSIuoSzV+Umm5CQ9MTYnZeDg3CqI48CDrFa7j5 tHuMRuRLPmfb0iVojew99pJox1AKsu0JztDq55JUkgTy07lqj55b18Y/ftEq0c0= 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-omap@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: 766230 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 C04616EB44 for ; Thu, 25 Jan 2024 14:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193435; cv=none; b=eGcQNNHDEhC0H8XME1/CowhlG+KvrXXmMd4G7b1sClREu8AtTZ2YItdxObpaNyKTCkcHmo+4NN2M2WPPJ59hjN8lkGey0wmUnBO7MSVOK67Jk1jl5jblvFfRVQc7LZV8s9QN5FRPllF7N1q28/onhLDcR2+0dAfJHv35QDcdHnc= 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.179 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-f179.google.com with SMTP id 38308e7fff4ca-2cf33b909e8so7533731fa.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=YKD+ZVzDQdIHz0vEH/PUBIso2rbqKPwAGP2PoMInp9zVEhDdc7TMnUckYrlHW2R3Xr GZhibxcetObbu5HXsQ50lO4ZWmLWdfoqIArrVnYvJkfm7Rf748P0cdrJl8qZo8HyLsh9 sFJDhjzijwHkwjk3OqpRZhbJcJPc1NTumDMrI4yqHFPDGTPZE0BuhX5mwvBNTznJUAba DzDo3lJF4qDcGOzcaZ2zhYiZIcLW8wU7RaHUpWSC4ze5CNy0fOqtAus9Q/LAVtGNdRw5 pgg95E2S/FCBaK5edHEZHkruAx/2DwADmKFrFrf+O82wJd9Tm+IZGSWE84DBSb3xPMoU MEYQ== X-Gm-Message-State: AOJu0Yx+QPI8JDrzJq39VWvBhx2oLOJJCEE8EsRB6COgGuHvU6U4cq1a b85HCaCxHbopRwkD6R/prIbHkUJhjhzcai9qlmVmXaRl00MRerpEwtt+Fsk3EQk= 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-omap@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: 766229 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 879C56EB4C 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=1706193436; cv=none; b=ZkURfaXraJGTGUhLxxbrVQPv61wIxHMjqpzXgEICVkuBJl2knUeGLW2+pm5JBttqxUTcwl+zUybTvnNcBz2xGmEVkij49B+pjad/NPvgH3RaDVaDBh+2nXARz3B4771PgNW8FrfK1kF6BMNe3wpqCNbaTHwPqfmI+Na93x+4nqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193436; c=relaxed/simple; bh=Qs//UMnixr5IUp6jilmOnSE7i7QVfxi3SrizSBiLzF4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JFt7UkzWX9UTICVinZvFl7pm/GQH42HKfuFc1nda/JU8KIsiEZhDd6QazYVIUJ0G0cIKA5IaKdJBW/ZUZYwMIdtFSKaY44XNXyDUoCoRD9Z4jrTr5LkQSZSlODxXowE+j0vWDGaLkTQ21s9SG9P6A7Ay7/qBRLqNCkfgEhgdYbw= 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-2cf33b909e8so7533891fa.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=REwRgr+6MWc5mJ/+b2IY0CAo1I6LQtuko3CdZt7euX+S6L2bIDVWINZOpqp6h4O26M Zl3kuaRpGyKsMNRdyX3zr9pXXtGFESB1p+hjt9QWqTt8LLH+mhsma+5OfrkV7K9dWy1S BldgKouDVSWJJXfxf4/vSxdHuCybodAv6XRrCz8j+LN8KlYce3MoPpBkFmjIYr3M5hae PDNrVFRATlpBOJu9BL8VUh228ZfykNcTDw0YRyMwpJfQJvs/ZtyMQLbPV//HdeECIrSi YGxXsyNH5rwo7VJjQv1rtRsuAPSNEH30eLvjDTOo8KL+H3SPF+/qjGlEstUCAlP7dB+E 9Rhg== X-Gm-Message-State: AOJu0Yzy0quOV5+s4KGuXeGGow+VCC47z6FNP9iLLmkqaylkWmcAT2qX 0YLWox6NJA9XFSBq/jh1/eLxOkZv2RWFDXfgoKKwIOHq0kpFgxdx4ug67SpGw5c= 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-omap@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: 766732 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 56ABC6E2DA for ; Thu, 25 Jan 2024 14:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706193437; cv=none; b=RJdm6Jdw0xry2EjUhJINGK7+6Utqp4PXegCSHTtg1zIyvS+sBd90jeQl4i+UyiZ3+44aBWf6cGM0cocq3isDlozGbcBhLIaMHGhBW8kbbGw6QFDsQMbdkQoOjY9OjNnAji699J9oG5IMMJU1YgS28JTB3kmdt62fh+EeRiyV35s= 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.182 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-f182.google.com with SMTP id 38308e7fff4ca-2cf0390eddbso51958411fa.3 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=d4DsNYVHKwIzpzfRzKoVjx1nSBZyFRai5giIBrdf0Y1KG4vIjELsYqrXeGVFOsFZX6 2SkGr4eBbKUieTKbMYBpO2GxI1f7B0XxJE9qVubM8kIj/OTwc2Ey7EUz8Cs025WYVkAn 1e8bZu3UQ3oL92U8dACUiDElO1lO2yscDzttmoueknbWhowNE0AlutolJPfXY/ZAXpzo HzubcHgf5yzry3ExkssdRZLonvaBg2kOoSfz2SD4lwnKJTDK1DF0/iGbGSZGbjl2vmXL ErZVr5irU1kmTsSPJGFv4OcdAAvdYGX+MTpeDntpJHmiawa5TINFqQxK9hCIxvWJLwFU QNBQ== X-Gm-Message-State: AOJu0YybqKB67/97Dvk5ucTWpUMhS1Y+zNKp5hVjBcFjoFO8KXrUc3Mq r07jdYkfEqAkl01Ld9Wo5fv3YGIxVsFGMbMQHPf8t9486RGaoCZTf87CBa3G3YA= 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-omap@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); }