From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752827AbcGTHu0 (ORCPT ); Wed, 20 Jul 2016 03:50:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45653 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbcGTHuX (ORCPT ); Wed, 20 Jul 2016 03:50:23 -0400 Subject: Re: [PATCH v11 04/10] genirq/msi-doorbell: allow MSI doorbell (un)registration To: Thomas Gleixner References: <1468933367-23159-1-git-send-email-eric.auger@redhat.com> <1468933367-23159-5-git-send-email-eric.auger@redhat.com> Cc: eric.auger.pro@gmail.com, marc.zyngier@arm.com, christoffer.dall@linaro.org, andre.przywara@arm.com, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org, drjones@redhat.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, pbonzini@redhat.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, iommu@lists.linux-foundation.org, Jean-Philippe.Brucker@arm.com, yehuday@marvell.com, Manish.Jaggi@caviumnetworks.com, robert.richter@caviumnetworks.com From: Auger Eric Message-ID: Date: Wed, 20 Jul 2016 09:50:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 20 Jul 2016 07:50:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thomas, On 19/07/2016 16:22, Thomas Gleixner wrote: > On Tue, 19 Jul 2016, Eric Auger wrote: >> + >> +#include >> +#include >> +#include >> + >> +struct irqchip_doorbell { >> + struct irq_chip_msi_doorbell_info info; >> + struct list_head next; > > Again, please align the struct members. > >> +}; >> + >> +static LIST_HEAD(irqchip_doorbell_list); >> +static DEFINE_MUTEX(irqchip_doorbell_mutex); >> + >> +struct irq_chip_msi_doorbell_info * >> +msi_doorbell_register_global(phys_addr_t base, size_t size, >> + int prot, bool irq_remapping) >> +{ >> + struct irqchip_doorbell *db; >> + >> + db = kmalloc(sizeof(*db), GFP_KERNEL); >> + if (!db) >> + return ERR_PTR(-ENOMEM); >> + >> + db->info.doorbell_is_percpu = false; > > Please use kzalloc and get rid of zero initialization. If you add stuff to the > struct then initialization will be automatically 0. OK > >> +void msi_doorbell_unregister_global(struct irq_chip_msi_doorbell_info *dbinfo) >> +{ >> + struct irqchip_doorbell *db, *tmp; >> + >> + mutex_lock(&irqchip_doorbell_mutex); >> + list_for_each_entry_safe(db, tmp, &irqchip_doorbell_list, next) { > > Why do you need that iterator? > > db = container_of(dbinfo, struct ....., info); > > Hmm? definitively > >> + if (dbinfo == &db->info) { >> + list_del(&db->next); >> + kfree(db); > > Please move the kfree() outside of the lock region. It does not matter much > here, but we really should stop doing random crap in locked regions. OK Thanks Eric > > Thanks, > > tglx >