From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E23D0C433EF for ; Wed, 17 Nov 2021 12:44:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F3AB60FED for ; Wed, 17 Nov 2021 12:44:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9F3AB60FED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nIVJIklHpvCAexl3VjT7LixFWvbhjad9nL3aEPVKQO8=; b=nsOMd3S974tNtd eVR89bmlvWiZVsu+OVRi77quSA0IgQbwkXhLroD7+AwLqy8Gf+t/MmZSltrYugEkf3YBMTFaL0qa+ 3JyI7HDkUK99PgUJnhdaObbyEP2t0H/nDYad3/vHmC44yfQ/rg/a3Se/y5FZc+wOj9+tw88tRVwaQ cZtXoaVbvMf84qHiNLT9j/xpS/3yYsY0Ipwo1Pc/cqMaQ1fodGvipF5Xmp3xmDSsprg0C38ATLzQm U6eZREaBJEPSNeZ04pYCKe6IbWqgsSA8Fawc6ibsz1f3OsgBoc2mwILt0SwJWKSlYHDRKvm2MbY1I UUgxjJJdCc7xUkHxJ0Ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnKGw-004jcp-KC; Wed, 17 Nov 2021 12:42:42 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnKGs-004jc4-8K; Wed, 17 Nov 2021 12:42:39 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10170"; a="233884934" X-IronPort-AV: E=Sophos;i="5.87,241,1631602800"; d="scan'208";a="233884934" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2021 04:42:36 -0800 X-IronPort-AV: E=Sophos;i="5.87,241,1631602800"; d="scan'208";a="593340140" Received: from smile.fi.intel.com ([10.237.72.184]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2021 04:42:33 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1mnKGf-007n8z-Te; Wed, 17 Nov 2021 14:42:25 +0200 Date: Wed, 17 Nov 2021 14:42:25 +0200 From: Andy Shevchenko To: Florian Fainelli Cc: bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Quinlan , Nicolas Saenz Julienne , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas Subject: Re: [PATCH v2 1/1] PCI: brcmstb: Use BIT() as __GENMASK() is for internal use only Message-ID: References: <20211115112000.23693-1-andriy.shevchenko@linux.intel.com> <41b85802-6118-33a6-692a-043d74b82d8e@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <41b85802-6118-33a6-692a-043d74b82d8e@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_044238_359459_1C55F86A X-CRM114-Status: GOOD ( 17.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 16, 2021 at 12:38:39PM -0800, Florian Fainelli wrote: > On 11/15/21 3:20 AM, Andy Shevchenko wrote: > > Use BIT() as __GENMASK() is for internal use only. The rationale > > of switching to BIT() is to provide better generated code. The > > GENMASK() against non-constant numbers may produce an ugly assembler > > code. On contrary the BIT() is simply converted to corresponding shift > > operation. > > The code is not necessarily any different on ARMv8 as far as I can tell, > before: > > static void brcm_msi_set_regs(struct brcm_msi *msi) > { > u32 val = __GENMASK(31, msi->legacy_shift); > 84: b9406402 ldr w2, [x0,#100] > 88: d2800021 mov x1, #0x1 > // #1 > 8c: 9ac22021 lsl x1, x1, x2 > 90: 4b0103e1 neg w1, w1 > > > after: > > static void brcm_msi_set_regs(struct brcm_msi *msi) > { > u32 val = ~(BIT(msi->legacy_shift) - 1); > 84: b9406402 ldr w2, [x0,#100] > 88: d2800021 mov x1, #0x1 > // #1 > 8c: 9ac22021 lsl x1, x1, x2 > 90: 4b0103e1 neg w1, w1 > > and the usage of BIT() does not make this any clearer. While I disagree on the conclusion it's good that assembly isn't bad. Last time I have tried to compile just GENMASK() excerpts for arm32 the non-constant variants were quite bad. And it was obvious win for BIT() over GENMASK(). Actually it maybe that I have tested something like `GENMASK(C1 + var, C2 + var)` vs. `GENMASK(C1, C2) << var` that time. -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel