Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp640272pxt; Thu, 12 Aug 2021 06:32:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvSCHvNhU1KIQS25VLbMazZCZGj5zWeG6hcL7dnIGLH8pQXQJRn27dqfVgpFCnidS8pcLg X-Received: by 2002:a17:906:b104:: with SMTP id u4mr3567294ejy.201.1628775158108; Thu, 12 Aug 2021 06:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628775158; cv=none; d=google.com; s=arc-20160816; b=oV7x1dupvdf2btbWTpb/39whk6ACfNT+7nVc3SOEhYtrD8A5HnBEa7ZV4PvzqkIxux d9KYMSDo6Ba2s7POCM9UnXPBP1KA54VFz4Jm7HYT5F4LH+DLkaLQ4UymydZBFBizq9OK 4U/8JFLjIetvjT2qNrFTmot6eYPIG0YVGNUidlHoQlljCTykbCgSKsCjoefvRhf9Qk3M aocuWlVILD3pX9mpsnNU026ou+AQ9X7NjOBYUUvI7Vcy0TjoKf/1MDdOfndzxO3LFKGr QQwOVysK2YkIPEP99UlobTWH12Lz09irr9MZ3qqSIB5POjYnDZBL6kQv7y8s5tTLD5bU lEVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=s8jaa09NlsPdR4ZDZS2W6doeMJXB2STFIUYquSIFStg=; b=j04RNoobxshygMFiII+iZz3ViJAHZduY099eenUf0xKlbNc/tTbixbBvao/sj7L5kw Abeq3Qf3x57NGi6xKjvs72J+RJejYbkUNPA8DOMG0a5j2VHtPXa7Ju7DNZLf5nQk3Lyq BYO9G2d4pU0eY03PNU8c9iRPDx7GATA1agCdtrqEKD/L2KZj6wS4RJD35Kq/gadZQngb gK85AGmWDXtahjbt8KnTrfPVoB2l1UDzCC77Hw/k1X4PS3Du6S4UA5DpulIoeOqj69R/ TIEdssJRNjEWCl4MYr0PKDRcE5i3tQ7yx+F2QPCnod6GLWR+NMTZ2nUYROPqj4rfnvw7 AvIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si2503887ejj.544.2021.08.12.06.32.13; Thu, 12 Aug 2021 06:32:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237454AbhHLN3B (ORCPT + 99 others); Thu, 12 Aug 2021 09:29:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:33786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232081AbhHLN3A (ORCPT ); Thu, 12 Aug 2021 09:29:00 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 563A560FC3; Thu, 12 Aug 2021 13:28:35 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mEAl7-004Yub-BY; Thu, 12 Aug 2021 14:28:33 +0100 Date: Thu, 12 Aug 2021 14:28:32 +0100 Message-ID: <87zgtm94hr.wl-maz@kernel.org> From: Marc Zyngier To: Huacai Chen Cc: Huacai Chen , Thomas Gleixner , LKML , Xuefeng Li , Jiaxun Yang Subject: Re: [PATCH 3/9] irqchip/loongson-pch-pic: Add ACPI init support In-Reply-To: References: <20210706030904.1411775-1-chenhuacai@loongson.cn> <20210706030904.1411775-4-chenhuacai@loongson.cn> <877di38u5c.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: chenhuacai@gmail.com, chenhuacai@loongson.cn, tglx@linutronix.de, linux-kernel@vger.kernel.org, lixuefeng@loongson.cn, jiaxun.yang@flygoat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Aug 2021 13:23:27 +0100, Huacai Chen wrote: > [...] > > > > +struct fwnode_handle *pch_pic_acpi_init(struct fwnode_handle *parent, > > > > + struct acpi_madt_bio_pic *acpi_pchpic) > > > > +{ > > > > + int count; > > > > + struct pch_pic *priv; > > > > + struct irq_domain *parent_domain; > > > > + > > > > + priv = kzalloc(sizeof(*priv), GFP_KERNEL); > > > > + if (!priv) > > > > + return NULL; > > > > + > > > > + raw_spin_lock_init(&priv->pic_lock); > > > > + priv->base = ioremap(acpi_pchpic->address, acpi_pchpic->size); > > > > + if (!priv->base) > > > > + goto free_priv; > > > > + > > > > + priv->domain_handle = irq_domain_alloc_fwnode(priv->base); > > > > + if (!priv->domain_handle) { > > > > + pr_err("Unable to allocate domain handle\n"); > > > > + goto iounmap_base; > > > > + } > > > > + > > > > + priv->ht_vec_base = acpi_pchpic->gsi_base; > > > > + count = ((readq(priv->base) >> 48) & 0xff) + 1; > > > > + parent_domain = irq_find_matching_fwnode(parent, DOMAIN_BUS_ANY); > > > > + if (!parent_domain) { > > > > + pr_err("Failed to find the parent domain\n"); > > > > + goto iounmap_base; > > > > + } > > > > + > > > > + priv->pic_domain = irq_domain_create_hierarchy(parent_domain, 0, > > > > + count, priv->domain_handle, > > > > + &pch_pic_domain_ops, priv); > > > > + > > > > + if (!priv->pic_domain) { > > > > + pr_err("Failed to create IRQ domain\n"); > > > > + goto iounmap_base; > > > > + } > > > > + > > > > + pch_pic_reset(priv); > > > > + pch_pic_priv[nr_pch_pics++] = priv; > > > > + > > > > + register_syscore_ops(&pch_pic_syscore_ops); > > > > + > > > > + return priv->domain_handle; > > > > + > > > > +iounmap_base: > > > > + iounmap(priv->base); > > > > +free_priv: > > > > + kfree(priv); > > > > + > > > > + return NULL; > > > > +} > > > > + > > > > +#endif > > > > > > A lot of this code is common with its OF counterpart. How about making > > > this logic common? > > OK, let me think about. > Though pch_pic_acpi_init() is similar to pch_pic_of_init(), but it is > difficult to make a common function, because we cannot prepare > everything before the common function. For example, ioremap() can be > the common part, but pch_pic_acpi_init() should get the vector count > after ioremap(). If we use an argument to distinguish the caller in > the common function, the complexity increases and seems no benefits. All firmware implementations allocate private data structures, irq domains, map MMIO regions, etc. All that can be common. We even have APIs that deal with both firmware interfaces. As for the 'read the vector count from the HW', what does it have to do with driving the HW using DT or ACPI? The HW doesn't *know*. If you are conflating HW changes and firmware interfaces, then you have already lost. M. -- Without deviation from the norm, progress is not possible.