Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759906AbbKULuk (ORCPT ); Sat, 21 Nov 2015 06:50:40 -0500 Received: from unicorn.mansr.com ([81.2.72.234]:57439 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751521AbbKULui convert rfc822-to-8bit (ORCPT ); Sat, 21 Nov 2015 06:50:38 -0500 From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Stephen Boyd Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Nicolas Pitre , Arnd Bergmann , Steven Rostedt Subject: Re: [RFC/PATCH 3/3] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions References: <1448068997-26631-1-git-send-email-sboyd@codeaurora.org> <1448068997-26631-4-git-send-email-sboyd@codeaurora.org> Date: Sat, 21 Nov 2015 11:50:28 +0000 In-Reply-To: <1448068997-26631-4-git-send-email-sboyd@codeaurora.org> (Stephen Boyd's message of "Fri, 20 Nov 2015 17:23:17 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2147 Lines: 74 Stephen Boyd writes: > +static int module_patch_aeabi_uidiv(unsigned long loc, const Elf32_Sym *sym) > +{ > + extern char __aeabi_uidiv[], __aeabi_idiv[]; > + unsigned long udiv_addr = (unsigned long)__aeabi_uidiv; > + unsigned long sdiv_addr = (unsigned long)__aeabi_idiv; > + unsigned int udiv_insn, sdiv_insn, mask; > + > + if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) { > + mask = HWCAP_IDIVT; > + udiv_insn = __opcode_to_mem_thumb32(0xfbb0f0f1); > + sdiv_insn = __opcode_to_mem_thumb32(0xfb90f0f1); > + } else { > + mask = HWCAP_IDIVA; > + udiv_insn = __opcode_to_mem_arm(0xe730f110); > + sdiv_insn = __opcode_to_mem_arm(0xe710f110); > + } > + > + if (elf_hwcap & mask) { > + if (sym->st_value == udiv_addr) { > + *(u32 *)loc = udiv_insn; > + return 1; > + } else if (sym->st_value == sdiv_addr) { > + *(u32 *)loc = sdiv_insn; > + return 1; > + } > + } > + > + return 0; > +} [...] > +static void __init patch_aeabi_uidiv(void) > +{ > + extern unsigned long *__start_udiv_loc[], *__stop_udiv_loc[]; > + extern unsigned long *__start_idiv_loc[], *__stop_idiv_loc[]; > + unsigned long **p; > + unsigned int udiv_insn, sdiv_insn, mask; > + > + if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) { > + mask = HWCAP_IDIVT; > + udiv_insn = __opcode_to_mem_thumb32(0xfbb0f0f1); > + sdiv_insn = __opcode_to_mem_thumb32(0xfb90f0f1); > + } else { > + mask = HWCAP_IDIVA; > + udiv_insn = __opcode_to_mem_arm(0xe730f110); > + sdiv_insn = __opcode_to_mem_arm(0xe710f110); > + } > + > + if (elf_hwcap & mask) { > + for (p = __start_udiv_loc; p < __stop_udiv_loc; p++) { > + unsigned long *inst = *p; > + *inst = udiv_insn; > + } > + for (p = __start_idiv_loc; p < __stop_idiv_loc; p++) { > + unsigned long *inst = *p; > + *inst = sdiv_insn; > + } > + } > +} These functions are rather similar. Perhaps they could be combined somehow. -- M?ns Rullg?rd mans@mansr.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/