Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp871653rdb; Fri, 23 Feb 2024 02:46:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoeq599TvW0zqtXeRHZqBk8oI1WNP4VE73gzjU4cV1PGMu5mSiQxOij1/FuBgnLC4eIs1/KXDfHmpJqXDYRDRLnBYs6sRQExBX5QCipg== X-Google-Smtp-Source: AGHT+IH4Ffli7vrPiWm367ctPcutL91WPfScSc2aZiA/tuZJE7gqvhh2DuWL4agNrlN+8kzdnkqA X-Received: by 2002:aa7:c1d0:0:b0:565:211b:32ea with SMTP id d16-20020aa7c1d0000000b00565211b32eamr1449839edp.19.1708685175541; Fri, 23 Feb 2024 02:46:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708685175; cv=pass; d=google.com; s=arc-20160816; b=kM8rQCETZApF0io/teX2uqv5v4BP4b5jZCogZA3RZRxZ4dgBWq4aqvQqBm5Oc0XF04 TbrwwH5c09LHFoEDEYtWPRMBgjby58tcYWZ+W1w3cJfCZojw7GTlnVcUSXtWqB8iLjo7 fbM3iy5LA2s9WcGzDHWbQMJV2RE36ZIsLzDgStsWajYpO9Cb2N1ugUgdgzNnPkrZUt+t 9fRSycX6LVnh57bzwKz2wAJ/Aj6tvnMZwz7pDbVg+d6UWjMY3OENLoQs1VMi+rs9uTOf SzLBeHr9vsn3TxK0U0Ok8/luqznSe8JracZ/NCXWCzXn2gnt0J9s1sto6No+hX/Hp/4h 3cpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=pMA/M1Wst7tXkYIO5GIr1rjeX1F/9HHGrY1Lxy8EC3w=; fh=YXb94MNbzX/KXyyoL0GNZX5PeVE4PTqwG6ITPWfhPVk=; b=ytKfyDJqNQM7jiGIPUL0oCSQyOup+pp3h8Jv6szWr7KClGU8Zmxqe50+uSAYZKnEAG lnwmZ36L60PFrz/SQiBGgYpKm6MzF9HN9mw0uaFrL8UXFICUe92EbDU/KDVkIavOJqQX qyxqgsx4Yqj2Q2bSZ9NCwzd5VNvdA3DWdRj9MraowKSNp+oMnQneqvBj1eh3r2UY7K3n 8MRw0dZwnC+9dH8jjxRUZrn5oH8kNu862WsvxcZ4RQTB3CsSPB8hr+Gq2se37SBBSDEq 3O+sTEWXa+X8jSsgXJS09cRW60YP/P5kx7NuMAYP4SdGx0tMCs+lsxxEXkSEvwdorHoc pYlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nNXUAdlz; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-78170-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78170-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y11-20020a056402358b00b0056582779925si100822edc.97.2024.02.23.02.46.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 02:46:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78170-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nNXUAdlz; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-78170-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78170-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 231711F22CD2 for ; Fri, 23 Feb 2024 10:46:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86AA97A73A; Fri, 23 Feb 2024 10:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nNXUAdlz" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C82F5FB82; Fri, 23 Feb 2024 10:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708684904; cv=none; b=OpxC+MP6aKlSfrkIxNisIXXE0lH0anGf5Pxt0qgVFMyBzUnTfbCug85og/fgDAZgspT8z4gtLX57tS0K3WBnGNqfA+c8PM7uD+RfOYhOyNaczPIw8VufLTS0gGHDZSml+lRu3WKfR+rZwSRxH8fexDNBGQ3kpZLVfw5O+Rc4M1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708684904; c=relaxed/simple; bh=pMA/M1Wst7tXkYIO5GIr1rjeX1F/9HHGrY1Lxy8EC3w=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=OYDaltaPLpq5zNpd3+JNM4LNnEH5/teblyXxTT/37c21tPX01PGJW5r6k0dbE8xSoX2e0hGxdHSNwqKFyI+Q9fdy6Gf3hW5ktUZa9Heq32SLLZX/4+h/4s1hy1VkcHo+aDvT80NauSrgI8Qpzb+tX2qQlrDXaSfgaQys0l0BwZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nNXUAdlz; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a3d5e77cfbeso128235366b.0; Fri, 23 Feb 2024 02:41:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708684901; x=1709289701; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=pMA/M1Wst7tXkYIO5GIr1rjeX1F/9HHGrY1Lxy8EC3w=; b=nNXUAdlzppPpKfGM+9uUXwTErhlOIWOEuIIycM5iubmq6LkmexL98e41OsNy+L8qDe yrV0hi618880HngsiGM+Zg8HCnkGimOHdp/QZen5W71FFV3LvKYc7YBMbjhar/+eyZGY Ad3AECKIxoa9Hqrhh2knV8qRLDy9Q8OfkkhsxSdLkJDJhZsQ+vLljKhMzoNn6UKjYBsA NSKHgNsSnqu1dMls+GHOKI4lW3eHVA9Xi6MvAPcK9/rCbWnxWQ3+rEx51rj2sOvXXp7Y WGNBxtDVmhFmGOZKNgkDT1iuE5Mcleu6DqRhoZ7FYpgFdwGX5CKOx0gaSrYDkT1po3DB bkpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708684901; x=1709289701; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=pMA/M1Wst7tXkYIO5GIr1rjeX1F/9HHGrY1Lxy8EC3w=; b=Vda7QvdLes8BW4WLCprRLOHrrirXF7Y64xBXOWHNbGJOzbIuXqCToVOpbT2K5t6ua8 xhhANJ4Qnwq8okg3rZMNSaJTmScoToN0SRfbu0hEjaoWinDZVzzAGTs/UAvb+vkmXTEO 3MWIMHNca4cu2Y8d7z9XMC6xhFLuNUkPDUQ2uK7MruQ/zCqBF8aCHNhBjgaZiRA8Wi0N Wb5ckVjjTYNq4Ml7vUbtog6inCBl3OQF0iF6gloGgvSzPha6K6XHJyd+hJDX29iF9dAI tzD5OmOqV5FISQpOtdMpaabmNO/oWo8RzSye4WvE08WsJzCXPX/OOfnJMM7JvmsyM2RT GLaw== X-Forwarded-Encrypted: i=1; AJvYcCWTZyMP29Kzo4jXJqKUZDzq9EXd4yaWyb5yhhuiaJnTjp9boHC0beCS5iPZuLgqd74wM549jziqk/lWzHTJkGZJUgGCBfofNJKRqlEZOdXZmLOLo134gEN9k8bRh2zIC8AvBVHpbcJD/w== X-Gm-Message-State: AOJu0Yx8fwGP6tvSPi+tVDfcPfSZVFX5Qh3HeJQ4rwGLZXckCId8RRLR ZQgJbYHglmSBOe3McYvEILV0bxXJVswz9Nz5/eo5UXLQwW3nC9Zb X-Received: by 2002:a17:906:5c9:b0:a3f:4800:1fa8 with SMTP id t9-20020a17090605c900b00a3f48001fa8mr4270726ejt.26.1708684901141; Fri, 23 Feb 2024 02:41:41 -0800 (PST) Received: from ?IPv6:2003:f6:ef1b:2000:944c:cbc7:1e1c:2c47? (p200300f6ef1b2000944ccbc71e1c2c47.dip0.t-ipconnect.de. [2003:f6:ef1b:2000:944c:cbc7:1e1c:2c47]) by smtp.gmail.com with ESMTPSA id ty24-20020a170907c71800b00a3ee41cbe87sm3762669ejc.153.2024.02.23.02.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 02:41:40 -0800 (PST) Message-ID: Subject: Re: [PATCH 1/2] driver core: Introduce device_link_wait_removal() From: Nuno =?ISO-8859-1?Q?S=E1?= To: Herve Codina , Saravana Kannan Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Lizhi Hou , Max Zhen , Sonal Santan , Stefano Stabellini , Jonathan Cameron , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Android Kernel Team Date: Fri, 23 Feb 2024 11:45:02 +0100 In-Reply-To: <20240223101115.6bf7d570@bootlin.com> References: <20231130174126.688486-1-herve.codina@bootlin.com> <20231130174126.688486-2-herve.codina@bootlin.com> <20240223101115.6bf7d570@bootlin.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-02-23 at 10:11 +0100, Herve Codina wrote: > Hi Saravana, >=20 > On Tue, 20 Feb 2024 16:31:13 -0800 > Saravana Kannan wrote: >=20 > ... >=20 > > > +void device_link_wait_removal(void) > > > +{ > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * devlink removal jobs ar= e queued in the dedicated work queue. > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * To be sure that all rem= oval jobs are terminated, ensure that > > > any > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * scheduled work has run = to completion. > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 drain_workqueue(fw_devlink_wq);= =C2=A0=20 > >=20 > > Is there a reason this needs to be drain_workqueu() instead of > > flush_workqueue(). Drain is a stronger guarantee than we need in this > > case. All we are trying to make sure is that all the device link > > remove work queued so far have completed. >=20 > I used drain_workqueue() because drain_workqueue() allows for jobs alread= y > present in a workqueue to re-queue a job and drain_workqueue() will wait > also for this new job completion. >=20 > I think flush_workqueue() doesn't wait for this chain queueing. >=20 > In our case, my understanding was that device_link_release_fn() calls > put_device() for the consumer and the supplier. > If refcounts reaches zero, devlink_dev_release() can be called again > and re-queue a job. >=20 Looks sensible. The only doubt (that Saravana mays know better) is that I'm= not sure put_device() on a supplier or consumer can actually lead to devlink_dev_release(). AFAIU, a consumer or a supplier should not be a devi= ce from the devlink class. Hence, looking at device_release(), I'm not sure it= can happen unless for some odd reason someone is messing with devlinks in .remo= ve() or .type->remove(). - Nuno S=C3=A1