Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C0C6C77B7F for ; Mon, 8 May 2023 12:19:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2B07C11C6; Mon, 8 May 2023 14:18:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2B07C11C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683548352; bh=qS/IyHurtYwxUmAB3ePYgJdupD5iJTsM2x68BBMwUuc=; h=Date:From:To:Subject:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Sj2GDEUoP9Vj+gz38x8Ww3OC23VcYehhhcQKla851eb5msPWULM6JW+PnA3QByAQp fCsnWglKyz1+KmpQHL7E4lqnRQz855l0KylBD+m3+XnJbKtz0U0H3yFilqMGHatkJg 7zRibqCV3Pl66ZV/bxisnaGjIzCmuhcszwPbuouI= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 82082F8032D; Mon, 8 May 2023 14:17:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 92930F8032D; Mon, 8 May 2023 14:17:53 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0611EF802E8 for ; Mon, 8 May 2023 14:17:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0611EF802E8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=zlVuvqhk; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+m9K1cU0 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5222B22048; Mon, 8 May 2023 12:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683548266; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RwIsm7ASHSDpCO4K7UmEvzVjZL6xkTh7OrQRNhbkeWE=; b=zlVuvqhkyjc/UutnoUdXby3alM6uc7CMfbWgXLUM4LSGs52wGPlIwVuseG9q5EBE+wxm36 KVF9UKJPaINQjeQzL8oGI2Mo54guPCxIzPi8mviIIMtXejy57QsPwLIKiZ4G3PCmg89h3L f2L9cb1ErxrZcieoWUscJRWTJefCyV8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683548266; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RwIsm7ASHSDpCO4K7UmEvzVjZL6xkTh7OrQRNhbkeWE=; b=+m9K1cU0F2s0K67SN4lxX7IQyIfvxKZdlQTRjITmM9iimcnGXM40W/mta8KtISOoFAqS5a NeJnVTpAv3frilBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 346C31346B; Mon, 8 May 2023 12:17:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZHvkC2roWGQhRwAAMHmgww (envelope-from ); Mon, 08 May 2023 12:17:46 +0000 Date: Mon, 08 May 2023 14:17:45 +0200 Message-ID: <87y1lz6mqe.wl-tiwai@suse.de> From: Takashi Iwai To: Oswald Buddenhagen Subject: Re: [PATCH v2] ALSA: emu10k1: macro-ize snd_emu10k1_ptr_{read,write}() In-Reply-To: <20230508120229.2471010-1-oswald.buddenhagen@gmx.de> References: <20230508120229.2471010-1-oswald.buddenhagen@gmx.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Message-ID-Hash: OONERB4N4VKV3MDLTJDLXBV4CSD4FRFE X-Message-ID-Hash: OONERB4N4VKV3MDLTJDLXBV4CSD4FRFE X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: alsa-devel@alsa-project.org X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Mon, 08 May 2023 14:02:29 +0200, Oswald Buddenhagen wrote: > > The idea to encode the bitfield manipulation in the register address is > quite clever, but it's somewhat wasteful to do these calculations at > runtime, given that they are all constants. So change that. This yields > a marginal saving in runtime cost at a marginal cost in code side (less > than 400 bytes). > > The call sites where the read/write is done with a non-constant register > needed adjustment, so there is a bit of churn involved. On the upside, > this makes the various use cases more obvious, and makes it easier to > grep for them. > > snd_emu10k1_ptr_{read,write}() must be macros, as they check the > constness of the passed register argument, and the C language has no > provisions for doing this differently. There are __builtin_constant_p(), if we inevitably need to check the constant in a static inline function. But, I still doubt whether we can measure any significant runtime cost saving. Do we have numbers? (OTOH, the cost of memory bloat could be measured easily, though.) I'm very much for introducing macros to define the registers instead of magical combos; it'll be a good code simplification and make it easier to read. But for the additional complexity of code just for some micro optimization... I'm not sure whether it's wroth. (If the numbers are convincing, we can go for it, of course.) thanks, Takashi