Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp836353ybb; Fri, 3 Apr 2020 12:47:00 -0700 (PDT) X-Google-Smtp-Source: APiQypJSgSrknIIrsez8lCrnssN86wRIpfilR9OqvgIT/7RH9MBu06j2xykJ/VhASiuLAMgYDx0L X-Received: by 2002:a4a:8241:: with SMTP id t1mr8004707oog.57.1585943220532; Fri, 03 Apr 2020 12:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585943220; cv=none; d=google.com; s=arc-20160816; b=IQyDQFv7csnXi60sxjTwsSyhtHE1sLJI8GGQ5GGej/2mHFWd9c2YjclUTOsPf5L3ZD e69F6hbpWeURsZYiCHnEFrsDwtujFbnZMiyU02vGzbaLXVXTO+t3n5C6CGljgfLewliZ oLYBbXtTFY5bAjRvle0R95sXZYq5rmfEx0k7DnkRiUTaMBaH6pOmC/HYd4UNINr2cGLi nFRY5+Z+e0aL2MCIoa2hXFvSKsQXM37OzjB8W+1zCBIw34ttuK4v+R1T34cgBjTTq9oO 4Ru5oNHa3sMDU+8MAajxdYCD46kDP7HVLVctY88eF5yF6IZDHJla68iLBEgY8Aukmi/i V8uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dL35/KDrO9kk5GYoU2spCW4xpugUQC8ErbDAX9x0Gu8=; b=xl4tZMlZa/Up2t8FNkvdERJlR1r5/YUbeAuCF5uzSy1lgcL0rYKweUU0PQO8FeS7t/ rYyWf/Vg4Fn8ow9vhSV0/u4IiJYTpCvbHwMZcwPN9LG5kI8VAgeP6i3Wg1PSOu1Dx8DF bX4QSOy8LUeQesCZw+jfdCfyCjwVg76DXuPlVeccl0bIk8hY1J90wEoo+R76XSpRtM/l 4byIIjSLflsez9FOuPByfdo3QBpE9yl/Ki5ElCOf6xOcTX30PgXpSJkfjEk+dRym1+cQ ycltmcFTEm1ZLwFo1rBErvma+XmFA4aaeZik1sNIpNkM9wJATKs4afp59ABY0MWMqO2o j72Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RFvhkqM3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id a23si4355257oos.67.2020.04.03.12.46.47; Fri, 03 Apr 2020 12:47:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RFvhkqM3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728203AbgDCTo3 (ORCPT + 99 others); Fri, 3 Apr 2020 15:44:29 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35597 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727930AbgDCTo3 (ORCPT ); Fri, 3 Apr 2020 15:44:29 -0400 Received: by mail-wr1-f66.google.com with SMTP id g3so7608103wrx.2; Fri, 03 Apr 2020 12:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dL35/KDrO9kk5GYoU2spCW4xpugUQC8ErbDAX9x0Gu8=; b=RFvhkqM38AZ3tO6/eGOW8EMuB+S366v2bxcxzLwsQYxD7wEd8Ms4deyxkM2EBHnDHu JwVbeSiTaiq1NY9DY8pPNfCJkP1ovZ4hGxPMVYuSWh2fnstb45fzjJtv3wFfbGDZRIdP bgQ9ctj+/5iTU/uyyPIlzpvOOb/jmsaUracBI5gQgTpQbkhjsZAJFufcVSG9fWs1TERr Tr/aORQOoiWvisaFOXrym7FdY8SwT0zsEH2q47IrUA5HWiHDgTSt3HsHxZUAnD0f21kH nT4oZJBR7izhY8SGuofAneMYBs0ziBefPPss2Z+GoLgrsVYBUYyCHeZOqXGOloVprwKQ nrXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dL35/KDrO9kk5GYoU2spCW4xpugUQC8ErbDAX9x0Gu8=; b=oViFHfLTpDSgnro09+wAePwsIm3sMiflPztB7BhnyPQPwyTgvOAzHDWK4jV9r3gk59 BK1tRD1toTQG++D48dd/nAH1J1affhBF9AYD6O3Psnl/B/xPe0y/wdTFbURPB5+JJXha sT4DNorBetX9sppQubOQvtVW5f7eggxphz+n5cHWK1vX3zoRxmBSk44T5iQAo8BZFNjf 30SmJd7Vh7/ZHlsXED66uo8LfTAn4IBSQ+ujx/XSx//1GL6w1Kqxlo6dIPl9LQiqLY6G OYw+tUKH29pidy3v5N8Lp9uiG0PqwIkexfcX4U/MNe4Im+8YIUBbtCjiEQ3C3gVqk1R3 EDjQ== X-Gm-Message-State: AGi0PuYBJtkeFL6pd+BPpE2/RhI326bp8hwxTu9I/Z1MFCd28Prt8IbQ aroeadGSRfvzwrV/xt2C/QFR7l3P X-Received: by 2002:a5d:500d:: with SMTP id e13mr1566557wrt.362.1585943067756; Fri, 03 Apr 2020 12:44:27 -0700 (PDT) Received: from localhost (pD9E51CDC.dip0.t-ipconnect.de. [217.229.28.220]) by smtp.gmail.com with ESMTPSA id m11sm12835978wmf.9.2020.04.03.12.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 12:44:26 -0700 (PDT) Date: Fri, 3 Apr 2020 21:44:25 +0200 From: Thierry Reding To: Clemens Gruber Cc: linux-pwm@vger.kernel.org, Andy Shevchenko , Matthias Schiffer , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org, Sven Van Asbroeck , YueHaibing , Mika Westerberg Subject: Re: [PATCH v2 REBASED] pwm: pca9685: fix pwm/gpio inter-operation Message-ID: <20200403194425.GC201060@ulmo> References: <20200401170106.134037-1-clemens.gruber@pqgruber.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lCAWRPmW1mITcIfM" Content-Disposition: inline In-Reply-To: <20200401170106.134037-1-clemens.gruber@pqgruber.com> User-Agent: Mutt/1.13.1 (2019-12-14) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --lCAWRPmW1mITcIfM Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 01, 2020 at 07:01:06PM +0200, Clemens Gruber wrote: > From: Sven Van Asbroeck >=20 > This driver allows pwms to be requested as gpios via gpiolib. > Obviously, it should not be allowed to request a gpio when its > corresponding pwm is already requested (and vice versa). > So it requires some exclusion code. >=20 > Given that the pwm and gpio cores are not synchronized with > respect to each other, this exclusion code will also require > proper synchronization. >=20 > Such a mechanism was in place, but was inadvertently removed > by Uwe's clean-up patch. >=20 > Upon revisiting the synchronization mechanism, we found that > theoretically, it could allow two threads to successfully > request conflicting pwms / gpios. >=20 > Replace with a bitmap which tracks pwm in-use, plus a mutex. > As long as pwm and gpio's respective request/free functions > modify the in-use bitmap while holding the mutex, proper > synchronization will be guaranteed. >=20 > Reported-by: YueHaibing > Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()") > Cc: Mika Westerberg > Cc: Uwe Kleine-K=C3=B6nig > Cc: YueHaibing > Link: https://lkml.org/lkml/2019/5/31/963 > Signed-off-by: Sven Van Asbroeck > Reviewed-by: Mika Westerberg > Tested-by: Clemens Gruber > [cg: Tested on an i.MX6Q board with two NXP PCA9685 chips] >=20 > --- > drivers/pwm/pwm-pca9685.c | 85 ++++++++++++++++++++++----------------- > 1 file changed, 48 insertions(+), 37 deletions(-) Applied, thanks. Thierry --lCAWRPmW1mITcIfM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl6HkhkACgkQ3SOs138+ s6EpLw/7B2wgmKpQYAy0SEAUiVfRJqbh5qpUT26I6qKNgXMtkhPjhtinfPd7MCta YYmIWZxEPUZ2iO1pmWKItkQpCsyomanvTLZX7g/4+8zd8I6bVgREdtckx+8gAQ6W L2IBR0QcPOyRVJYJB09IcCoX0A5EfWp3qL3s8dm66nTnk+WwsrTma6IpaMUkHS3y ezvztdPJ6l6q6M/ZgiXrRj/+oSrzvj/x0Fa3jqT13i0+DWUldk4SuY2Bt0GmFByu FaSKeonlma4tCIkczxge2Zg3niVYN5VylsnZoIV2K6l3x3YM4w4nX5Wu6kVDz+bd caNzwGhJyrlrlWt7vGPph+MAP/wzY+anaO8v5HnN3a0QDq4P39swCgffGQsLGdeE 7f5ivDPUHwhzWoIyNAdWMBekPA2Y0QaFAaC2/WBd3Eoh70YOfgLS4VQRchljE49e eLt4kZq0jkEdPXtrNTZ4oeF4uY9u2vGkR802+AJ2QCC7PqWQfJTVg7cX28pP5fj0 sPVdNXbxilZ+9lNZq4OAO2BoYFBR/rSIc36xxri/+jIAqA8X044NJqlPcR0T54nV SFNpRx4EVTGxTi14Cq/zVPuai7OxM/nug5lFx63qYvGp2+a7M3D+lZJ6WSimuoK/ KpRAsgNGeHZCeGllgIh548dbc8VRT2XPrIqGRJBcHzO2rwWt9bY= =miJb -----END PGP SIGNATURE----- --lCAWRPmW1mITcIfM--