From patchwork Sun Nov 19 23:34:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Zigotzky X-Patchwork-Id: 839369 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yg7Ww582Bz9s7c for ; Mon, 20 Nov 2017 10:35:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xenosoft.de header.i=@xenosoft.de header.b="uvW1k6pD"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yg7Ww2j4mzDrV9 for ; Mon, 20 Nov 2017 10:35:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xenosoft.de header.i=@xenosoft.de header.b="uvW1k6pD"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=mo6-p00-ob.smtp.rzone.de (client-ip=2a01:238:20a:202:5300::4; helo=mo6-p00-ob.smtp.rzone.de; envelope-from=chzigotzky@xenosoft.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xenosoft.de header.i=@xenosoft.de header.b="uvW1k6pD"; dkim-atps=neutral Received: from mo6-p00-ob.smtp.rzone.de (mo6-p00-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5300::4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yg7V73HKWzDrRj for ; Mon, 20 Nov 2017 10:34:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1511134456; s=domk; d=xenosoft.de; h=Content-Language:Content-Type:In-Reply-To:MIME-Version:Date: References:To:From:Subject; bh=CRRBZrZRPvJan/fK+D7uh/hxieMpCstrYwEaLnDAB6g=; b=uvW1k6pDEdBVCVj/LvE7yt5IQ970CFj8helm3opkCXF0MvCzTILXroU0/X1VM/tWVP DkbBnuW3BC2LsWSwZNmYMBI9GNhHTdnAT2hKQcIt6+iaWFGaiauEdLJ7nEYOCRVNZsb0 0qwMg7TqYaDpWrOmU4fQX+nUQYc39I1FtZHcE= X-RZG-AUTH: :L2QefEenb+UdBJSdRCXu93KJ1bmSGnhMdmOod1DhGM4l4Hio94KKxRySf+VvAflxJtIT50wmwd4v X-RZG-CLASS-ID: mo00 Received: from [192.168.1.139] (ppp-188-174-95-145.dynamic.mnet-online.de [188.174.95.145]) by smtp.strato.de (RZmta 42.9 DYNA|AUTH) with ESMTPSA id m08e38tAJNYFS6S (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate) for ; Mon, 20 Nov 2017 00:34:15 +0100 (CET) Subject: Qoriq P5020 PowerPC board doesn't boot with the latest git version anymore From: Christian Zigotzky To: linuxppc-dev@lists.ozlabs.org References: <3e4805a4-6114-205d-653b-ea6cd7fdc057@xenosoft.de> <8ed2edc7-a14b-35b3-86c1-a9995f41df84@xenosoft.de> Message-ID: Date: Mon, 20 Nov 2017 00:34:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux ppc64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <8ed2edc7-a14b-35b3-86c1-a9995f41df84@xenosoft.de> Content-Language: de-LU X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi All, I created a patch for the git kernel today. (see attachment) Without the patch, the latest git kernel doesn't boot on my Cyrus Plus board. Cheers, Christian On 19 November 2017 at 5:57PM, Christian Zigotzky wrote: > Hi All, > > A little success. :-) I reverted the following files from the bad > commit a8a217c22116eff6c120d753c9934089fb229af0 [1]: > > arch/powerpc/include/asm/spinlock.h > kernel/locking/spinlock.c > include/linux/spinlock_up.h > include/linux/spinlock.h > include/linux/rwlock.h > > After that I compiled the latest git kernel again. Then I was able to > boot the latest git kernel on my Varisys Cyrus Plus board [2][3]. :-) > > That means the bug is in one of these files. > > Please help me to find the bug in these files above. > > Thanks, > Christian > > > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a8a217c22116eff6c120d753c9934089fb229af0 > [2] http://www.amigaos.net/hardware/133/amigaone-x5000 > [3] http://wiki.amiga.org/index.php?title=AmigaONE_X5000 > --- a/arch/powerpc/include/asm/spinlock.h 2017-11-18 20:57:47.921703650 +0100 +++ b/arch/powerpc/include/asm/spinlock.h 2017-11-19 18:51:51.630906446 +0100 @@ -182,6 +182,9 @@ static inline void arch_spin_unlock(arch * read-locks. */ +#define arch_read_can_lock(rw) ((rw)->lock >= 0) +#define arch_write_can_lock(rw) (!(rw)->lock) + #ifdef CONFIG_PPC64 #define __DO_SIGN_EXTEND "extsw %0,%0\n" #define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */ --- a/kernel/locking/spinlock.c 2017-11-18 20:57:48.974708915 +0100 +++ b/kernel/locking/spinlock.c 2017-11-19 18:26:18.526892449 +0100 @@ -35,6 +35,9 @@ */ #else +#define raw_read_can_lock(l) read_can_lock(l) +#define raw_write_can_lock(l) write_can_lock(l) + /* * Some architectures can relax in favour of the CPU owning the lock. */ @@ -68,7 +71,7 @@ void __lockfunc __raw_##op##_lock(lockty \ if (!(lock)->break_lock) \ (lock)->break_lock = 1; \ - while ((lock)->break_lock) \ + while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\ arch_##op##_relax(&lock->raw_lock); \ } \ (lock)->break_lock = 0; \ @@ -88,7 +91,7 @@ unsigned long __lockfunc __raw_##op##_lo \ if (!(lock)->break_lock) \ (lock)->break_lock = 1; \ - while ((lock)->break_lock) \ + while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\ arch_##op##_relax(&lock->raw_lock); \ } \ (lock)->break_lock = 0; \ --- a/include/linux/spinlock_up.h 2017-11-18 20:57:38.788657985 +0100 +++ b/include/linux/spinlock_up.h 2017-11-19 18:48:19.787635450 +0100 @@ -69,4 +69,7 @@ static inline void arch_spin_unlock(arch #define arch_spin_is_contended(lock) (((void)(lock), 0)) +#define arch_read_can_lock(lock) (((void)(lock), 1)) +#define arch_write_can_lock(lock) (((void)(lock), 1)) + #endif /* __LINUX_SPINLOCK_UP_H */ --- a/include/linux/spinlock.h 2017-11-18 20:57:38.693657510 +0100 +++ b/include/linux/spinlock.h 2017-11-19 18:37:36.933284464 +0100 @@ -283,6 +283,12 @@ static inline void do_raw_spin_unlock(ra 1 : ({ local_irq_restore(flags); 0; }); \ }) +/** + * raw_spin_can_lock - would raw_spin_trylock() succeed? + * @lock: the spinlock in question. + */ +#define raw_spin_can_lock(lock) (!raw_spin_is_locked(lock)) + /* Include rwlock functions */ #include @@ -395,6 +401,11 @@ static __always_inline int spin_is_conte return raw_spin_is_contended(&lock->rlock); } +static __always_inline int spin_can_lock(spinlock_t *lock) +{ + return raw_spin_can_lock(&lock->rlock); +} + #define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock) /* --- a/include/linux/rwlock.h 2017-11-18 20:57:38.652657305 +0100 +++ b/include/linux/rwlock.h 2017-11-19 18:19:54.045970054 +0100 @@ -59,6 +59,9 @@ do { \ # define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->raw_lock); __release(lock); } while (0) #endif +#define read_can_lock(rwlock) arch_read_can_lock(&(rwlock)->raw_lock) +#define write_can_lock(rwlock) arch_write_can_lock(&(rwlock)->raw_lock) + /* * Define the various rw_lock methods. Note we define these * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various