Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1880718pxb; Tue, 26 Oct 2021 18:33:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8hYd+qfuod/VzuhmsT3dDqHhvgqL4MBlIorYs65VvgcPGvm/xc2DBWD1gSDUkJMLJgEm2 X-Received: by 2002:a17:90b:4f87:: with SMTP id qe7mr2511540pjb.29.1635298413865; Tue, 26 Oct 2021 18:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635298413; cv=none; d=google.com; s=arc-20160816; b=WsTAtWKXWnK/DTPoS4GkEVpsu5JVa0Tk18vDWQlfEoF7RQrmJ23qkPTtQWxCm3OA1g HS0ekeWJmUqlv/Ni3/qMV/L4UUSsohymnW7+KXRJIC0Uwl5mj1sYwPU9C6TYmSTI2YCW AhS4QK+2os9n7OlJXOvRNoOYbtUrheNrJyDP+dF8Vbl/cVnI68+91ZlYXmiKf/Fsg7H+ zKnQ2Q38pMutAfRuPm8BuVyz3r6WQs13ghzbUKUUFX7fK9yGul2r9HDoaJw64bDo4hqh Vsz/nx3l1l95Hn0vbk/AGWQDDkK+gs2dA+konHN+R3EL/OpFYRpdH+fZGe9Ry8m6a8J3 YptQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WgPoDLreotacKgSCxjssM8YVC++au175VVy5gQ/BSV8=; b=gtCTXYAxYnQF5CwPOg0LqrJI6SU/IzH5CZ8HEmhk0Hw5fc+E2HMkrXG9AfcQSihtoc NIyFIJnnzPZw+eTQn9K80m9Egvx37OMmqNxYrZfG4cYyZeYpaedO3ZA5A2RAp2nV9uFU vUwo5bk/Ow/F43zq5Nt4BeoxHroiQYZBrwDg7vRcDAn+WkP95GDuXzNTbe2oF66XUv32 I2GOxBUTnee7YneXkdeNiCyAbnWJts1VIc4v7+kOTLxopWx5+9XRxMhFzw3DaXno5TXm PTjxwu8SVYv+XWfnClRmYWNV9m4Q2sGD7vVHkRzFGgqkOSP2igltRZeSEbT4Vt3ydVnq MevA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LQH2g30T; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e124si3820973pgc.318.2021.10.26.18.33.08; Tue, 26 Oct 2021 18:33:33 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=LQH2g30T; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237608AbhJZQ7R (ORCPT + 99 others); Tue, 26 Oct 2021 12:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236295AbhJZQ7R (ORCPT ); Tue, 26 Oct 2021 12:59:17 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E863C061745; Tue, 26 Oct 2021 09:56:53 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id c4so56095pgv.11; Tue, 26 Oct 2021 09:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=WgPoDLreotacKgSCxjssM8YVC++au175VVy5gQ/BSV8=; b=LQH2g30TyCkDqZpUSJtZ8Sb1hNOa0JFac2VOJkn5gw1JSXdNp9a6j1j4L9M7SAxT8m i/d7d2lE94vcPT3SJpaonNL+zbfAc3KzKEnbi5H/KvZWAAXKbc3201McS7YRbHigyhX0 3Urf7fzqeIQNUb3mMDVy8ZR5WJ/LhTJe75DyNQ6QTCB+lilYbO3gYyvfPinkofj8LyXs 98xORT4V3222+b/iW5FvuqZmJbC/fZtZSDO50KZ3rAOveID2Y0KJtBoMOnVVsmhNi/Xg SEET9SDM4dUtDqwvUP+Pynna5u7hifU3iv/eEqA72AaQqjtd2pa7/9fwvUIrhS3VPLiD MWkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WgPoDLreotacKgSCxjssM8YVC++au175VVy5gQ/BSV8=; b=44wRY4iku6K3VzPD2JHbrPyhDHYx3+dOcfNo73Bif9i0Pzktgj09uuU6nSoMVxrrJr j3F0JK9T5t59hUpRrNunoLrQSxb/RhbJauLlXMsXs3GXdHW+WG5NUIUgsc1YPiutMZ5k 9jWpxSXjnweIC9l/FzK9JPPEbpwh1yjotjwdRHxjkQXaW7lsY4agO7d+9HcrRw2HoPr1 SM7dj5jl5MfSNg5PZBYPKophoVKx25O1Sixkw5Oni+B/buGnPF3OEUwgwsNhGJI4mh4P ZQncUyoD254gKujRT9X8XLT4DXzV9VKtxKDnaUA9cBwwa7SMvfA0buKoeBBh8X8vo1UJ 1bfQ== X-Gm-Message-State: AOAM533pd7b7D6zgg4ck843gwnQW+kH75DjE+9mbtz8knv1YZlDhG6lj VLeW7H0YkcTELXLxJnAEwRvA/GIy8qvm0IjHZtY= X-Received: by 2002:aa7:8b1a:0:b0:44d:37c7:dbb6 with SMTP id f26-20020aa78b1a000000b0044d37c7dbb6mr27340407pfd.11.1635267412857; Tue, 26 Oct 2021 09:56:52 -0700 (PDT) MIME-Version: 1.0 References: <20210922125939.427-1-caihuoqing@baidu.com> <20211015025815.GA3874@LAPTOP-UKSR4ENP.internal.baidu.com> In-Reply-To: From: Jason Gerecke Date: Tue, 26 Oct 2021 09:56:41 -0700 Message-ID: Subject: Re: [PATCH] HID: wacom: Make use of the helper function devm_add_action_or_reset() To: Jiri Kosina , Dmitry Torokhov Cc: Ping Cheng , Benjamin Tissoires , Benjamin Tissoires , Linux Input , LKML , Aaron Skomra , "Dickens, Joshua" , Cai Huoqing Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 19, 2021 at 8:36 AM Jason Gerecke wrote: > > On Sun, Oct 17, 2021 at 9:53 PM Dmitry Torokhov wrote: >> >> I think this is OK, but I would prefer if assignments that alter the >> >> shared data (i.e. assignment to wacom_wac->shared->pen, etc) would >> continue stay under mutex protection, so they need to be pulled up. > > > > On Mon, Oct 18, 2021 at 8:26 AM Jiri Kosina wrote: >> >> I don't see any issue with that ordering, but I'd also prefer for clarit= y >> to keep updating the shared data structure under the mutex protection. >> > > The data behind the "shared" struct (e.g. wacom_wac->shared->pen) is not = currently under any mutex protection. I don't think mutex protection is nec= essary, but we can take a look... I believe all of its members are either f= lags (so already atomic) or initialized during probe and then just used as = a handle with appropriate NULL checks (but maybe two threads could be simul= taneously issuing events to the same device?). > > If a patch to add mutex protection to the shared struct is necessary, tha= t's going to be a seperate patch that touches a lot more of the driver. Following up on this. I took a second look at the shared struct, and believe that things should work fine during initialization and steady-state. There are, however, opportunities for e.g. one device/thread to be removed and set e.g. `shared->touch =3D NULL` while a second device/thread is attempting to send an event out of that device. This is going to be very rare and only on disconnect, which is probably why we've never received reports of real-world issues. This shared issue is present with or without the changes by Cai and myself. I would ask that these two patches be merged while we look at introducing a new mutex to protect the contents of the shared pointer. Jason --- Now instead of four in the eights place / you=E2=80=99ve got three, =E2=80=98Cause you added one / (That is to say, eight) to the two, / But you can=E2=80=99t take seven from three, / So you look at the sixty-fours....