Received: by 10.213.65.68 with SMTP id h4csp3642791imn; Tue, 10 Apr 2018 02:13:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/1+1dPysDPDP5p+lr8NJjfdCKV23ixZtlRXIGxZCwDsxavAVJigkqqiMYtO19aEjzRAKbK X-Received: by 10.101.97.16 with SMTP id z16mr28007534pgu.23.1523351586100; Tue, 10 Apr 2018 02:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523351586; cv=none; d=google.com; s=arc-20160816; b=ywkliSSkUpEVnDD5WZk+/q9H+TbeG6OZOedvD6U/ctQj2dU6KCbn37EKuaDdOSPdAu FrZBzHKgJU3m5eNMXRvpbo3ziw/Zp/h36k/SnnrDxties5jQKXKycw87lrElVqYMOt4c 2FNSOaYEe+WSvHUxHMhDwRBQA3I01pWkLQuRqoyUmgQ10t+HHjRffMAm6aHDnvTmWSz7 ehEZ7SQT4V3Z1h3v7D7nTNR/YO35Yv0s7kld5Cg6CznLpMUhWcEv4pKni5nxz1iiobsa Sz+AeBj+ONpYI1wn4CNke/+Vap1Z2dDkWGZvFmUtE7PfM3wPrVI9vtv9oMn14HX64iHD skMg== 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=qwi5lZVtmdqxi4wFYNbqyoPBqrBVSMnUqbz9KA6wj7Y=; b=xT+a/Vy0CxiwpbV9DWvzqaF3NWQy33y/I0dcic5IPi+sRgwXPNqE3xRW7IElPSnWU4 5eQqtB/gj0xkLIsJpH7myvbzo7riIBh/+mVJbBZe+VjM3UleCLSCOfnTbH7oHI6id8ub iyrbX0tuKxZmTUP+vvx1bpV4KtmUxrnIq3zIi6bQ+HALm2r5JLqMQ/nglocDj4QpkfsT xCHY9RQxI8K5OoTpLEfXsAED7upDyq0hD3TmCtkQ0/gLEFuQlq2RwfOwl3J8C98mA5FC kgZ9NxAFg7x8VJCR6a9O3KZBXJvxCQKtuwzaqBc8vBc2Pgk2hqPUiVebLoSnjVRPXsrh UZpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g4Fgl5vm; 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 n81si1781300pfj.152.2018.04.10.02.12.29; Tue, 10 Apr 2018 02:13:06 -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=g4Fgl5vm; 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 S1753325AbeDJJIz (ORCPT + 99 others); Tue, 10 Apr 2018 05:08:55 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:52914 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753105AbeDJJG0 (ORCPT ); Tue, 10 Apr 2018 05:06:26 -0400 Received: by mail-it0-f66.google.com with SMTP id f6-v6so14877233ita.2; Tue, 10 Apr 2018 02:06:26 -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=qwi5lZVtmdqxi4wFYNbqyoPBqrBVSMnUqbz9KA6wj7Y=; b=g4Fgl5vmqNxoEegX7r4A3qqQHeWyBWhk2bEvHemUPJ1vYqaQbJ/06odzZgzdA+Cymj 1xhHOAaVoGQBcHBLGqufnfziT13Ik/yag/lWEMvq6XRXt/RNEv+x9+fEPxgzT9aAlluc krHn9t7Ov079JKssEoKt5pl6rKbpjCnBxQ6yHdsqR+UOvvXR4oFCWzBK7pqlqYzRgIVB TFRluUDnjthCqyC8a2Fqcac+cOUpwfQeyd1GKvNRemvZllmwc4vpudfRbEKD4pPd+mmi LoqS0lZbwbqFQzr7kpkSEvSjsQ1kBnnrhRCpXmBHTRZCea5YApl1z7wATy+P4qrS5iq3 ajPQ== 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=qwi5lZVtmdqxi4wFYNbqyoPBqrBVSMnUqbz9KA6wj7Y=; b=NRL9L5qaVPJ3yDAlAmIZF8CIut9BzD08YDiYGzK7X3JtYtm0wQ27bNct2yCjkJ9zHr alE3POVn+zM9El4QaCf43fLBBal9W7Im2a3qT0+mEfrEZeRzxTbvHEHWgs4nRCv8uL5A es+y6nfVbV7K526ErEAOkIckFbKMb0zbVXjkcZ+FTPZgDncWCsOzNZ/mUlEnHxhmAafa En5jYbvDEY2MM25TOD6w2/fFuAsVaLsaj5g3yZicE751JNaJmBCFVkTDb5m5rAxylFGb wVCs1hX4RD15jq6WUQr8sInHUa/OaHWU4ybIRvrvRqLNkrj6idzTae5vhGwXtk4L2zLm 46QQ== X-Gm-Message-State: ALQs6tAhJIVqv/BjZfQoVYYNIEeRJX6jYoy+VE4KuhCjeLglICowGbtR NDbUG5JFDKCen8Gw2utUVebB3uE9 X-Received: by 2002:a24:5143:: with SMTP id s64-v6mr1385320ita.116.1523351186059; Tue, 10 Apr 2018 02:06:26 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id e9sm1051630ioj.47.2018.04.10.02.06.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 02:06:25 -0700 (PDT) From: Jia-Ju Bai To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] spi: spi-topcliff-pch: Replace GFP_ATOMIC with GFP_KERNEL in pch_spi_handle_dma Date: Tue, 10 Apr 2018 17:06:16 +0800 Message-Id: <1523351176-29741-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pch_spi_handle_dma() is never called in atomic context. This function is only called by pch_spi_process_messages(). pch_spi_process_messages() is only set as a parameter of INIT_WORK() in pch_spi_pd_probe(). Despite never getting called from atomic context, pch_spi_handle_dma() calls kcalloc() with GFP_ATOMIC, which does not sleep for allocation. GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL, which can sleep and improve the possibility of sucessful allocation. This is found by a static analysis tool named DCNS written by myself. And I also manually check it. Signed-off-by: Jia-Ju Bai --- drivers/spi/spi-topcliff-pch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 97d1375..dc93ca9 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -1007,7 +1007,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) spin_unlock_irqrestore(&data->lock, flags); /* RX */ - dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_ATOMIC); + dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_KERNEL); sg_init_table(dma->sg_rx_p, num); /* Initialize SG table */ /* offset, length setting */ sg = dma->sg_rx_p; @@ -1067,7 +1067,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) head = 0; } - dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_ATOMIC); + dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_KERNEL); sg_init_table(dma->sg_tx_p, num); /* Initialize SG table */ /* offset, length setting */ sg = dma->sg_tx_p; -- 1.9.1