From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163147AbdEXJH1 (ORCPT ); Wed, 24 May 2017 05:07:27 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:62634 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030506AbdEXJHV (ORCPT ); Wed, 24 May 2017 05:07:21 -0400 Subject: Re: [PATCH v6 net-next 17/17] net: qualcomm: add QCA7000 UART driver To: Lino Sanfilippo , Rob Herring , Mark Rutland , "David S. Miller" References: <1495545173-22150-1-git-send-email-stefan.wahren@i2se.com> <1495545173-22150-18-git-send-email-stefan.wahren@i2se.com> <053235ad-a963-6a09-ccb0-b643115dee00@gmx.de> <1059621060.236992.1495568289051@email.1und1.de> <41c7302e-b25c-9f57-470a-dd95200a060f@gmx.de> Cc: linux-serial@vger.kernel.org, Jiri Slaby , Greg Kroah-Hartman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski , devicetree@vger.kernel.org From: Stefan Wahren Message-ID: <50e5a442-777f-1516-4e94-16db7fa28f8b@i2se.com> Date: Wed, 24 May 2017 11:06:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <41c7302e-b25c-9f57-470a-dd95200a060f@gmx.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:L12szVF/yeC18hZuO9zrYN1UvvZ4WxO928wgmabTuIv9Ii1U6SV e6nwSl7WLTEnl8GS2gOdGRUnZP90FL4q5xBrUeTk62OYp1+w+o58uQ6RiPxIyy2GIOJIBIS rvjOp3kWWzkzPvLRakYnfcKtAvXyw23LKn1yrmdEBiWg1SmZZDm+k6SSNklDXre0FxClYTo egYZoat9ErtdekLNDFxjw== X-UI-Out-Filterresults: notjunk:1;V01:K0:FTux0AsX6k8=:mvJx0mwMRasXvIhVIOYiPK Wq4QGgnUP7CvNBsq8JVBe0gK8FyhEF+inDlEFkp6C97fq/NMhGhnkIai4vkfIiZYbU1x7pypT v41PefyND75fPBhMurXsBYcw+SoDKDErntM5ZT6eKzRhWkEnUEdtswZ+M2G0/yJ5D3DqACGxq AGrdQ19zquIKNLh79o+yIRMPB4+C/VWfXtEzbrmdGm8RTAD9tFg8ofpClvxh4AiEOGCaGUdZ8 iT7cz6PznSL8gxFeQsa4bml+sonnkYP+mwNo7LQ3bhAcOQyvZn58NrXV0V7tDtyIZf2dzOBPh 7HAZfMIxdtNNi2gyulfrIdRyfW5cWhQ3CBz+jdKhNTcpmRTc3IJQ7RCtoTryRQWvCB1m/AA4R zSwb7EF9CwfOPJDgBFYZn4Idcrjhk+WEkMXjItfAmxV006PW2hZmVB4lL+62iswKEYTKbd7ei xD1/dVjEDZvR4vWaPAdjIrnrReMs0AYyqdI/6d+uQVf7mKfHW7QvRIxWp8lN+eVLCFAU3iido fOqrrQoQ0/MjJcg4wZ48GMtTZOMmVaW80e/EPIHpOU4p5HzttUMf4ERLGqOJJ9RNoWb6rxQR0 +M4LmNBTnmvhIwJwfs2/aoFmkkdHalGT8AKIDdqPpyPrQDm63s2tun9ym+f5K0SWTaP7iTLWO ztATyYH0iboSi1Va+oJNxdYeEFCubItAkoqSdU7i/ZPC5naroXlv2lQWo6u5FBvXzmma1gCQ3 EM+PKarZnCBu/KIK Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 23.05.2017 um 23:01 schrieb Lino Sanfilippo: > On 23.05.2017 21:38, Stefan Wahren wrote: >>> Lino Sanfilippo hat am 23. Mai 2017 um 20:16 geschrieben: >>> >>> I suggest to avoid this possible race by first unregistering the netdevice and then >>> calling cancel_work_sync(). >> What makes you sure that's safe to unregister the netdev while the tx work queue is possibly active? > unregister_netdevice() calls netdev_close() if the interface is still up. netdev_close() calls flush_work() > so the unregistration is delayed until the tx work function is finished. Furthermore both close() and > tx work are synchronized by means of the qca->lock which also guarantees that unregister_netdevice() wont > be finished until the tx work is done. > Thanks for the explanation. I suspect there could be the same race between serdev_device_close() and the tx work queue. So i would propose a variant of your original suggestion: unregister_netdev(qca->net_dev); /* Flush any pending characters in the driver. */ serdev_device_close(serdev); cancel_work_sync(&qca->tx_work); Since we have the same pattern in the error path of the probe function, the same applies there. Stefan