From patchwork Wed Jun 8 14:15:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 862242 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p58J5vMi006942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 8 Jun 2011 19:06:18 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QUJXM-0004Up-5z; Wed, 08 Jun 2011 14:15:12 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QUJXL-0005JU-Oq; Wed, 08 Jun 2011 14:15:11 +0000 Received: from relais.videotron.ca ([24.201.245.36]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QUJXE-0005JB-Tt for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2011 14:15:09 +0000 MIME-version: 1.0 Received: from xanadu.home ([66.130.28.92]) by vl-mh-mrz21.ip.videotron.ca (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTP id <0LMH00CMR67YPY20@vl-mh-mrz21.ip.videotron.ca> for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2011 10:14:22 -0400 (EDT) Date: Wed, 08 Jun 2011 10:15:02 -0400 (EDT) From: Nicolas Pitre X-X-Sender: nico@xanadu.home To: Arnd Bergmann Subject: Re: Dynamic patching in discarded sections In-reply-to: <201106081123.59414.arnd@arndb.de> Message-id: References: <201106081123.59414.arnd@arndb.de> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110608_101505_021550_5C2FACCC X-CRM114-Status: GOOD ( 24.60 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [24.201.245.36 listed in list.dnswl.org] Cc: Russell King - ARM Linux , lkml , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 08 Jun 2011 19:06:18 +0000 (UTC) On Wed, 8 Jun 2011, Arnd Bergmann wrote: > I've been playing with randconfig builds and found an interesting problem > with the combination of: > > CONFIG_ARM_PATCH_PHYS_VIRT=y > CONFIG_HOTPLUG=n > CONFIG_DMABOUNCE=n > CONFIG_MMC_SPI=y > > The problem is shown with this code: > > static int __devexit mmc_spi_remove(struct spi_device *spi) > { > ... > dma_unmap_single(host->dma_dev, host->ones_dma, > MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE); > dma_unmap_single(host->dma_dev, host->data_dma, > sizeof(*host->data), DMA_BIDIRECTIONAL); > ... > } > > and the error message (in case someone looks for this using google) is > > `.devexit.text' referenced in section `.pv_table' of drivers/built-in.o: defined in discarded section `.devexit.text' of drivers/built-in.o > `.devexit.text' referenced in section `.pv_table' of drivers/built-in.o: defined in discarded section `.devexit.text' of drivers/built-in.o > > What happens is that dma_unmap_single() calls > __dma_single_dev_to_cpu(dma_to_virt(dev, handle), size, dir), which requires > patching in the caller. However, due to CONFIG_HOTPLUG being disabled, the > __devexit section gets discarded, and the linker cannot create an entry in the > .pvtable section for the mmc_spi_remove function. We really need to push for better toolchain support here. This could easily be solved with some way to query the currently active section from the assembler and use that to construct the argument to the .pushsection directive. This way, the .pvtable section could become .pvtable.__devexit when the reference is made from a __devexit section, and that could be discarded altogether at link time if unneeded. Dave Martin proposed an extension to gas here (also sent to binutils@sourceware.org): http://article.gmane.org/gmane.linux.linaro.toolchain/701 But as far as I know, nothing further happened. And this is not an ARM specific issue either as the X86 alternates have the same problem. > I don't know if the same problem exists in other places in the code, but it's > entirely possible. I also couldn't think of a good solution for this, short of > moving the definition of dma_unmap_single() to out of line code. Probably the best interim solution would be: But clearly the toolchain should be more accommodating instead. Nicolas diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index dfbb377..f231c92 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -21,7 +21,8 @@ #define ARM_CPU_KEEP(x) #endif -#if defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK) +#if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \ + defined(CONFIG_ARM_PATCH_PHYS_VIRT) #define ARM_EXIT_KEEP(x) x #else #define ARM_EXIT_KEEP(x)