From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 273A73D9049 for ; Mon, 20 Jul 2026 09:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784540059; cv=none; b=ryqRMazfnwrMZMsHZH23XKS/1A41Hx00Zb2jdRsYaxZL28H0k3S3ajScgGMTrA0FleU94VPSZtcN9HTTaFhsTie660Z9KcfpH35ZF0lxtewnyf5i0i261K4rtf8Mofa/xdRNr41xUu3kFJ6E5qjVrlMvNghlOM217IZl0032lt0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784540059; c=relaxed/simple; bh=ZK1ic4vCm2/9iGRAdrWkXp+e+SOL57GW4JVsEGX1lyA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=CXJnv2ykQKeG6236mgmyPjDHG9Kc6iGc+rBvIN6v6dp26Ql0BYcNMlixRLETSXQXNCfcsTvEjxUNzqZN2FhBECvNEC2OUKtcFVoyro2LLWfn3JIuTktPUOKSRwDbZnmgBqepGcaELDpvlh+CYbb61OMKePH7oaLjpKtXu2tjxcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NsonceMu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NsonceMu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 002CD1F00A3A; Mon, 20 Jul 2026 09:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784540057; bh=g+sFTmwFYPV7NkiS8z1lAkDhr6tLYLslKZ2/ipwDeMU=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=NsonceMuIGImMEQattjAP3xJAU/YB9j0g7FX6aQXVwpNYTZ2TBbFXt78enneSaTqQ 9BkBHdai809yR0yhwEZItXWi6nEvKuB+4uPjLYVXm0cbMLsw67eg/KXn+Nl4Bj2mhN 4YWuyJbEmRa7kPkY7qpb/m8icT2/KNLFvitGOaW5q/YuDAhEK9oaKSjMq/s5/7Y8MJ gO+UUbUWyfVv/UkvyxCJq36IPSKnzsF2jJFIPNtrdmO+Jmaf1DzTINV9qmatoRPdPv UYZSjYwOYWyiFduPXDqriF+l4C+EbilXAUN74JXvERVVFTk4vbGUQQUghYS56rbDTu atq8XKmN6Yxew== From: Thomas Gleixner To: Alexander Wilhelm Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC 1/2] irqchip/ls-scfg-msi: refactor allocation to bitmap_find_free_region() In-Reply-To: <20260716-irqchip-ls-scfg-msi-add-multi-msi-support-v1-1-9795356d0ebc@westermo.com> References: <20260716-irqchip-ls-scfg-msi-add-multi-msi-support-v1-0-9795356d0ebc@westermo.com> <20260716-irqchip-ls-scfg-msi-add-multi-msi-support-v1-1-9795356d0ebc@westermo.com> Date: Mon, 20 Jul 2026 11:34:14 +0200 Message-ID: <87ik6angx5.ffs@fw13> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Thu, Jul 16 2026 at 12:15, Alexander Wilhelm wrote: > Replace the manual find_first_zero_bit()/__set_bit() pair with > bitmap_find_free_region(), and __clear_bit() with bitmap_release_region(). Please don't enumerate WHAT the patch is doing. Explain context, problem and solution in that order: https://docs.kernel.org/process/maintainer-tip.html#changelog > @@ -141,28 +141,32 @@ static int ls_scfg_msi_domain_irq_alloc(struct irq_domain *domain, > { > msi_alloc_info_t *info = args; > struct ls_scfg_msi *msi_data = domain->host_data; > - int pos, err = 0; > + int order = get_count_order(nr_irqs); > + int pos, err; > + unsigned int i; See the variable declaration chapter in the documentation above. > WARN_ON(nr_irqs != 1); > > spin_lock(&msi_data->lock); > - pos = find_first_zero_bit(msi_data->used, msi_data->irqs_num); > - if (pos < msi_data->irqs_num) > - __set_bit(pos, msi_data->used); > - else > - err = -ENOSPC; > + pos = bitmap_find_free_region(msi_data->used, msi_data->irqs_num, > + order); > spin_unlock(&msi_data->lock); Please convert this to scoped_guard(spinlock, &msi_data->lock) pos = bitmap_find_free_region(msi_data->used, msi_data->irqs_num, order); No line break required. You have 100 characters. > - if (err) > - return err; > + if (pos < 0) > + return pos; > > err = iommu_dma_prepare_msi(info->desc, msi_data->msiir_addr); > - if (err) > + if (err) { > + spin_lock(&msi_data->lock); > + bitmap_release_region(msi_data->used, pos, order); > + spin_unlock(&msi_data->lock); scoped_guard() please > return err; > + } > > - irq_domain_set_info(domain, virq, pos, > - &ls_scfg_msi_parent_chip, msi_data, > - handle_simple_irq, NULL, NULL); > + for (i = 0; i < nr_irqs; i++) > + irq_domain_set_info(domain, virq + i, pos + i, > + &ls_scfg_msi_parent_chip, msi_data, > + handle_simple_irq, NULL, NULL); > Lacks brackets. See bracket rules in documentation. > return 0; > } > @@ -172,16 +176,18 @@ static void ls_scfg_msi_domain_irq_free(struct irq_domain *domain, > { > struct irq_data *d = irq_domain_get_irq_data(domain, virq); > struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(d); > + int order = get_count_order(nr_irqs); > int pos; > > pos = d->hwirq; > - if (pos < 0 || pos >= msi_data->irqs_num) { > - pr_err("failed to teardown msi. Invalid hwirq %d\n", pos); > + if (pos < 0 || pos + nr_irqs > msi_data->irqs_num) { > + pr_err("failed to teardown msi. Invalid hwirq %d nr %u\n", > + pos, nr_irqs); No line break required. > return; > } > > spin_lock(&msi_data->lock); > - __clear_bit(pos, msi_data->used); > + bitmap_release_region(msi_data->used, pos, order); > spin_unlock(&msi_data->lock); > } Thanks, tglx