Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp713234pxf; Wed, 10 Mar 2021 16:08:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwupVyXA8BkwkmopLQSqr7XgGhRQBO07WJdyqZ7kN45arUb6HnR0NVxBxG2KCTv7/SUfvxv X-Received: by 2002:aa7:df84:: with SMTP id b4mr5867707edy.240.1615421298250; Wed, 10 Mar 2021 16:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615421298; cv=none; d=google.com; s=arc-20160816; b=lFEP5jlbXIHLFNiBV4e/26Hiv7EWCBGrMlpb2Z7Ag3CkpM/5UNlrKFWF2gCjkACu9q 0UqYue6GrPcrpCC5hmsGE9Ja5pptjoNr75CV6ynCvQibzponSnKEJKy969YksLMhPLEA kqGg8S/oWNtNDCmoAoLi5d/A4cp/eBpr1qlRYqHgGEx1/6dQnK8uExv2phPwFH6mFH4v gyw2SnjYRXDFENFZf6z+m8yyXV7orChj5KAmpmhU7SkWrJY4f7iCa+F7Wb28AtFLQW/j pDWTpIGT1ToUy3ljL+djS7Ml+c8TeoumUSM+nr4R9CYUSn4ZllbIUvCYP8PLTVlDk/Zw erNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nMdEvDV9VCn8ULwq7zFI9sfQzb6LiHHIvyDrW2yOdOQ=; b=qvJSJadcEBuQtoKnSRENID8uzOT0BGr+FR47+liKV6iWBu73yK0BbzGu8ruqDvwntH Utz6SCKc1xRTK2eR2jVUVoUP8Zq9XROBMVWG/ZVJlq0oF3uq497xGOkVwYbbTWctZUXG x7tttyd5Ru5gKAiy855dlsN0TIVKYbymuGFUM73pTjtnLmE87AWN1ycv9u0DYYkmy1W+ RXYa1h2QhPIFlijuR8k3tppULTK52gRVZGJlms3U1GebVxA6IZw+LPqBavkgBbzPRZ8+ WWs8hrGHBEVeiL16/5fVeN3ySJeCMvT8BLsFnaT0MlKNNwEiHTFYzK9Mu5AmGhtmPZd2 msTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pHbUatCv; 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 v2si515410ejw.670.2021.03.10.16.07.26; Wed, 10 Mar 2021 16:08:18 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pHbUatCv; 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 S229796AbhCKAGa (ORCPT + 99 others); Wed, 10 Mar 2021 19:06:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:45570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbhCKAF6 (ORCPT ); Wed, 10 Mar 2021 19:05:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2EC3064E33; Thu, 11 Mar 2021 00:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615421158; bh=iFxVJgMoDpJ44jsE4Fuo7YkLXTeRvt9qHwXirR8S6SQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pHbUatCvju/H17C/5K/sXqE3GC74q+fVaVWePgzCGPEelm8i6fAHWz7kps59DplLz rl8g4mlo7ESlnxn/xVc/ow7B1sTyAa92MPRjY/MNPbjODF0ndY5jAMoWs9UhvruzzF pbRgOgVPXwajI2R6qhkbtG469UMo5Vt3Conr7vGybjMfgOyMsHqGydidarB/nUqtte x4bln9KOuq+PyFRDgZ1vH3TCOzJ92D9mEtph5qIxTfFsaDe9ZqyixECTwwRCaB0ise 0Vc2O5Xib/wPG/mDsEVfXTteHQGUWLD2sx6M0MVavI3kUxpsoSFPiecKAXA5hEMwgY qOpr7+u2Ha48Q== Received: by pali.im (Postfix) id 00BD9A83; Thu, 11 Mar 2021 01:05:55 +0100 (CET) Date: Thu, 11 Mar 2021 01:05:55 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Marc Zyngier , Jianjun Wang Cc: Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi , Ryder Lee , Philipp Zabel , Matthias Brugger , linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sj Huang , youlin.pei@mediatek.com, chuanjia.liu@mediatek.com, qizhong.cheng@mediatek.com, sin_jieyang@mediatek.com, drinkcat@chromium.org, Rex-BC.Chen@mediatek.com, anson.chuang@mediatek.com Subject: Re: [v8,5/7] PCI: mediatek-gen3: Add MSI support Message-ID: <20210311000555.epypouwxdbql2aqx@pali> References: <20210224061132.26526-1-jianjun.wang@mediatek.com> <20210224061132.26526-6-jianjun.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210224061132.26526-6-jianjun.wang@mediatek.com> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 24 February 2021 14:11:30 Jianjun Wang wrote: > +static int mtk_msi_bottom_domain_alloc(struct irq_domain *domain, > + unsigned int virq, unsigned int nr_irqs, > + void *arg) > +{ > + struct mtk_pcie_port *port = domain->host_data; > + struct mtk_msi_set *msi_set; > + int i, hwirq, set_idx; > + > + mutex_lock(&port->lock); > + > + hwirq = bitmap_find_free_region(port->msi_irq_in_use, PCIE_MSI_IRQS_NUM, > + order_base_2(nr_irqs)); > + > + mutex_unlock(&port->lock); > + > + if (hwirq < 0) > + return -ENOSPC; > + > + set_idx = hwirq / PCIE_MSI_IRQS_PER_SET; > + msi_set = &port->msi_sets[set_idx]; > + > + for (i = 0; i < nr_irqs; i++) > + irq_domain_set_info(domain, virq + i, hwirq + i, > + &mtk_msi_bottom_irq_chip, msi_set, > + handle_edge_irq, NULL, NULL); > + > + return 0; > +} > + > +static void mtk_msi_bottom_domain_free(struct irq_domain *domain, > + unsigned int virq, unsigned int nr_irqs) > +{ > + struct mtk_pcie_port *port = domain->host_data; > + struct irq_data *data = irq_domain_get_irq_data(domain, virq); > + > + mutex_lock(&port->lock); > + > + bitmap_clear(port->msi_irq_in_use, data->hwirq, nr_irqs); Marc, should not be there bitmap_release_region() with order_base_2()? bitmap_release_region(port->msi_irq_in_use, data->hwirq, order_base_2(nr_irqs)); Because mtk_msi_bottom_domain_alloc() is allocating order_base_2(nr_irqs) interrupts, not only nr_irqs. > + > + mutex_unlock(&port->lock); > + > + irq_domain_free_irqs_common(domain, virq, nr_irqs); > +}