Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp398684ybc; Fri, 22 Nov 2019 07:03:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwYfp9FQATUKdDVl7BA0/jOj63STpIbetPeTMDgVJvy7WvqwsSwngDLzy4hKmKcjPDqR94x X-Received: by 2002:a50:a5a5:: with SMTP id a34mr1588814edc.217.1574435037057; Fri, 22 Nov 2019 07:03:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574435037; cv=none; d=google.com; s=arc-20160816; b=wofjnnPGiRMsL6o8MC8nkIy5kfOfbIlHV0WpwkoVrIaxQn1jzJZDQzetoGZ8hZSf4W kF2eLhKDHEsOl+Z+EqSv6owKCj2ho7SDST9UShMX2mxyS3BjDUJwkTwCeVmXjGWE4jvZ yn0ABCgttPfrzv1JYiLG6JayQ9SqnPrYGEpJeGHrgHBZQOJDJR0gYyDyZQb8ow2NM1e6 WZyxgnj2hsjOgSIzyYnRrhBRYDPovgYPvAFEpbhG5BEMqM69huC5qjMAZTGWQUAZ3sen SkJnKvMoK6GleYcH2gtSu5uioIU/5ZZNXIjCysGcBG1q4xfY3UbfVCPQc2dnUF6sIxIS np8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=YKrP6olTyoVQWnqntUSJ3R3+TkpdqJFIJOVy9eC5Mdo=; b=q3c9ptCcEMGlTmSuaUVhhlzfxdu4Im6hpIS6E3szHNIaZKe1fIpZMPAVdMTdb10DCJ fjoIzxl2vIVudpmNRF9RKLPq4U/skaR3wNgTCL5+1bZjyafAUMxBdQEao2IO0sp1DOSO c7+ydqFn1QqaJ/9MvClcInjbUdxpT8vyTf1q1gXHmwZbrEh8RZxS5Bj23WRiWnEG4AwO f9zxECk89yp14lrB27ZF6Yz5v8c7QPxL88lt08uxGZQO38ErgTPCnZgDqrYwmCbWOjm4 4sn6k6hxSl+KetzUHL78eTS0Tj7ThN7zeHdeRcBGQ+fX7C5XDeKuuhDzavhQ+/YPsgPB QHBw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c3si727134edq.30.2019.11.22.07.03.30; Fri, 22 Nov 2019 07:03:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbfKVO7K (ORCPT + 99 others); Fri, 22 Nov 2019 09:59:10 -0500 Received: from foss.arm.com ([217.140.110.172]:48596 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbfKVO7K (ORCPT ); Fri, 22 Nov 2019 09:59:10 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 07C22DA7; Fri, 22 Nov 2019 06:59:10 -0800 (PST) Received: from [10.1.196.37] (e121345-lin.cambridge.arm.com [10.1.196.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C59D03F703; Fri, 22 Nov 2019 06:59:07 -0800 (PST) Subject: Re: [PATCH v2 4/6] PCI: brcmstb: add Broadcom STB PCIe host controller driver To: Jim Quinlan , Nicolas Saenz Julienne Cc: Florian Fainelli , maz@kernel.org, Phil Elwell , linux-kernel@vger.kernel.org, Jeremy Linton , Eric Anholt , mbrugger@suse.com, bcm-kernel-feedback-list , Stefan Wahren , Jim Quinlan , linux-pci , Bjorn Helgaas , Andrew Murray , Lorenzo Pieralisi , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linux-rpi-kernel@lists.infradead.org References: <20191112155926.16476-1-nsaenzjulienne@suse.de> <20191112155926.16476-5-nsaenzjulienne@suse.de> <20191119162502.GS43905@e119886-lin.cambridge.arm.com> <7e1be0bdcf303224a3fe225654a3c2391207f9eb.camel@suse.de> <20191121120319.GW43905@e119886-lin.cambridge.arm.com> <276d4160bbe6a4e8225bbd836f43d40da41d25f1.camel@suse.de> From: Robin Murphy Message-ID: <24e5302a-51c6-df39-5381-a790752f261d@arm.com> Date: Fri, 22 Nov 2019 14:59:06 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/11/2019 9:07 pm, Jim Quinlan wrote: [...] >> As for [...]_NUM_MASK_BITS I'm looking for a smart/generic way to calculate it >> from the actual mask. No luck so far. If not, I think I'll simply leave it as >> is for now. HWEIGHT()? >>>> FYI, What's happening here is that we have to save the CPU address range >>>> (which >>>> is already shifted right 20 positions) in two parts, the lower 12 bits go >>>> into >>>> PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT while the higher 8 bits go into >>>> PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI or >>>> PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI. >>> >>> The hardware spec require bits 31:20 of the address, and the high registers >>> require 39:32 right? >> >> Yes, that's it. >> >>> (Apologies, the indirection by the WR_FLD_** macros easily confuses me. These >>> type of macros are helpful, or rather would be if the whole kernel used them. >>> I think they can add confusion when each driver has its own set of similar >>> macros. This is why its *really* helpful to use any existing macros in the >>> kernel - and only invent new ones if needed). >> >> I agree it's pretty confusing, I think v3, using bitfield.h as much as >> possible, looks substantially more welcoming. > > The reason we use custom macros is because we'd like to keep the > register names the same as the HW declares and our internal tools > support. As you may have noticed, our register names are unusually > long and it is hard to fit a simple read or write field assignment > within 80 columns w/o using custom macros tailored to our register > names' format. > > Perhaps Nicolas can pull a rabbit out of a hat and use Linux macros > while keeping our long register names, but if he has to use his own > shorter register names it will become harder for Broadcom developers > to debug this driver. Regardless of the length of the names, the standard bitfield helpers can still make things easier to reason about - in this particular case I think you could lose some boilerplate and indirection with essentially no change to the readability you're concerned for - compare: #define REG_NAME ... #define REG_NAME_FIELD_NAME_MASK ... #define REG_NAME_FIELD_NAME_SHIFT ... val = RD_FIELD(base, REG_NAME, FIELD_NAME); vs. #define REG_NAME ... #define FIELD_NAME ... reg = bcm_readl(base + REG_NAME); val = FIELD_GET(FIELD_NAME, reg); Robin.