Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1397313pxj; Fri, 21 May 2021 13:14:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypClnHUY4e4Hd+Pwz7CV3qMSjsK2uiLmRZ3TcSP0k9On/PF0IH3n65j1lEP8rBDbSJ9ldP X-Received: by 2002:a5d:8a16:: with SMTP id w22mr599765iod.186.1621628067690; Fri, 21 May 2021 13:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628067; cv=none; d=google.com; s=arc-20160816; b=JKV05IjfZ+8o/SCpsHjhdXVJ9H0XUzL0v2r/TlpXABnhzIt8o4ih7DZCPVbYk7K4X3 234LVsT70NhhMk4BVr6ompNr5WMYKkYViq86tPkAjTBDfU91r6pHWw2bQgNqCBqBSmdH GgrZqhVO1yDdfBpTlIeQ8f+EwYLHq6pc5y0THMvMBuO5C3NYO2VPtgOkhQcZfMZWIrqR nAznWedGvMCZpZmOTKn4TcWutvh1U0Bw7Apj13jWVY15UzeYeU7T+Qw9ibpTHWTOK9QX hxogA0hxQQvDnjAi929B+UF/MsEJEeMBmA5A5zT8eqAUvsg6IZWdo5qs8fOUZXPbmzLs KoLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XLinM7Z5qqFbKC4GObmBe7x0M/4rvU07bFC2G7aHNhU=; b=KLNOiegtDmn6zi5F4Vr1S9MgDbFOTifaaDFRo/dg7iAZbVnjDp5GsVN05SokTvwSU3 URI1hgFpi4z1Aj5E+U/QokrV9V8My0ceEIdWLjPB9OdNqp9RCLY61Co4/PWWmm0YpU8o vhIwWNiYp0+SQIx24bVXiXpH7ihduBu+Fun5tNhS45Tt6W/jHRVPnRsVIopAmFZ4TPF8 H7hL2ixt+ulR1o4BYxiusUtJx3hF1Vq0cyiAe6J2yclGwa2unm+YwdAepjJ9L6nYPrNa gvgozMMDcAUudkgIga2sWcBzmdHIlQ+5G/+eoMbxBBh8SoKC/VxtY82OgOr51D7Dl+VC CYWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ONWDyYeV; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si7884737iog.67.2021.05.21.13.14.15; Fri, 21 May 2021 13:14:27 -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=@linuxfoundation.org header.s=korg header.b=ONWDyYeV; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231374AbhEULca (ORCPT + 99 others); Fri, 21 May 2021 07:32:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:56172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbhEULca (ORCPT ); Fri, 21 May 2021 07:32:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C4DAF613DA; Fri, 21 May 2021 11:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621596667; bh=XCW+h8GxyRMMPHetbkEqtfnjz33mh3sQXexOSdqhuy4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ONWDyYeVs/0J4Vkz+ueCYV0mSFQu9dZ6ray+woDOk8ypSUcoMX6Tw4aQZ3M2eq1da wouGyDIgIDRtX3zrdMpVRBUZS2hL6f0PSp9DUlX7FDqpAviYiNx/nER4LuMFzqxqgX +wEmCOIz4t+QuO9vJE1Tz0RiQbNwgTCxxyNwgV4A= Date: Fri, 21 May 2021 13:31:04 +0200 From: Greg KH To: Zheyu Ma Cc: cernekee@gmail.com, jirislaby@kernel.org, linux-serial@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH v2] serial: rp2: use 'request_firmware' instead of 'request_firmware_nowait' Message-ID: References: <1621577323-1541-1-git-send-email-zheyuma97@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 21, 2021 at 07:15:21PM +0800, Zheyu Ma wrote: > On Fri, May 21, 2021 at 2:51 PM Greg KH wrote: > > > > On Fri, May 21, 2021 at 06:08:43AM +0000, Zheyu Ma wrote: > > > In 'rp2_probe', the driver registers 'rp2_uart_interrupt' then calls > > > 'rp2_fw_cb' through 'request_firmware_nowait'. In 'rp2_fw_cb', if the > > > firmware don't exists, function just return without initializing ports > > > of 'rp2_card'. But now the interrupt handler function has been > > > registered, and when an interrupt comes, 'rp2_uart_interrupt' may access > > > those ports then causing NULL pointer dereference or other bugs. > > > > > > Because the driver does some initialization work in 'rp2_fw_cb', in > > > order to make the driver ready to handle interrupts, 'request_firmware' > > > should be used instead of asynchronous 'request_firmware_nowait'. > > > > You just now slowed down the probe function. Are you _sure_ this is ok? > > Sorry, I'm not an expert in the field, but from my point of view, the > previous function 'rp2_fw_cb' does some initialization work that is > not suitable for asynchronous execution. Because after these initial > work, the driver can work normally (including preparing to handle > interrupts). > > > Do you have this hardware to test this? If so, what is the init time > > before and after this change? > > To be honest, I don't have real hardware, I tested it with QEMU. I > made a total of 5 attempts. Before this change, the average boot time > required by kernel is 6.382s, the time required for insmoding this > module is 0.139s; After this change, the average boot time required by > kernel is 6.426s, the time required for insmoding this module is > 0.160s. This change really slowed down the probe function. Ok, at least you've tested it :) I'll take a slower init over a broken init any day. I'll go queue this up, thanks. greg k-h