From patchwork Wed Oct 5 10:19:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 612720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C68EC433F5 for ; Wed, 5 Oct 2022 10:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbiJEKUP (ORCPT ); Wed, 5 Oct 2022 06:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbiJEKUO (ORCPT ); Wed, 5 Oct 2022 06:20:14 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C472C71BFF for ; Wed, 5 Oct 2022 03:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664965213; x=1696501213; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CzShbDe+0jMVu0dTbKcNM0QEbOfiTZeiXRO22k/SJcM=; b=aMkzGiG//S7hIcCPDZ8mpQnCRJIM2N0j0DO/Nlfs4bD8rHqrQ1Gli3N+ kOHCvqtSJBxZ7Rs6Pl7JjoG1Wyf0HFsioXK/CT5ItHGxLe7cIlSv+TSpX gZfsb6oYEE8T9hk0n4SQiG1mAsesoRdaf9tD7Xz1WBJBgX5yOf+Hf3uwC Eu573MgMp6oOXZkTElTZmM8NqBbPbmNPkH//b+wfx5Z2nmJyqjQHOm5il tSWIx6xKpcxcq0Ywg/ZVr+SHTB8XtGhJRZ+39PjwaTIwdB1lvloPnVMrp bbVTlWL2Iq713lCsmt/AJHUib1vqH5CnIBO+8zVK2z3mKn0Iz4TEhGYbD w==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="304110410" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="304110410" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:13 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="728605909" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="728605909" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.59.192]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:11 -0700 From: Adrian Hunter To: Ulf Hansson Cc: Stefan Wahren , Florian Fainelli , Wolfram Sang , Alex Dubov , Thierry Reding , linux-mmc@vger.kernel.org Subject: [PATCH 01/14] mmc: sdhci: Remove local_irq_{save,restore}() around k[un]map_atomic() Date: Wed, 5 Oct 2022 13:19:38 +0300 Message-Id: <20221005101951.3165-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005101951.3165-1-adrian.hunter@intel.com> References: <20221005101951.3165-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org A long time ago the kmap_atomic API required a slot to be provided which risked the possibility that other code might use the same slot at the same time. Disabling interrupts prevented the possibility of an interrupt handler doing that. However, that went away with commit 3e4d3af501cc ("mm: stack based kmap_atomic()"). When the second argument to kmap_atomic was removed by commit 482fce997e14 ("mmc: remove the second argument of k[un]map_atomic()"), local_irq_{save,restore}() should have been removed also. Remove it now. Signed-off-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index fef03de85b99..0ee20f4beebf 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -705,16 +705,14 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, return sg_count; } -static char *sdhci_kmap_atomic(struct scatterlist *sg, unsigned long *flags) +static char *sdhci_kmap_atomic(struct scatterlist *sg) { - local_irq_save(*flags); return kmap_atomic(sg_page(sg)) + sg->offset; } -static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags) +static void sdhci_kunmap_atomic(void *buffer) { kunmap_atomic(buffer); - local_irq_restore(*flags); } void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, @@ -756,7 +754,6 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, struct mmc_data *data, int sg_count) { struct scatterlist *sg; - unsigned long flags; dma_addr_t addr, align_addr; void *desc, *align; char *buffer; @@ -788,9 +785,9 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, SDHCI_ADMA2_MASK; if (offset) { if (data->flags & MMC_DATA_WRITE) { - buffer = sdhci_kmap_atomic(sg, &flags); + buffer = sdhci_kmap_atomic(sg); memcpy(align, buffer, offset); - sdhci_kunmap_atomic(buffer, &flags); + sdhci_kunmap_atomic(buffer); } /* tran, valid */ @@ -851,7 +848,6 @@ static void sdhci_adma_table_post(struct sdhci_host *host, int i, size; void *align; char *buffer; - unsigned long flags; if (data->flags & MMC_DATA_READ) { bool has_unaligned = false; @@ -874,9 +870,9 @@ static void sdhci_adma_table_post(struct sdhci_host *host, size = SDHCI_ADMA2_ALIGN - (sg_dma_address(sg) & SDHCI_ADMA2_MASK); - buffer = sdhci_kmap_atomic(sg, &flags); + buffer = sdhci_kmap_atomic(sg); memcpy(buffer, align, size); - sdhci_kunmap_atomic(buffer, &flags); + sdhci_kunmap_atomic(buffer); align += SDHCI_ADMA2_ALIGN; } From patchwork Wed Oct 5 10:19:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 612719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A33ADC433F5 for ; Wed, 5 Oct 2022 10:20:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbiJEKUV (ORCPT ); Wed, 5 Oct 2022 06:20:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiJEKUT (ORCPT ); Wed, 5 Oct 2022 06:20:19 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681CC73902 for ; Wed, 5 Oct 2022 03:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664965218; x=1696501218; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UUs+qYdCmXUrQman2MZrT8uLyoAo4la1YqjYh5vGoY4=; b=F3wBl1exW2a07GRkQ2rfQWM+kBfJCxr6FQuIf5t2na37edXtameHaQzN d0X3uUZ1oJXrkAQIPWlEMk5MnwoDYHR0bk9AMiyQf/vDNm5mCyjpJQnvD ni1yirk3F4VZNgXILl02Dy9zX4uerDy3WmV04pkuViUfiYlTHmDCrAvFp dBSIhfryq9JMLfcmJCYUAuqaK6OJykM1GUBN0oHph/jdq0DRmcjowjlyC ptsRMUDBL4YJ/FebxwRkcEYPpfTBhD3vAil6/BRJllWxiefIJXJc6X6ps 2bRPbxd5wO2XloAYo0N9muDmpToyKO/ONf3T9NyWE7Sruuh8DqhSraghT Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="304110416" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="304110416" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:18 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="728605916" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="728605916" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.59.192]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:15 -0700 From: Adrian Hunter To: Ulf Hansson Cc: Stefan Wahren , Florian Fainelli , Wolfram Sang , Alex Dubov , Thierry Reding , linux-mmc@vger.kernel.org Subject: [PATCH 03/14] mmc: sdhci: Replace kmap_atomic() with kmap_local_page() Date: Wed, 5 Oct 2022 13:19:40 +0300 Message-Id: <20221005101951.3165-4-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005101951.3165-1-adrian.hunter@intel.com> References: <20221005101951.3165-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org kmap_local_page() is equivalent to kmap_atomic() except that it does not disable page faults or preemption. Where possible kmap_local_page() is preferred to kmap_atomic() - refer kernel highmem documentation. In this case, there is no need to disable page faults or preemption, so replace kmap_atomic() with kmap_local_page(), and, correspondingly, kunmap_atomic() with kunmap_local(). Signed-off-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 31d87ec7d055..fb6e9a81f198 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -697,12 +697,12 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, static char *sdhci_kmap_atomic(struct scatterlist *sg) { - return kmap_atomic(sg_page(sg)) + sg->offset; + return kmap_local_page(sg_page(sg)) + sg->offset; } static void sdhci_kunmap_atomic(void *buffer) { - kunmap_atomic(buffer); + kunmap_local(buffer); } void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, From patchwork Wed Oct 5 10:19:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 612718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52C0DC4332F for ; Wed, 5 Oct 2022 10:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbiJEKUa (ORCPT ); Wed, 5 Oct 2022 06:20:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiJEKU2 (ORCPT ); Wed, 5 Oct 2022 06:20:28 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24DF173917 for ; Wed, 5 Oct 2022 03:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664965224; x=1696501224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Jh13VvZzGFPhxWL+aCBqD8YhZrYTDwgou6rEZvcP2c=; b=ZWaYS/USyI8O/NQdpgiRfVj/rRqyo1sRcjAUKyGqnKdZu3L1WVb+kAkm GvYxL8V+miOFvYOQOgT81i4ZZkMl9/TdJYAJZkqDggL9AdxALYAckA8GL W8rNQp6wqOJKmJkBt8KgZE04N2xNdcNkLhoTFgACRPT3JsOMXDT+hOUTU 0AW9ZMwf03hjZIjX8NrcG03agaP4WLSz00QksnVTYOxOidDmOL/upUJaB PM2C99zIRCbZ44NVEuoJFplTmaDltnXIRrZdFV0xYmT5j1wras6sDiFKP xN6Cot+PAeGY41vwXONaWsLvtoytrD3GaET1cSL3coQ7d9GoqUCWpmwd1 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="304110426" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="304110426" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:22 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="728605943" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="728605943" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.59.192]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:20 -0700 From: Adrian Hunter To: Ulf Hansson Cc: Stefan Wahren , Florian Fainelli , Wolfram Sang , Alex Dubov , Thierry Reding , linux-mmc@vger.kernel.org Subject: [PATCH 05/14] mmc: bcm2835: Remove local_irq_{save, restore}() around sg_miter_{next,stop}() Date: Wed, 5 Oct 2022 13:19:42 +0300 Message-Id: <20221005101951.3165-6-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005101951.3165-1-adrian.hunter@intel.com> References: <20221005101951.3165-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org sg_miter_next() using an sg_mapping_iter with flag SG_MITER_ATOMIC uses kmap_atomic() to map pages. A long time ago the kmap_atomic API required a slot to be provided which risked the possibility that other code might use the same slot at the same time. Disabling interrupts prevented the possibility of an interrupt handler doing that. However, that went away with commit 3e4d3af501cc ("mm: stack based kmap_atomic()"). Remove local_irq_{save,restore}() around sg_miter_{next,stop}(). Signed-off-by: Adrian Hunter --- drivers/mmc/host/bcm2835.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 49acbfa87ab8..440773e3ba55 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -327,7 +327,6 @@ static void bcm2835_dma_complete(void *param) static void bcm2835_transfer_block_pio(struct bcm2835_host *host, bool is_read) { - unsigned long flags; size_t blksize; unsigned long wait_max; @@ -335,8 +334,6 @@ static void bcm2835_transfer_block_pio(struct bcm2835_host *host, bool is_read) wait_max = jiffies + msecs_to_jiffies(500); - local_irq_save(flags); - while (blksize) { int copy_words; u32 hsts = 0; @@ -421,8 +418,6 @@ static void bcm2835_transfer_block_pio(struct bcm2835_host *host, bool is_read) } sg_miter_stop(&host->sg_miter); - - local_irq_restore(flags); } static void bcm2835_transfer_pio(struct bcm2835_host *host) From patchwork Wed Oct 5 10:19:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 612717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C272EC433F5 for ; Wed, 5 Oct 2022 10:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbiJEKUb (ORCPT ); Wed, 5 Oct 2022 06:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiJEKU3 (ORCPT ); Wed, 5 Oct 2022 06:20:29 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FAE574B80 for ; Wed, 5 Oct 2022 03:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664965228; x=1696501228; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H+qpET7m8KjrmynFemQpw4n7WO+ula0zi+RhEelZiHk=; b=el+AKt0g8ElWr1bGdFex+NO+I5Kk7vff4cLCY9ngncBO79SD/dLPST2m g+00VRjWb2CNXww4hSyacrkjPcI+0Yf0cIkdV/fX83sDaMldMDI51ymgr VUicZZ8/0U7ihxfnKzDtD2lIK9uL4HYFaoWOtrfQVp+cGLAR7IhX1YFCL DXbmaKjdg7k1LGSWyr8v7pEULXY51aIv7+ZVJAJpW00l5HdW+z1KjIj2Y u8LClPfbcZKmRMzKsmLBuSr65gJLPT4VAWx+czfI0qObJlnPJ3YcI5sJ/ Vzz4eAUcWJyoWThKUYZDLMZnvNMTR1ezKWLh7P8+g0zL9b6LTImVEPngO g==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="304110444" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="304110444" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:27 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="728605965" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="728605965" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.59.192]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:25 -0700 From: Adrian Hunter To: Ulf Hansson Cc: Stefan Wahren , Florian Fainelli , Wolfram Sang , Alex Dubov , Thierry Reding , linux-mmc@vger.kernel.org Subject: [PATCH 07/14] mmc: mmc_test: Remove local_irq_{save, restore}() around sg_copy_{from,to}_buffer() Date: Wed, 5 Oct 2022 13:19:44 +0300 Message-Id: <20221005101951.3165-8-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005101951.3165-1-adrian.hunter@intel.com> References: <20221005101951.3165-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org sg_copy_{from,to}_buffer() call sg_copy_buffer() which uses an sg_mapping_iter with flag SG_MITER_ATOMIC, so then sg_miter_next() uses kmap_atomic() to map pages. A long time ago the kmap_atomic API required a slot to be provided which risked the possibility that other code might use the same slot at the same time. Disabling interrupts prevented the possibility of an interrupt handler doing that. However, that went away with commit 3e4d3af501cc ("mm: stack based kmap_atomic()"). Remove local_irq_{save,restore}() around sg_copy_{from,to}_buffer(). Signed-off-by: Adrian Hunter --- drivers/mmc/core/mmc_test.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c index 8d9bceeff986..6cd6f8a94a71 100644 --- a/drivers/mmc/core/mmc_test.c +++ b/drivers/mmc/core/mmc_test.c @@ -932,7 +932,6 @@ static int mmc_test_transfer(struct mmc_test_card *test, unsigned blocks, unsigned blksz, int write) { int ret, i; - unsigned long flags; if (write) { for (i = 0; i < blocks * blksz; i++) @@ -940,9 +939,7 @@ static int mmc_test_transfer(struct mmc_test_card *test, } else { memset(test->scratch, 0, BUFFER_SIZE); } - local_irq_save(flags); sg_copy_from_buffer(sg, sg_len, test->scratch, BUFFER_SIZE); - local_irq_restore(flags); ret = mmc_test_set_blksize(test, blksz); if (ret) @@ -987,9 +984,7 @@ static int mmc_test_transfer(struct mmc_test_card *test, return RESULT_FAIL; } } else { - local_irq_save(flags); sg_copy_to_buffer(sg, sg_len, test->scratch, BUFFER_SIZE); - local_irq_restore(flags); for (i = 0; i < blocks * blksz; i++) { if (test->scratch[i] != (u8)i) return RESULT_FAIL; From patchwork Wed Oct 5 10:19:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 612716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BC4AC433FE for ; Wed, 5 Oct 2022 10:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229781AbiJEKUd (ORCPT ); Wed, 5 Oct 2022 06:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiJEKUc (ORCPT ); Wed, 5 Oct 2022 06:20:32 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF1A75CC2 for ; Wed, 5 Oct 2022 03:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664965232; x=1696501232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dGXSJEkacErT+CMoDEUiOkDAkmEkNZ8NLs8UbTLgyiE=; b=Fj47/nLHDukEA1AWp1r1ELCCw3/K/uDatB1YROlZfHbs+M1uD3bbRFHx uyImIjtLbYyh2rPHDxv4cazAy6XqQ3tkoh5cumJmYfiYow1axs1VMmmV4 ls/9O9L7n9DWs/6ahZVqaxxGf9u9szIBq3+w9KSO2U+TH50+Ygx0hWaxE sLrbvJhMb8VRZF3lq5GFOSvWUBNjCpdRHURRYG6zmqV2JzbdfutnKAVS8 IMsINe21FH4XNrcrEa7A/5cgvvgnIYv8tK1HDoANXUR0qRvXocWVkPxeW 0cXc+8BfycQnV0cdOqy4mdvoa1ajvWoSnNcrpjFVUoJan1RHUTwNQ5ClO g==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="304110451" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="304110451" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:32 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="728605981" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="728605981" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.59.192]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:29 -0700 From: Adrian Hunter To: Ulf Hansson Cc: Stefan Wahren , Florian Fainelli , Wolfram Sang , Alex Dubov , Thierry Reding , linux-mmc@vger.kernel.org Subject: [PATCH 09/14] mmc: tifm_sd: Remove local_irq_{save, restore}() around tifm_sd_bounce_block() Date: Wed, 5 Oct 2022 13:19:46 +0300 Message-Id: <20221005101951.3165-10-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005101951.3165-1-adrian.hunter@intel.com> References: <20221005101951.3165-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org tifm_sd_bounce_block() calls functions that ultimate use kmap_atomic() to map pages. A long time ago the kmap_atomic API required a slot to be provided which risked the possibility that other code might use the same slot at the same time. Disabling interrupts prevented the possibility of an interrupt handler doing that. However, that went away with commit 3e4d3af501cc ("mm: stack based kmap_atomic()"). When the second argument to kmap_atomic was removed by commit 482fce997e14 ("mmc: remove the second argument of k[un]map_atomic()"), local_irq_{save,restore}() should have been removed also. Remove it now. Signed-off-by: Adrian Hunter --- drivers/mmc/host/tifm_sd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c index ed1685add446..d539f9b48422 100644 --- a/drivers/mmc/host/tifm_sd.c +++ b/drivers/mmc/host/tifm_sd.c @@ -264,16 +264,13 @@ static int tifm_sd_set_dma_data(struct tifm_sd *host, struct mmc_data *r_data) unsigned int t_size = TIFM_DMA_TSIZE * r_data->blksz; unsigned int dma_len, dma_blk_cnt, dma_off; struct scatterlist *sg = NULL; - unsigned long flags; if (host->sg_pos == host->sg_len) return 1; if (host->cmd_flags & DATA_CARRY) { host->cmd_flags &= ~DATA_CARRY; - local_irq_save(flags); tifm_sd_bounce_block(host, r_data); - local_irq_restore(flags); if (host->sg_pos == host->sg_len) return 1; } @@ -300,11 +297,9 @@ static int tifm_sd_set_dma_data(struct tifm_sd *host, struct mmc_data *r_data) if (dma_blk_cnt) sg = &r_data->sg[host->sg_pos]; else if (dma_len) { - if (r_data->flags & MMC_DATA_WRITE) { - local_irq_save(flags); + if (r_data->flags & MMC_DATA_WRITE) tifm_sd_bounce_block(host, r_data); - local_irq_restore(flags); - } else + else host->cmd_flags |= DATA_CARRY; sg = &host->bounce_buf; From patchwork Wed Oct 5 10:19:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 612715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A149C433FE for ; Wed, 5 Oct 2022 10:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbiJEKUk (ORCPT ); Wed, 5 Oct 2022 06:20:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbiJEKUi (ORCPT ); Wed, 5 Oct 2022 06:20:38 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D790A75496 for ; Wed, 5 Oct 2022 03:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664965236; x=1696501236; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ySqpMmfPU6WHUVl46ZFzM3QA7uwCVmEUc5bGhgxfZPs=; b=eFYfWyCb/s7SCxKbA29LMjtfaZSqpd3WluZDxeB1vPinAw3ObtxAFXRr qOgC/Zf3jKjEbfiDKCaoPUgUzUOsUfWXbjHB5GwZc12iCXD41Y1el4Bbw u3V/nqvkns0qKEivpDKV4blnuCdjke6+KwpccMWBIwIR+saOR65iHQxDv 2LcVBNqocFZiCYrmCOwV5uLPbxbJXPgHTB54LUMiF+Qz0JgY42FfKDU6u SE2y4XLfNbHG3BKvBdQfMPDoqT/Q7EvpQoII2DgtYqmc14nbikTgAMue7 arQZr7Y/YEDmb/gvU2pZrPPATRnm1dFTK0/XsogeianXxmxmIFsxOB/UI Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="304110462" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="304110462" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:36 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="728606008" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="728606008" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.59.192]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:34 -0700 From: Adrian Hunter To: Ulf Hansson Cc: Stefan Wahren , Florian Fainelli , Wolfram Sang , Alex Dubov , Thierry Reding , linux-mmc@vger.kernel.org Subject: [PATCH 11/14] mmc: tmio_mmc_core: Remove local_irq_{save,restore}() around k[un]map_atomic() Date: Wed, 5 Oct 2022 13:19:48 +0300 Message-Id: <20221005101951.3165-12-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005101951.3165-1-adrian.hunter@intel.com> References: <20221005101951.3165-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org A long time ago the kmap_atomic API required a slot to be provided which risked the possibility that other code might use the same slot at the same time. Disabling interrupts prevented the possibility of an interrupt handler doing that. However, that went away with commit 3e4d3af501cc ("mm: stack based kmap_atomic()"). When the second argument to kmap_atomic was removed by commit 482fce997e14 ("mmc: remove the second argument of k[un]map_atomic()"), local_irq_{save,restore}() should have been removed also. Remove it now. Signed-off-by: Adrian Hunter Reviewed-by: Wolfram Sang --- drivers/mmc/host/renesas_sdhi_sys_dmac.c | 5 ++--- drivers/mmc/host/tmio_mmc.h | 7 ++----- drivers/mmc/host/tmio_mmc_core.c | 10 ++++------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index 99e3426df702..e9cc6c15d229 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -254,12 +254,11 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host) /* The only sg element can be unaligned, use our bounce buffer then */ if (!aligned) { - unsigned long flags; - void *sg_vaddr = tmio_mmc_kmap_atomic(sg, &flags); + void *sg_vaddr = tmio_mmc_kmap_atomic(sg); sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length); memcpy(host->bounce_buf, sg_vaddr, host->bounce_sg.length); - tmio_mmc_kunmap_atomic(sg, &flags, sg_vaddr); + tmio_mmc_kunmap_atomic(sg, sg_vaddr); host->sg_ptr = &host->bounce_sg; sg = host->sg_ptr; } diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 501613c74406..22375790b57b 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -204,18 +204,15 @@ void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i); void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i); irqreturn_t tmio_mmc_irq(int irq, void *devid); -static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg, - unsigned long *flags) +static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg) { - local_irq_save(*flags); return kmap_atomic(sg_page(sg)) + sg->offset; } static inline void tmio_mmc_kunmap_atomic(struct scatterlist *sg, - unsigned long *flags, void *virt) + void *virt) { kunmap_atomic(virt - sg->offset); - local_irq_restore(*flags); } #ifdef CONFIG_PM diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 437048bb8027..6d50c0dd53fe 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -412,7 +412,6 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) void *sg_virt; unsigned short *buf; unsigned int count; - unsigned long flags; if (host->dma_on) { pr_err("PIO IRQ in DMA mode!\n"); @@ -422,7 +421,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) return; } - sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr, &flags); + sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr); buf = (unsigned short *)(sg_virt + host->sg_off); count = host->sg_ptr->length - host->sg_off; @@ -437,7 +436,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) host->sg_off += count; - tmio_mmc_kunmap_atomic(host->sg_ptr, &flags, sg_virt); + tmio_mmc_kunmap_atomic(host->sg_ptr, sg_virt); if (host->sg_off == host->sg_ptr->length) tmio_mmc_next_sg(host); @@ -446,11 +445,10 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) static void tmio_mmc_check_bounce_buffer(struct tmio_mmc_host *host) { if (host->sg_ptr == &host->bounce_sg) { - unsigned long flags; - void *sg_vaddr = tmio_mmc_kmap_atomic(host->sg_orig, &flags); + void *sg_vaddr = tmio_mmc_kmap_atomic(host->sg_orig); memcpy(sg_vaddr, host->bounce_buf, host->bounce_sg.length); - tmio_mmc_kunmap_atomic(host->sg_orig, &flags, sg_vaddr); + tmio_mmc_kunmap_atomic(host->sg_orig, sg_vaddr); } } From patchwork Wed Oct 5 10:19:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 612714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8573AC433F5 for ; Wed, 5 Oct 2022 10:20:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbiJEKUn (ORCPT ); Wed, 5 Oct 2022 06:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiJEKUm (ORCPT ); Wed, 5 Oct 2022 06:20:42 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66FBF75FCA for ; Wed, 5 Oct 2022 03:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664965241; x=1696501241; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cRbhPhG0W1B4mhSRGBLSoQqNQatbwceuvJPOUVg7haw=; b=OiZoa/QSIKLcVFJUkweKgmQgN5RBdjVJa6HHXwHqM90hlv1bVCOhkvr5 vrXJpr+V40TS4Raab/IozoA1yuwHuaV7S9qnXOF8yeSiggeG7Ac3kLXag fP/Za53sRPDq8UVfzBtgeqpQBNZ8AA/Aq8+PB/AzpbcfRNolyw4FcM/bk FPxhkuGCtoB94Pp6q1/2svNQcssYIy4E7jGN7X3wMm+Ou7jdB8X6xfDFT ClP+1SyTfWJCr5iozwmynWnl14/zQJP4c3Vg3e8razvehqx4zeS9OxWBJ DcQJFCLsZazoArWv+7xhd4vXCESbK4mF4xxM1TaamtJmcpiTfq/T4yXs4 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="304110474" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="304110474" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:41 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="728606021" X-IronPort-AV: E=Sophos;i="5.95,159,1661842800"; d="scan'208";a="728606021" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.59.192]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2022 03:20:39 -0700 From: Adrian Hunter To: Ulf Hansson Cc: Stefan Wahren , Florian Fainelli , Wolfram Sang , Alex Dubov , Thierry Reding , linux-mmc@vger.kernel.org Subject: [PATCH 13/14] mmc: au1xmmc: Replace kmap_atomic() with kmap_local_page() Date: Wed, 5 Oct 2022 13:19:50 +0300 Message-Id: <20221005101951.3165-14-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221005101951.3165-1-adrian.hunter@intel.com> References: <20221005101951.3165-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org kmap_local_page() is equivalent to kmap_atomic() except that it does not disable page faults or preemption. Where possible kmap_local_page() is preferred to kmap_atomic() - refer kernel highmem documentation. In this case, there is no need to disable page faults or preemption, so replace kmap_atomic() with kmap_local_page(), and, correspondingly, kunmap_atomic() with kunmap_local(). Signed-off-by: Adrian Hunter --- drivers/mmc/host/au1xmmc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index c88b039dc9fb..82dd0ae40305 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c @@ -388,7 +388,7 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host) /* This is the pointer to the data buffer */ sg = &data->sg[host->pio.index]; - sg_ptr = kmap_atomic(sg_page(sg)) + sg->offset + host->pio.offset; + sg_ptr = kmap_local_page(sg_page(sg)) + sg->offset + host->pio.offset; /* This is the space left inside the buffer */ sg_len = data->sg[host->pio.index].length - host->pio.offset; @@ -409,7 +409,7 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host) __raw_writel((unsigned long)val, HOST_TXPORT(host)); wmb(); /* drain writebuffer */ } - kunmap_atomic(sg_ptr); + kunmap_local(sg_ptr); host->pio.len -= count; host->pio.offset += count; @@ -446,7 +446,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host) if (host->pio.index < host->dma.len) { sg = &data->sg[host->pio.index]; - sg_ptr = kmap_atomic(sg_page(sg)) + sg->offset + host->pio.offset; + sg_ptr = kmap_local_page(sg_page(sg)) + sg->offset + host->pio.offset; /* This is the space left inside the buffer */ sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset; @@ -488,7 +488,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host) sg_ptr[count] = (unsigned char)(val & 0xFF); } if (sg_ptr) - kunmap_atomic(sg_ptr); + kunmap_local(sg_ptr); host->pio.len -= count; host->pio.offset += count;