Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5096508ybh; Wed, 7 Aug 2019 00:20:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmGzWQfQiziamkFn9eZCeRvUZY6MzOfQ9WdiGXQt8Q1ML+41S4UVQCOxoI+PSxLw5dYCuU X-Received: by 2002:a17:902:2ea2:: with SMTP id r31mr6959336plb.200.1565162428420; Wed, 07 Aug 2019 00:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565162428; cv=none; d=google.com; s=arc-20160816; b=r06BbkEpWyjuPpbLcw4MXupDaBJAKRJviAZMi2e/Yk3dGP31epq1WFyrOdhDWt1fzN TllwfyVqCBBKW2cUSeFUKQ4DH8FDb0zfzryERMQB9VQq1RA+zpF0IfGWvoejrCjggIjd /ZCAutXfKd22e4ruH9hnADrB9SgdYYX27L8UBLNpTQBoESsHb4MDQ42g7SF9YqAZ270I jsVGEfHSrmOYylSHwuEdh3LjU571FjVnF7h/cMSXS9+6zJBME34rD67iLOMRL3b0cXeB /r9T8EC7hxWyqkizkfheePPDvLErMFMcUAuomFm20u5lc7O/3bP7yYIIJ9Yra2P+KQpv 20JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=lStqXB1CE+Wazs+U2rxsTV3wYflhaLXJIkT4Eebm9Ds=; b=rmzRIce8FuOA25ccduxQbd6xxvS6W6zCdFDfgf8axOkjVomj3ZwVYCYOqkZhxZeokl uevwq9ETSRHIf3Yb1uPlSpHHxZGD3oBsFSqCdse63M/4a0i1uO6XZFVFIxIWzPkw8oPu 6aWZgRpqT721t3i9NZCk8cGcQJZdFleOqEcd+i3M9GamOOde7RlEXFjxWlcOhckwQuxI jYfoORMk06bXTpDGLw8rvn4W9fKUHI98mDQpuFw0BtG2eeGjaAvCUI5F+d1U1Gg4nOgj /Goy2QOcU4pxfb3uKTsAQnKiuov7jZFL09DHzRkaeRLwZNzh+IrrzUUHsnY+FCwvSR3k 4LBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GkhaTE0U; 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=fail (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 i23si48454927pfa.196.2019.08.07.00.20.12; Wed, 07 Aug 2019 00:20:28 -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=fail header.i=@gmail.com header.s=20161025 header.b=GkhaTE0U; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387403AbfHGHST (ORCPT + 99 others); Wed, 7 Aug 2019 03:18:19 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40106 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbfHGHSS (ORCPT ); Wed, 7 Aug 2019 03:18:18 -0400 Received: by mail-pl1-f195.google.com with SMTP id a93so39304008pla.7; Wed, 07 Aug 2019 00:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lStqXB1CE+Wazs+U2rxsTV3wYflhaLXJIkT4Eebm9Ds=; b=GkhaTE0UE4nePuRPazYfHVmLl6UFjBwfbR+C7iplIolBn3RNuWmgNzI5I+eVahe+xe Z43Ykl28TtMMC3LHyqfeOlHRS2OAr9n+GrSpcd9ldBUs0yKv1ECHGpiVeYIF4rLATZE4 FUdFochaJMaCsk00J0T+sUD60TXWdH3PfHsf4C3YJBh+z4Jk31SiocHLSNhkrP3s+S2g UPBx5S44gcygQJX/CZVv2nzw1YlDFBbGYooMVxb+n/uAU52tGGaJJxvzf5uKgHDuRo4R fTfqCUOey/c94OTSearRQTi1pYfvL8ou/ryK/TVvyHihQrVdVTuwXHqgvwYJHCl82TGp omSQ== 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=lStqXB1CE+Wazs+U2rxsTV3wYflhaLXJIkT4Eebm9Ds=; b=Gx1JvqOi2S5f/S6wNT4Hx4/g689lj4XcEleFdYbqwdSj5gJTyV+msDB48yoWC/uBLT mmZe7FoOysj8ffE5lx15CjLZtJkTaVRMt1RTqiSCnNPPFPNfBNfpNDZxdAViuUBcAX3w 8Ad2co8dmnw3m4vN5CfO32bjTRbLa2Ar67ydKRCLC3lTY9Q6DbSbyGk8PCFxzR/oMkQQ 3WRA4L9XRA5i7oqHau544TC6KGfDsZvvYZoTVSTMdIj8yIf/zb/FhylDyo2LGNsVh9sa g0vmprnJypLhNOZibcFb4xL8M+B6N61tSyeTctKFPid/xYpcdgw/2xDDWPvBi3KwvChE BFKw== X-Gm-Message-State: APjAAAVOXq6liDhb2LrXw+9QgY4gSfmaRoumWwGrUdg4mvqGSCVMl46G pGvOZ1TdtbbVhXLwgpwu3QREidzKDSE= X-Received: by 2002:a17:902:9004:: with SMTP id a4mr6927957plp.109.1565162298236; Wed, 07 Aug 2019 00:18:18 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id q22sm83570089pgh.49.2019.08.07.00.18.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 00:18:17 -0700 (PDT) From: Fuqian Huang Cc: Greg Kroah-Hartman , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH v2] i2c: avoid sleep in IRQ context Date: Wed, 7 Aug 2019 15:18:07 +0800 Message-Id: <20190807071807.17488-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org i2c_pxa_handler -> i2c_pxa_irq_txempty -> i2c_pxa_reset -> i2c_pxa_set_slave -> i2c_pxa_wait_slave As i2c_pxa_handler is an interrupt handler, it will finally calls i2c_pxa_wait_slave which calls msleep. Add in_interrupt check before msleep to avoid sleep in IRQ context. When in interrupt context, use mdelay instead of msleep. Signed-off-by: Fuqian Huang --- drivers/i2c/busses/i2c-pxa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 2c3c3d6935c0..876e693bafd9 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -456,7 +456,10 @@ static int i2c_pxa_wait_slave(struct pxa_i2c *i2c) return 1; } - msleep(1); + if (in_interrupt()) + mdelay(1); + else + msleep(1); } if (i2c_debug > 0) -- 2.11.0