From patchwork Tue Feb 20 11:10:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 20652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp325002dyc; Tue, 20 Feb 2024 03:11:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUHgtVmCZUcZD9VkQT0lVQhdUVhbnPka0QAkafC8iAGN0HiuqzB+fvSrvD/r+lBv6dr67bVhn5MyOBWjasEwlxikRpTQw== X-Google-Smtp-Source: AGHT+IF0SoXmXW10fS20EPXoIffeTvn18QIrFP86OetWq0ID3KLOiqeAqBQMLEN0kEFnNwwtT6wh X-Received: by 2002:ae9:f202:0:b0:787:7ec4:ead with SMTP id m2-20020ae9f202000000b007877ec40eadmr279335qkg.39.1708427503447; Tue, 20 Feb 2024 03:11:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708427503; cv=pass; d=google.com; s=arc-20160816; b=O1JrjNOTbesvM0r673R/NxpKYQ6J2bAoN+8jl92HnkWR80aFCh8AAjWUb1OPuVfXN4 CApIclx1RwLZwaAGAPMidKqn6X+V7auBwoFWcshQ9NbtflBN+5SqzgLaR2wpHY7aa6W6 5NXUiPlNIXbU1a1aBaOI+c0bv4GKgGrOZLxrBeI+1M76q8bdpPGJ6qCxkmdFI2ahrRQJ KLPzTkAizSzz+BBoJqEPaUtSPyj7wLjXPFKhG20iT69Np9i6+1+2/NnBdeUSabBIkRZp FEYsbEDUzWEDBdbxKUL9BUjfiyv9tVN76VthKM2hQ6meFQP2HNMab4ECVEIGZPElxvNd Kk7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=mB1ESwZoS4AZNAYIIMVqsrJVUx3SAqDDr22iiRILhVc=; fh=bQDfEZGNvUJOgi5NqmHXoHCcxSTUxiah6hyMMNL5D+k=; b=G2M50ZZP6iaFv6q3YEzdbeQw/CGJXUPz/HBbif0GogTJWdmex/b0inozee+XbiTzom mw6goXItLYWDMZjkyiWxmn/PaM9TvCWX4wL5Kb031k8szT5ZOL1pVOplfgFpo9nextEw e3dQhfNIoepprFBaMh7A431NYX4j/CA5epD5GTDB+UWpwOrZbH4zB0lhnvWNPo+3fJQ2 beq3LCcCzZ0CiHWuOGW93vyCmFY5EUkNMw1kgCIUdIDngn9wvfmmlmMoTKFh2mlfMmvB KHy3lSM9ssPgVD9ItiamvReAMusK7Uax4eeN/R0niRxK2XTA1JykutNLZcGf2FN/XbNA zd6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=RhL46L08; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-72875-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72875-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b17-20020a05620a119100b007877aff36e8si602764qkk.468.2024.02.20.03.11.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 03:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72875-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=RhL46L08; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-72875-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72875-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BF05B1C24140 for ; Tue, 20 Feb 2024 11:10:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 169BC664D8; Tue, 20 Feb 2024 11:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RhL46L08" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 9222E60EFB; Tue, 20 Feb 2024 11:10:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708427437; cv=none; b=hb7+qOJzBpyZZWZLhq29kmKK2TuxZUdu83Unq8z0w7gnkHPCTe3oRoYfrVs/AD6YXouIac2+rtSIMkzh77CbEp5vakDwXFRuRvdBVxVk+5UKE2gyOabUg1i/yE6RDxWMr3cwJIXDpogCXduIcZVHdf2DQ1XdseNz/JNJcSDr500= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708427437; c=relaxed/simple; bh=4r5xHuvDtpeJSD5sE4rlBgiTdD5DY6axVimQFHMktKM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=QKuWUobNQ9Il9Y/6nZOwpgWOsCbyGKqVDm2/peJxyfnxH5OcWUcWKTRdVlfgGD9TlOyjeE+t6IJz+Id063NHkVcuU6odbjqmGoQIogkt9jS98d35SYnbLsaxlqrj0n0zgL/bJ3KpNrVpVp31q7aMfB5kBVBzLzLgi6PfNhL99Wo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=RhL46L08; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id E25031BF208; Tue, 20 Feb 2024 11:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708427427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mB1ESwZoS4AZNAYIIMVqsrJVUx3SAqDDr22iiRILhVc=; b=RhL46L084E3pqCNOdgocRMlArxKfoWC4Port0mGLe1Yc18cSw/vWW4XR2O4kXGcUXJlMtL abBo/XTi7RIhMUwlo4WIA1kCj/b7+XH7cXGd//i0Xv4UZtLONb71qpf+Kbb7OPO+Z/rikz hpu+K+rVJ50dNTBVl0NUfjYp145Om8qbxE7LKcE8YaTI+x8BLiXVwwlKLatliG9myUMjs/ hbd7GY6XkL97yOEGlodaiSevZHbylEfVcr/vXPg1mB04KmITwMCq2pws83fpe8gP1/I6Gl d9Wuyye6lseaDJiU8OFUUCYUJazFngdh2WbtNJtr3cRXCKzFhkexJWGfueW6Fg== From: Herve Codina To: Bartosz Golaszewski , Kent Gibson , Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni , Herve Codina Subject: [PATCH 0/2] gpio-cdev: Release IRQ used by gpio-cdev on gpio chip removal Date: Tue, 20 Feb 2024 12:10:16 +0100 Message-ID: <20240220111019.133697-1-herve.codina@bootlin.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791416077755210353 X-GMAIL-MSGID: 1791416077755210353 Hi, When a gpio chip device is removed while some related gpio are used by the user-space (gpiomon for instance), the following warning can appear: remove_proc_entry: removing non-empty directory 'irq/233', leaking at least 'gpiomon' WARNING: CPU: 2 PID: 72 at fs/proc/generic.c:717 remove_proc_entry+0x190/0x19c ... Call trace: remove_proc_entry+0x190/0x19c unregister_irq_proc+0xd0/0x104 free_desc+0x4c/0xc4 irq_free_descs+0x6c/0x90 irq_dispose_mapping+0x104/0x14c gpiochip_irqchip_remove+0xcc/0x1a4 gpiochip_remove+0x48/0x100 ... Indeed, even if the gpio removal is notified to the gpio-cdev, the IRQ used is not released when it should be. This series calls the gpio removal notifier sooner in the removal process in order to give a chance to a notifier function to release the IRQ before releasing the IRQ mapping and adds the needed operations to release the IRQ in the gpio cdev notifier function. Best regards, Hervé Codina Herve Codina (2): gpiolib: call gcdev_unregister() sooner in the removal operations gpiolib: cdev: release IRQs when the gpio chip device is removed drivers/gpio/gpiolib-cdev.c | 33 ++++++++++++++++++++++----------- drivers/gpio/gpiolib.c | 8 +++++++- 2 files changed, 29 insertions(+), 12 deletions(-)