From patchwork Sun Nov 4 13:52:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150109 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1537969ljp; Sun, 4 Nov 2018 05:53:02 -0800 (PST) X-Google-Smtp-Source: AJdET5d5W0mSl7M9j7s3+badebCTYjg1O16sC/EtT7GKZp15PTiPQtZRw0Bckdt79W6qV4l4Hab8 X-Received: by 2002:a17:902:a984:: with SMTP id bh4-v6mr18717865plb.163.1541339582322; Sun, 04 Nov 2018 05:53:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541339582; cv=none; d=google.com; s=arc-20160816; b=l9stzI8ZN7t2TwBnC8y//+a/R4HUdnkr3ogyviz3VqsIMlWFFjc3X4mkedm/fZhOf7 XCJ/Uxz6rP3J6cafTG2p5wGVIvl6I44bWDfHBJpA8EFuoRtqCwnCdnrr+EKY4JFGKRGY JukYLLMD9+/w37GF9LHZ4IDiVT1Ppm4pAM+urr2wrptiImIUo5DrPt3oTQIWROjW81PV pM5XJYtnHEOOL3vDkoXE8GFexBb8Yns1ers0trITgziGQXeqypQ3XB2tyrDwZ5Ux92aJ +r74GupxWCMheEYEYrm5xuuUKizhsrF09cJdzrK66uEgsTtc+3oClLR5yhTqBsrANlOT 0Gaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OdEhdih2dT7SIu71gjD0N49HJBaSMJinANYL/jICyn8=; b=G6lz0oDyrAe9zRkqwbHZMyW3EJFTK64nG/FcKPNW1LZqQS7+2invXYIGMVgKvdOzNQ EW5XwfUugVms9x0yEuk5CTGJd9CekN80Vlw3ScnWFHzdDiHFdzELYlF0HquiSmBvICal O8FdCd3pfxU28cGQKFLe4v0Jq/N0fIvW5jFyI6hgXGBMcbuSS2pcXkXbmRUcpQ1VyVgv rS/9gT+k/uGbAa7L4QCvQcnMJmweVQ7OfPQRcvpMGumuk4wlA7JXrW5ACjPppWCxCHqL pKaOazl7AKq7D7mOi6f3kK1AhDcQY6DMEWvakeWQMjYidvJ/kLEg26qKiHbabm5lp+HC puDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nuPl8KgN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si1456980pgj.409.2018.11.04.05.53.02; Sun, 04 Nov 2018 05:53:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nuPl8KgN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730795AbeKDXIE (ORCPT + 32 others); Sun, 4 Nov 2018 18:08:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:46360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730678AbeKDXIB (ORCPT ); Sun, 4 Nov 2018 18:08:01 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F3332085A; Sun, 4 Nov 2018 13:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339577; bh=tEJtpAqTMjlEQ/L67FZ9RIUlP5Om9vqXkw2axuGYhyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nuPl8KgNhG3siUxuZzX7a2khqAQNxkQJ7uAZCOZ/jHLtGlCz663zfTKQcNLGtrAx3 9nQHpgZ6nKEdH+hxLTphaPz+9+S17C2zpH9O0K/9hE0cQ4xXllTzvtEvT+wOYcUQv4 Y9dEiCqg98kD7jMH49FLAKYxSMeo5uFNyIVI+/18= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joel Stanley , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL 4.18 14/45] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS Date: Sun, 4 Nov 2018 08:52:09 -0500 Message-Id: <20181104135240.88431-14-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135240.88431-1-sashal@kernel.org> References: <20181104135240.88431-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joel Stanley [ Upstream commit 960e30029863db95ec79a71009272d4661db5991 ] Ever since commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type to POWER4") we force -mpower4 to be passed to the assembler irrespective of the CFLAGS used (for Book3s 64). When building a powerpc64 kernel with clang, clang will not add -many to the assembler flags, so any instructions that the compiler has generated that are not available on power4 will cause an error: /usr/bin/as -a64 -mppc64 -mlittle-endian -mpower8 \ -I ./arch/powerpc/include -I ./arch/powerpc/include/generated \ -I ./include -I ./arch/powerpc/include/uapi \ -I ./arch/powerpc/include/generated/uapi -I ./include/uapi \ -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc \ -maltivec -mpower4 -o init/do_mounts.o /tmp/do_mounts-3b0a3d.s /tmp/do_mounts-51ce54.s:748: Error: unrecognized opcode: `isel' GCC does include -many, so the GCC driven gas call will succeed: as -v -I ./arch/powerpc/include -I ./arch/powerpc/include/generated -I ./include -I ./arch/powerpc/include/uapi -I ./arch/powerpc/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc -a64 -mpower8 -many -mlittle -maltivec -mpower4 -o init/do_mounts.o Note that isel is power7 and above for IBM CPUs. GCC only generates it for Power9 and above, but the above test was run against the clang generated assembly. Peter Bergner explains: When using -many -mpower4, gas will first try and find a matching power4 mnemonic and failing that, it will then allow any valid mnemonic that gas knows about. GCC's use of -many predates me though. IIRC, Alan looked at trying to remove it, but I forget why he didn't. Could be either a gcc or gas issue at the time. I'm not sure whether issue still exists or not. He and I have modified how gas works internally a fair amount since he tried removing gcc use of -many. I will also note that when using -many, gas will choose the first mnemonic that matches in the mnemonic table and we have (mostly) sorted the table so that server mnemonics show up earlier in the table than other mnemonics, so they'll be seen/chosen first. By explicitly setting -many we can build with Clang and GCC while retaining the -mpower4 option. Signed-off-by: Joel Stanley Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index fb96206de317..2510ff9381d0 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -244,7 +244,11 @@ cpu-as-$(CONFIG_4xx) += -Wa,-m405 cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec) cpu-as-$(CONFIG_E200) += -Wa,-me200 cpu-as-$(CONFIG_E500) += -Wa,-me500 -cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 + +# When using '-many -mpower4' gas will first try and find a matching power4 +# mnemonic and failing that it will allow any valid mnemonic that GAS knows +# about. GCC will pass -many to GAS when assembling, clang does not. +cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 -Wa,-many cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc) KBUILD_AFLAGS += $(cpu-as-y) From patchwork Sun Nov 4 13:52:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150121 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1546573ljp; Sun, 4 Nov 2018 06:03:09 -0800 (PST) X-Google-Smtp-Source: AJdET5f2dgYguq+OImVepqpIRaUiLq07WPWtKXDGHPw40J1YgNQ7eVxSqrfmi52o8sXH175cCHfE X-Received: by 2002:a62:1bcf:: with SMTP id b198-v6mr6189623pfb.102.1541340189583; Sun, 04 Nov 2018 06:03:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340189; cv=none; d=google.com; s=arc-20160816; b=VbXn2T8aNnNNAERGzizrYpdwzXeNVKLVwJ+XF8UM0CuoHXP8K5ccvpmr6wFnMcJE9w U6SI8kWufssZIcFL1sLpzY1YJ71L0xjtRHlhUmgZnC7ThXMH5EPcI+2o6VHUD18b25Jb DHEzaZOTx/U6vomSLfJKouwFBjIDHLF/rQBaS7IsHQIqEQETLHw2PkKSAcs5s2LC6fYf UkssqmjNafbe9pxpbuA9yMIpCL4+fLC+qbxqnkH9lJM8zDP7lUIvxCUyOzWdJAwZjOC/ l0dLBWKFIqj3XSLprER0kKnr8dk7slVagVqBcronDVy2TA9F3XQmF69RuGzwYIp3c26q n4ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ESpjxJKtfwaRgvJFVAHVK7vaGZUkXXNlgRtDnVWvxeg=; b=Jyf0ZbkPDKWIbkkfgjcZ2/NK2DKdJLxFbT9IpwT97uujWfCAadWXyVK76g0z3Rexkm Sx4P1wWos8A57KpY09pm4vjSqQsWuMYUWYXx/h5XnpfBa695dPW2ebscQfMIA3Cx0fVI VvEz6WO9Ef1YGTvEpfWQuGMPVratsHVrW/XkMdgY4P4XOUrkSCOMo7RLvMiUfhjRhfL/ 74BGeLHb2y0LQHzgxtBTKGJcGpuEOr8m1VPIJfgcStfQAw2uLXGjLp0YEsmg3UnikiaN mzpimTLey34jOIgrzUYMENOmN1HJQUDdzrng9825WqbZehbb5vXSCrq2KebNoM34ajtw HoQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RNzOyryS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si41360533plc.103.2018.11.04.06.03.09; Sun, 04 Nov 2018 06:03:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RNzOyryS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731331AbeKDXSI (ORCPT + 32 others); Sun, 4 Nov 2018 18:18:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:46460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730824AbeKDXII (ORCPT ); Sun, 4 Nov 2018 18:08:08 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 405C72085A; Sun, 4 Nov 2018 13:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339584; bh=XsRtoR2HobAJkGooN+EhBAm9Zeet5xoJpEAy0slXurk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RNzOyrySFh6R8gPjnndkNiRNb9VDsoKeUH27OzVXbVqyIbZE6UO8+maBP/yG8gUkR WO1Fqxy6zzWBfEgGrmGceush3aRUfLOdkV9pUMxL2kGLZf7lENhR1GrrcWBdFX+KWO J7AAGcqa5nv53Vjf8dynkQOLd4CJKMPsDAtUYpQs= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomi Valkeinen , Peter Ujfalusi , Sasha Levin Subject: [PATCH AUTOSEL 4.18 23/45] drm/omap: fix memory barrier bug in DMM driver Date: Sun, 4 Nov 2018 08:52:18 -0500 Message-Id: <20181104135240.88431-23-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135240.88431-1-sashal@kernel.org> References: <20181104135240.88431-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomi Valkeinen [ Upstream commit 538f66ba204944470a653a4cccc5f8befdf97c22 ] A DMM timeout "timed out waiting for done" has been observed on DRA7 devices. The timeout happens rarely, and only when the system is under heavy load. Debugging showed that the timeout can be made to happen much more frequently by optimizing the DMM driver, so that there's almost no code between writing the last DMM descriptors to RAM, and writing to DMM register which starts the DMM transaction. The current theory is that a wmb() does not properly ensure that the data written to RAM is observable by all the components in the system. This DMM timeout has caused interesting (and rare) bugs as the error handling was not functioning properly (the error handling has been fixed in previous commits): * If a DMM timeout happened when a GEM buffer was being pinned for display on the screen, a timeout error would be shown, but the driver would continue programming DSS HW with broken buffer, leading to SYNCLOST floods and possible crashes. * If a DMM timeout happened when other user (say, video decoder) was pinning a GEM buffer, a timeout would be shown but if the user handled the error properly, no other issues followed. * If a DMM timeout happened when a GEM buffer was being released, the driver does not even notice the error, leading to crashes or hang later. This patch adds wmb() and readl() calls after the last bit is written to RAM, which should ensure that the execution proceeds only after the data is actually in RAM, and thus observable by DMM. The read-back should not be needed. Further study is required to understand if DMM is somehow special case and read-back is ok, or if DRA7's memory barriers do not work correctly. Signed-off-by: Tomi Valkeinen Signed-off-by: Peter Ujfalusi Signed-off-by: Sasha Levin --- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c index f92fe205550b..e884183c018a 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c @@ -285,6 +285,17 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait) } txn->last_pat->next_pa = 0; + /* ensure that the written descriptors are visible to DMM */ + wmb(); + + /* + * NOTE: the wmb() above should be enough, but there seems to be a bug + * in OMAP's memory barrier implementation, which in some rare cases may + * cause the writes not to be observable after wmb(). + */ + + /* read back to ensure the data is in RAM */ + readl(&txn->last_pat->next_pa); /* write to PAT_DESCR to clear out any pending transaction */ dmm_write(dmm, 0x0, reg[PAT_DESCR][engine->id]); From patchwork Sun Nov 4 13:52:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150110 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1538118ljp; Sun, 4 Nov 2018 05:53:12 -0800 (PST) X-Google-Smtp-Source: AJdET5cacy0j9A3PXhp/igG2AzYPNKnGHMN+19wk4fD/NA23DkKUHnh3yuGeP5+Eb3HtGlbCEuWR X-Received: by 2002:a17:902:108a:: with SMTP id c10-v6mr19173078pla.49.1541339592472; Sun, 04 Nov 2018 05:53:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541339592; cv=none; d=google.com; s=arc-20160816; b=ihcITczusMgndMe+rnXY3DS7OdSR+TIJnkx/FvHe/495oanTPi7oly5Ap4izPLlMpv oLSuenkcitBMht9d5Tm5UuGjdITitfUi9VnoQnehvC1U0R5nAj47er8+n+jQtZ8r8F1J AQ+0Z93IiD4dmYqAcra00/qvV1vG4b04QJhxjokXx/Agu6JSBnARjRC0b0aRSC80XsVM HyeGoF5UqB0A2XVPvr5ArDyd8Tg9V2xDc8HfJQXi7B3OSXaUNjwiN+3F3Y6s+sWP7Yga mzlY0ItB6TAqc3C1qk+wPVtozrHxwuiwY+T8Q4fV9ASyZt128SflsdDbHoa8+6M/s8oJ yHxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=M9YJTHASomuPid1YBC4H5TP0ehf3Jb/H6oWwX9qj8t4=; b=CKmfy/hY7UGoEiYWoLhNP5SYjgVKoZmTkt3OPKN9zrdJ99ztjczPuohyq+fXljmT04 mGh096s0cbboGB0rfwKnuhCv9Mui1TC9DNc7Uat5rfEZ1ZeQu2hcrpZ1tfkeOuXf+huS GCHnSNd6Lenf+/sVLZO0x5djEUte20hY4iAhsIpprUYMfZGoQjuiMldRhBy3BTBFWkli IELgiue44bJoMZ7I/aG3GZzZUMkfM/gi/kcqw0Tl3TwPUvQneclvuLIN2snTJx6f86WA U9V7iYlHtvo5zqWcY8iaBN8MGOa3FgSz2nwbwtBM9KkN1k8eR+hd49lef/3+M8uCZ551 vKrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vn0fF7bz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20-v6si26101908pgg.503.2018.11.04.05.53.12; Sun, 04 Nov 2018 05:53:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vn0fF7bz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730908AbeKDXIN (ORCPT + 32 others); Sun, 4 Nov 2018 18:08:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:46682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730884AbeKDXIN (ORCPT ); Sun, 4 Nov 2018 18:08:13 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28D41204FD; Sun, 4 Nov 2018 13:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339588; bh=xZXo0NyrnN9ENqHCMkPUPa3ZpIa13R7fzVlMeDCtsmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vn0fF7bzopA8DAO5auBuahxnBUuaM7labTPSm93s71Dum8oenOJh5MvDWNAPQS/li gfae2wmDvnAYS5y09J/8kddqulO4Zee/wnKGfcVrXLXlPAaYsQBYfRPsnXSD8t0tea B5OXSs5Vzcg/9kaugAQwGXt2o8uB8/OeIxPbDm6U= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: John Garry , Xinliang Liu , Sasha Levin Subject: [PATCH AUTOSEL 4.18 27/45] drm/hisilicon: hibmc: Do not carry error code in HiBMC framebuffer pointer Date: Sun, 4 Nov 2018 08:52:22 -0500 Message-Id: <20181104135240.88431-27-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135240.88431-1-sashal@kernel.org> References: <20181104135240.88431-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry [ Upstream commit 331d880b35a76b5de0eec8cbcecbf615d758a5f9 ] In hibmc_drm_fb_create(), when the call to hibmc_framebuffer_init() fails with error, do not store the error code in the HiBMC device frame-buffer pointer, as this will be later checked for non-zero value in hibmc_fbdev_destroy() when our intention is to check for a valid function pointer. This fixes the following crash: [ 9.699791] Unable to handle kernel NULL pointer dereference at virtual address 000000000000001a [ 9.708672] Mem abort info: [ 9.711489] ESR = 0x96000004 [ 9.714570] Exception class = DABT (current EL), IL = 32 bits [ 9.720551] SET = 0, FnV = 0 [ 9.723631] EA = 0, S1PTW = 0 [ 9.726799] Data abort info: [ 9.729702] ISV = 0, ISS = 0x00000004 [ 9.733573] CM = 0, WnR = 0 [ 9.736566] [000000000000001a] user address but active_mm is swapper [ 9.742987] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 9.748614] Modules linked in: [ 9.751694] CPU: 16 PID: 293 Comm: kworker/16:1 Tainted: G W 4.19.0-rc4-next-20180920-00001-g9b0012c #322 [ 9.762681] Hardware name: Huawei Taishan 2280 /D05, BIOS Hisilicon D05 IT21 Nemo 2.0 RC0 04/18/2018 [ 9.771915] Workqueue: events work_for_cpu_fn [ 9.776312] pstate: 60000005 (nZCv daif -PAN -UAO) [ 9.781150] pc : drm_mode_object_put+0x0/0x20 [ 9.785547] lr : hibmc_fbdev_fini+0x40/0x58 [ 9.789767] sp : ffff00000af1bcf0 [ 9.793108] x29: ffff00000af1bcf0 x28: 0000000000000000 [ 9.798473] x27: 0000000000000000 x26: ffff000008f66630 [ 9.803838] x25: 0000000000000000 x24: ffff0000095abb98 [ 9.809203] x23: ffff8017db92fe00 x22: ffff8017d2b13000 [ 9.814568] x21: ffffffffffffffea x20: ffff8017d2f80018 [ 9.819933] x19: ffff8017d28a0018 x18: ffffffffffffffff [ 9.825297] x17: 0000000000000000 x16: 0000000000000000 [ 9.830662] x15: ffff0000092296c8 x14: ffff00008939970f [ 9.836026] x13: ffff00000939971d x12: ffff000009229940 [ 9.841391] x11: ffff0000085f8fc0 x10: ffff00000af1b9a0 [ 9.846756] x9 : 000000000000000d x8 : 6620657a696c6169 [ 9.852121] x7 : ffff8017d3340580 x6 : ffff8017d4168000 [ 9.857486] x5 : 0000000000000000 x4 : ffff8017db92fb20 [ 9.862850] x3 : 0000000000002690 x2 : ffff8017d3340480 [ 9.868214] x1 : 0000000000000028 x0 : 0000000000000002 [ 9.873580] Process kworker/16:1 (pid: 293, stack limit = 0x(____ptrval____)) [ 9.880788] Call trace: [ 9.883252] drm_mode_object_put+0x0/0x20 [ 9.887297] hibmc_unload+0x1c/0x80 [ 9.890815] hibmc_pci_probe+0x170/0x3c8 [ 9.894773] local_pci_probe+0x3c/0xb0 [ 9.898555] work_for_cpu_fn+0x18/0x28 [ 9.902337] process_one_work+0x1e0/0x318 [ 9.906382] worker_thread+0x228/0x450 [ 9.910164] kthread+0x128/0x130 [ 9.913418] ret_from_fork+0x10/0x18 [ 9.917024] Code: a94153f3 a8c27bfd d65f03c0 d503201f (f9400c01) [ 9.923180] ---[ end trace 2695ffa0af5be375 ]--- Fixes: d1667b86795a ("drm/hisilicon/hibmc: Add support for frame buffer") Signed-off-by: John Garry Reviewed-by: Xinliang Liu Signed-off-by: Xinliang Liu Signed-off-by: Sasha Levin --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c index b92595c477ef..8bd29075ae4e 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c @@ -122,6 +122,7 @@ static int hibmc_drm_fb_create(struct drm_fb_helper *helper, hi_fbdev->fb = hibmc_framebuffer_init(priv->dev, &mode_cmd, gobj); if (IS_ERR(hi_fbdev->fb)) { ret = PTR_ERR(hi_fbdev->fb); + hi_fbdev->fb = NULL; DRM_ERROR("failed to initialize framebuffer: %d\n", ret); goto out_release_fbi; } From patchwork Sun Nov 4 13:52:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150120 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1545719ljp; Sun, 4 Nov 2018 06:02:24 -0800 (PST) X-Google-Smtp-Source: AJdET5cJCXZR/CPS6OC3Fk83wvoxfSSJpWuSUmki9rR9Mwio2ZGqQer+nLaDCkuYO3Rw2kt4PdAy X-Received: by 2002:a62:9109:: with SMTP id l9-v6mr18581079pfe.154.1541340143968; Sun, 04 Nov 2018 06:02:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340143; cv=none; d=google.com; s=arc-20160816; b=Aips07dMzL5UX3+viMBAvMKRmw+VZXAVTfnz1Vvz15qFRL/EpmE6nWtuM+LYlCNvlt 5P+D+NTW43Rx8O/dmvm8PWyNFQmz1iZfRlYeF7V7tmgTSkOpvvdGTqg2JH1GZJb52ysm HxPq7Azmesm0uO1dd3JuKoWUTTN026WNNL5EqObO3WcfL4UAFYlBMcdAAUXOwuh89a7K pVDeZbatFDV73qFbVYP5eaCb1RRA8S/8ujg7ix5KLENiOGekPbbhMCKPOzgoew1VdcC6 +V8hGFYJ1GTfvZVY23Kyh7JAHWspnNv1yh2r2WE7JRimgT7bY9Bdnt0DRpRGg3yokvd0 SvTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=7oXcIrqtSmuyBPYUG1e+EHqqso2pIJMI76WGppdfM4s=; b=ESApVUXCBFOJwo6/AZLa+KiS/k+tKqDTjqNeg+bu69Ylp06dKfDGBN39rI4uOk7Gon jl3cDYD0ijJCtVhUsaYGL5o88lPUQLnZeYnP6M0MNCnWK3NElxY4hR9J1xV8Vl0Glp5a Dh8s3EPs3nOMMO1ONbYsrqt9j3w/zCIK7f1Zshx7LXBumNirjgpBhy9XCKAGEy+XNDEt WXSl8p4nwqPDXcj7tqx7EXt4aBzmS4SgobUGagmcCRtT40KBmHl24ZO3Ebk5g3d3HYfg vLnpSXYzo9lVEt33sA/qFHG1DL8vqTtkT4gFIUrFvLrfRN6RM3tvHN0r/88ogpq4kBNp FJ2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XN4m8VJx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si10915652pgg.510.2018.11.04.06.02.23; Sun, 04 Nov 2018 06:02:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XN4m8VJx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731648AbeKDXR2 (ORCPT + 32 others); Sun, 4 Nov 2018 18:17:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:46858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730941AbeKDXIR (ORCPT ); Sun, 4 Nov 2018 18:08:17 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 247D120869; Sun, 4 Nov 2018 13:53:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339593; bh=M+nlvSSWJ6LODF+My80H6Ek0nsvcQgbQobsSHZ3QULs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XN4m8VJxfqJL9aTy//G86LiZ9DVqINJrXXIaSjOvMe7mlpdz6K4veWMFQhUTmJFHm x0nfkW8LB88CfIRdeNj5Lz0099MVyEEzfoas1uoL40qbeMBks/dY42aCNSMbk7SFjl jOIUAKhl1+sS4qOcLVRlDmP1QmcW2kRCbiUrHwX8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joel Stanley , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL 4.18 32/45] powerpc/boot: Ensure _zimage_start is a weak symbol Date: Sun, 4 Nov 2018 08:52:27 -0500 Message-Id: <20181104135240.88431-32-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135240.88431-1-sashal@kernel.org> References: <20181104135240.88431-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joel Stanley [ Upstream commit ee9d21b3b3583712029a0db65a4b7c081d08d3b3 ] When building with clang crt0's _zimage_start is not marked weak, which breaks the build when linking the kernel image: $ objdump -t arch/powerpc/boot/crt0.o |grep _zimage_start$ 0000000000000058 g .text 0000000000000000 _zimage_start ld: arch/powerpc/boot/wrapper.a(crt0.o): in function '_zimage_start': (.text+0x58): multiple definition of '_zimage_start'; arch/powerpc/boot/pseries-head.o:(.text+0x0): first defined here Clang requires the .weak directive to appear after the symbol is declared. The binutils manual says: This directive sets the weak attribute on the comma separated list of symbol names. If the symbols do not already exist, they will be created. So it appears this is different with clang. The only reference I could see for this was an OpenBSD mailing list post[1]. Changing it to be after the declaration fixes building with Clang, and still works with GCC. $ objdump -t arch/powerpc/boot/crt0.o |grep _zimage_start$ 0000000000000058 w .text 0000000000000000 _zimage_start Reported to clang as https://bugs.llvm.org/show_bug.cgi?id=38921 [1] https://groups.google.com/forum/#!topic/fa.openbsd.tech/PAgKKen2YCY Signed-off-by: Joel Stanley Reviewed-by: Nick Desaulniers Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/boot/crt0.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S index dcf2f15e6797..32dfe6d083f3 100644 --- a/arch/powerpc/boot/crt0.S +++ b/arch/powerpc/boot/crt0.S @@ -47,8 +47,10 @@ p_end: .long _end p_pstack: .long _platform_stack_top #endif - .weak _zimage_start .globl _zimage_start + /* Clang appears to require the .weak directive to be after the symbol + * is defined. See https://bugs.llvm.org/show_bug.cgi?id=38921 */ + .weak _zimage_start _zimage_start: .globl _zimage_start_lib _zimage_start_lib: