From owner-freebsd-current@FreeBSD.ORG Tue Mar 5 15:37:45 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C769AE2B; Tue, 5 Mar 2013 15:37:45 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 3C7AF936; Tue, 5 Mar 2013 15:37:45 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.6/8.14.6) with ESMTP id r25FbajN006299; Tue, 5 Mar 2013 17:37:36 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.0 kib.kiev.ua r25FbajN006299 Received: (from kostik@localhost) by tom.home (8.14.6/8.14.6/Submit) id r25Fba71006298; Tue, 5 Mar 2013 17:37:36 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 5 Mar 2013 17:37:36 +0200 From: Konstantin Belousov To: Jean-S?bastien P?dron Subject: Re: r247835: drm2 code breaks buildkernel Message-ID: <20130305153736.GH3794@kib.kiev.ua> References: <5135C70B.50906@zedat.fu-berlin.de> <5135CD0E.8040801@dumbbell.fr> <5135DE36.9010303@zedat.fu-berlin.de> <20130305123016.GE1483@glenbarber.us> <5135FD78.1050608@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jaoouwwPWoQSJZYp" Content-Disposition: inline In-Reply-To: <5135FD78.1050608@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: freebsd-current@freebsd.org, "J.R. Oldroyd" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Mar 2013 15:37:45 -0000 --jaoouwwPWoQSJZYp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 05, 2013 at 03:13:12PM +0100, Jean-S?bastien P?dron wrote: > On 05.03.2013 13:30, Glen Barber wrote: > > dev/drm2/ttm/ttm_lock.h:208: warning: redundant redeclaration of 'ttm_w= rite_unlock' [-Wredundant-decls] > > dev/drm2/ttm/ttm_lock.h:134: warning: previous declaration of 'ttm_writ= e_unlock' was here > > dev/drm2/ttm/ttm_lock.h:220: warning: redundant redeclaration of 'ttm_w= rite_lock' [-Wredundant-decls] > > dev/drm2/ttm/ttm_lock.h:146: warning: previous declaration of 'ttm_writ= e_lock' was here >=20 > Those redundant declarations weren't spotted by clang. >=20 > Konstantin, would you like me to commit the fix for this? And we need to > upstream it too. I am somewhat sceptical about upstreaming. I reported a real bug in the ttm_lock with the trivial fix when I read the code for porting. Bug was confirmed by Linux people, but no action was taken. >=20 > > dev/drm2/ttm/ttm_page_alloc.c:122: warning: declaration does not declar= e anything > > dev/drm2/ttm/ttm_page_alloc.c:123: warning: declaration does not declar= e anything >=20 > These errors and the following are caused by unnamed structs and unions > inside another struct: >=20 > struct ttm_pool_manager { > ... >=20 > union { > struct ttm_page_pool pools[NUM_POOLS]; > struct { > ... > } ; > }; > }; >=20 > With default options, clang accepts this but apparently, not gcc. >=20 > I would like an opinion from the toolchain gurus, because I don't know > what's the proper way to fix this one. >=20 > J.R. Oldroyd CC'd, because he started to work on radeonkms backport to 9 > and faced exactly those issues. The patch below is supposed to fix double declaration (it is pathetic that clang silently accepts this, while issuing countless useless warnings). Also there is a usual workaround for the anonimous union/struct issue. Glen neglected to even mention that he used gcc (is it true ?), as well as to show the command line invocation of the compiler. Hopefully the patch helps. diff --git a/sys/dev/drm2/ttm/ttm_lock.h b/sys/dev/drm2/ttm/ttm_lock.h index ac8159e..6d45457 100644 --- a/sys/dev/drm2/ttm/ttm_lock.h +++ b/sys/dev/drm2/ttm/ttm_lock.h @@ -125,27 +125,6 @@ extern int ttm_read_lock(struct ttm_lock *lock, bool i= nterruptible); extern int ttm_read_trylock(struct ttm_lock *lock, bool interruptible); =20 /** - * ttm_write_unlock - * - * @lock: Pointer to a struct ttm_lock - * - * Releases a write lock. - */ -extern void ttm_write_unlock(struct ttm_lock *lock); - -/** - * ttm_write_lock - * - * @lock: Pointer to a struct ttm_lock - * @interruptible: Interruptible sleeping while waiting for a lock. - * - * Takes the lock in write mode. - * Returns: - * -ERESTARTSYS If interrupted by a signal and interruptible is true. - */ -extern int ttm_write_lock(struct ttm_lock *lock, bool interruptible); - -/** * ttm_lock_downgrade * * @lock: Pointer to a struct ttm_lock diff --git a/sys/dev/drm2/ttm/ttm_page_alloc.c b/sys/dev/drm2/ttm/ttm_page_= alloc.c index ffc8483..9a30a46 100644 --- a/sys/dev/drm2/ttm/ttm_page_alloc.c +++ b/sys/dev/drm2/ttm/ttm_page_alloc.c @@ -113,16 +113,22 @@ struct ttm_pool_manager { struct ttm_pool_opts options; =20 union { - struct ttm_page_pool pools[NUM_POOLS]; - struct { - struct ttm_page_pool wc_pool; - struct ttm_page_pool uc_pool; - struct ttm_page_pool wc_pool_dma32; - struct ttm_page_pool uc_pool_dma32; - } ; - }; + struct ttm_page_pool u_pools[NUM_POOLS]; + struct _utag { + struct ttm_page_pool u_wc_pool; + struct ttm_page_pool u_uc_pool; + struct ttm_page_pool u_wc_pool_dma32; + struct ttm_page_pool u_uc_pool_dma32; + } _ut; + } _u; }; =20 +#define pools _u.u_pools +#define wc_pool _u._ut.u_wc_pool +#define uc_pool _u._ut.u_uc_pool +#define wc_pool_dma32 _u._ut.u_wc_pool_dma32 +#define uc_pool_dma32 _u._ut.u_uc_pool_dma32 + MALLOC_DEFINE(M_TTM_POOLMGR, "ttm_poolmgr", "TTM Pool Manager"); =20 static void --jaoouwwPWoQSJZYp Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIbBAEBAgAGBQJRNhFAAAoJEJDCuSvBvK1BpWQP9AgDjnFoVqBbbiQVEvSgSXpn KtZ6XfYhJL3aqAVlejKDmRNxOigU7t89bNxomYS+4BHxl8iTgX0O1KyBxi9muzKP VrwtfpD4K5Q77pM8EkQRb3PscxUUO0KuJlluk+pZlfb4w/Wh1bBXLmBcfprU645J RRTW6dm9D4Vkj/CmojqM0es2eI34hlJclqGkXAvez4a8PZIV4bzffoDF1DmehQnt 3QenI3M9fEwbg2CR1TYohsAgTZkEEJnuHlVjVB7Ll2xjr9aobrmTmRm9ZjUctTfL PHSZjgc3gDAfdHtpovW7DMrpJ37umXxqSi5INXkUvPKoML0Ejz8HW+QiSksFH7uB exwHeqKDGno4jKL625hvhLov3P3aK//50ZlWjW3E5ujqaLw0q48DEgJsACoEYu8e R2m6MlOHqxuLtIaMLW93ghJxu2ihP/nzj7GkP2Nv15/QR9H76ADTT4MnYD9S1bUr HU5S+/I+TibX2luIEtiokr4Y7Q6JC2GSl0NR/aqbXpuQOC+n8J6qifp/soXO/d+q iLT7L6mM387gaGfw4aFZP2bTHD2Rzv5D5OEKp879Kwp9CCm7VdIlg9M4KcV8KILv ZwYBoMch4T6GBnpykym0nXxXNa63J3CUf8c7Mn1zxqlAuPAg/vQuUnfSZlCQYjRM uZk44OVKTRSabmxkWkI= =hgsW -----END PGP SIGNATURE----- --jaoouwwPWoQSJZYp--