Received: by 10.223.176.5 with SMTP id f5csp390724wra; Sat, 27 Jan 2018 01:59:55 -0800 (PST) X-Google-Smtp-Source: AH8x225rCkY0wg94ljMkknNRrSkLIyHeRcyF1mSIYa2CqA4WoB5RViTyUsjm6yfNjaaCiNuj60Ru X-Received: by 10.99.96.199 with SMTP id u190mr17394561pgb.290.1517047195703; Sat, 27 Jan 2018 01:59:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517047195; cv=none; d=google.com; s=arc-20160816; b=OFQ90fg7BifgDPi/WSiDxMZ/RXAFDAOdFO3i/0fOqJfsGp27JxS5ymm1bNpSUwPGOO /fQtW6amacvQYjDcePsH2+r7l5LiHSen6iraaxzQ4ce3Bnk20Yei3O5YEcB2GamojmcV ARcwTSHsN6pc8HFTl/MPaO+pAY+cdhqEy29RMFjf8SsAxBNoLozZFq6bMFhVWp4KY/3u xZjtuu7JuSqK0wk8/Tp307jeNYiwqS9UfTfxuI5yckjaDVzXazWNpiPLaDQz+k3B74lf 7cOPKofbIXW/FyhrB6RGYm7oQdJojKj5CDY3VlvvofRez5tH44OoPM9u86Q+tR0iE/ov PH3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3VCHs4vJeh1wCyWpfsyKN/gfwneu+yXZL5g1zjRMdlc=; b=nl0bH+M5rAAL32BVw2+qnNzRAQrnleAKIwH9ZwBS1QD2gBh30LcYVJR55G5nQlpsR0 +vtYzEKF1nIzz8KuUo5NF2/1YStKt/chnI1tdLwFxmRPP1AbJ3EJcOZ1qREJldPKWQ0b 0EOh+SHr1b9v56CATXXMETBucjUH6Qil1QUZc0Ysim8MFi5aT7QxUV5aKF3AYwS3iOBo 1gyRqyNHbnIEJl3k3bRxP8C0ETtYyj2m6CYMaNnmVW+ja+nD2r/qoV619QOrm80w3SQ1 6YU05rS7Xfl/dpe6JRADUUhk0yPNJrnUg7jazzzYTe1z7ycQ4C3+I3bLJuTnf5AYMqLC uhaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VzFlQ0fg; 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=NONE 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 97-v6si5108104plb.789.2018.01.27.01.59.41; Sat, 27 Jan 2018 01:59:55 -0800 (PST) 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=VzFlQ0fg; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752436AbeA0J7S (ORCPT + 99 others); Sat, 27 Jan 2018 04:59:18 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:41012 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752078AbeA0J7Q (ORCPT ); Sat, 27 Jan 2018 04:59:16 -0500 Received: by mail-pf0-f195.google.com with SMTP id c6so1698880pfi.8; Sat, 27 Jan 2018 01:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=3VCHs4vJeh1wCyWpfsyKN/gfwneu+yXZL5g1zjRMdlc=; b=VzFlQ0fgdoZq8N5UVpUa+ZsywsmGhhLUu48mk4nxzKlpGzSiPRI2u6A0M1MMXBrVJD NcL4zLEr/Ok5mLiR6H6rFJCf6C7pu9LDWJOPOwMydb60znAPS6QXgjgjmjdiZ99cpwuY DOnbsAuPB83YIClHgr/3sVeDNnW7srslL6Ds2CXOPBZyCJ1BwqZ7vdwLS1zAFWvKXAfv B55nBrTIhfCWzG1k1MmIzyy4JmU9KUN3Tm0tSrKVjeLdEwb4KR0O/Ef3n8p6S2WsM+ls JNZelAwoF3p0sNTX10CVFUVcDupmc1TIgnpQ5DXNkmjv4/pBjztpx4kXEE1EP3DiIKGU 0WWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3VCHs4vJeh1wCyWpfsyKN/gfwneu+yXZL5g1zjRMdlc=; b=cglIUk6QuXvKJKRO1z9le/32WXiTJFbIWOnfgwmKLZiatYDzBJTBcEYmyrh17ZBJdq PEFT9x/1Dl9pWD2oy3/DXPdXSgUFf3IAbzL/GPtRavK3rt8KqlcM5r77vfWlTxSgerIx 0mlMKKgLyNvIDX5T41nZewttwOEFI+mW8ng5U63iKRtXvwRQIkjLat1A2k5GxatZwelo RWXx70iR83vKlkTfbtyTH8WhreQX2nrBMRs+Okj/4MS7wTlMEnSAqRlIVF695hcdAHwF jqGtRTR8r0dYLVSZiHPdtg57dL3Ih/n7CFU375Jnx684SCYtstZFcNqKYlkQtCz0Au5U RZZw== X-Gm-Message-State: AKwxytdEcfqbmcJHJluEaLVEXiJPt0/Da74Ae4mQT0y7sZZ6LG6rCPvr j4AvlEfFukcw5/MuSqVvX2Q= X-Received: by 10.101.88.7 with SMTP id g7mr652266pgr.249.1517047155614; Sat, 27 Jan 2018 01:59:15 -0800 (PST) Received: from bai-oslab.tsinghua.edu.cn ([2402:f000:1:4413:c943:4098:9a43:1e52]) by smtp.gmail.com with ESMTPSA id t1sm26315055pfj.21.2018.01.27.01.59.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jan 2018 01:59:15 -0800 (PST) From: Jia-Ju Bai To: marcel@holtmann.org, gustavo@padovan.org, johan.hedberg@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] bluetooth: hci_ll: Replace mdelay with msleep in download_firmware Date: Sat, 27 Jan 2018 18:03:52 +0800 Message-Id: <1517047432-23420-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org download_firmware() is never called from atomic context. It is only called by ll_setup() that is called only via function pointer "->setup" used in hci_uart_setup() in drivers/bluetooth/hci_serdev.c and drivers/bluetooth/hci_ldisc.c. hci_uart_setup() is called only via function pointer "->setup" used in hci_dev_do_open() in net/bluetooth/hci_core.c. All of the above functions do not enter atomic context. Besides, ll_setup() calls msleep() and hci_dev_do_open calls mutex_lock(). So it indicates that all the above functions call functions that can sleep. Despite never getting called from atomic context, download_firmware() calls mdelay() for busy wait. That is not necessary and can be replaced with msleep to avoid busy wait. This is found by a static analysis tool named DCNS written by myself. Signed-off-by: Jia-Ju Bai --- drivers/bluetooth/hci_ll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c index e2c078d..f804adc 100644 --- a/drivers/bluetooth/hci_ll.c +++ b/drivers/bluetooth/hci_ll.c @@ -644,7 +644,7 @@ static int download_firmware(struct ll_device *lldev) break; case ACTION_DELAY: /* sleep */ bt_dev_info(lldev->hu.hdev, "sleep command in scr"); - mdelay(((struct bts_action_delay *)action_ptr)->msec); + msleep(((struct bts_action_delay *)action_ptr)->msec); break; } len -= (sizeof(struct bts_action) + -- 1.7.9.5