From patchwork Fri Jul 21 22:09:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hotran X-Patchwork-Id: 9857763 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5725A600F5 for ; Fri, 21 Jul 2017 22:12:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4925D285B0 for ; Fri, 21 Jul 2017 22:12:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AFC8285EA; Fri, 21 Jul 2017 22:12:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9006A285B0 for ; Fri, 21 Jul 2017 22:12:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754156AbdGUWMA (ORCPT ); Fri, 21 Jul 2017 18:12:00 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:32826 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753853AbdGUWL7 (ORCPT ); Fri, 21 Jul 2017 18:11:59 -0400 Received: by mail-pg0-f48.google.com with SMTP id k14so33808488pgr.0 for ; Fri, 21 Jul 2017 15:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=Dl5WsYBThxGvoaQU2ml0pWhr4XTOD6uNFDImbQHNvvY=; b=eHNfpjUM48P/vqdz4dsx2olniY7RHn9K7/nqQYk5b6xI4xmTzxOi7isSE/tEHRYYPl Oi/OogixqA1lXqqV/kNUQb74dyYO/kSBkHlo+f1faD8FVplXEYAbi7ppr7xgFeW7uRgl 7V1+98wek8mfdr2BwVzKsczvUevxVfHhDkCmk= 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=Dl5WsYBThxGvoaQU2ml0pWhr4XTOD6uNFDImbQHNvvY=; b=UG2vmlbTc0z5OGmu36SZSgE3aX8oXNfzH0+ysKCdGT4d57dfqg3GQmE3pCwUwPpgi/ 9+kKC/v1gs1OO/Td9aSGGziJO/i3NkvgXYtyGXfpW4DbODPxGamLX8NR+NXf9xGReb13 ItKSlcl5u3kxEDct4+1WEo18MiJ1WPD+08gtcTlRaVWlfCzogCy8jPkxBeWvQqzZsk15 6I0NprQmHF34ExZez2WtCsVDaobBvE00CLYiwOOK8lvik+mQqLRELzXel2dw+x+CfK+W TWFOwk4FlU9tlxBU+c2cM8bLzQ0RZEG9a1nmgHuvUumQ4hBZjKOAS0lyuJLqppPWb+Nt cCtw== X-Gm-Message-State: AIVw113ZP1WYZ8N3y5O3yfTzy4gEcEJRLqi2mCRz58DpUIvRJBeUieu8 YBwJ7fU6Fd/8o2ji X-Received: by 10.84.232.13 with SMTP id h13mr10116960plk.168.1500675118753; Fri, 21 Jul 2017 15:11:58 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id q24sm11567444pfg.167.2017.07.21.15.11.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Jul 2017 15:11:58 -0700 (PDT) From: Hoan Tran To: "Rafael J. Wysocki" , Jassi Brar , Prakash Prashanth Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lho@apm.com, isubramanian@apm.com, Hoan Tran Subject: [PATCH] mailbox: pcc: Fix crash when request PCC channel 0 Date: Fri, 21 Jul 2017 15:09:29 -0700 Message-Id: <1500674969-12906-1-git-send-email-hotran@apm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When PCCT is not available, kernel crashes as below when requests PCC channel 0. This patch fixes this issue. [ 0.920454] PCCT header not found. ... [ 8.031309] Unable to handle kernel NULL pointer dereference at virtual address 00000010 [ 8.031310] [0000000000000010] user address but active_mm is swapper [ 8.031312] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 8.031313] Modules linked in: [ 8.031316] CPU: 31 PID: 1 Comm: swapper/0 Tainted: G W 4.13.0-rc1 #18 [ 8.031317] Hardware name: AppliedMicro(R) 07/20/2017 [ 8.031318] task: ffff809ef3b08000 task.stack: ffff809ef3b10000 [ 8.031322] PC is at pcc_mbox_request_channel+0x8c/0x160 [ 8.031325] LR is at xgene_slimpro_i2c_probe+0x1c0/0x378 [ 8.031326] pc : [] lr : [] pstate: 00000045 [ 8.031327] sp : ffff809ef3b13bd0 [ 8.031327] x29: ffff809ef3b13bd0 x28: ffff000008ed90a0 [ 8.031329] x27: ffff000009091000 x26: ffff000008e50470 [ 8.031330] x25: ffff000008ed9100 x24: ffff809eefd9ac30 [ 8.031332] x23: 0000000000000000 x22: ffff0000090e3e10 [ 8.031333] x21: ffff0000090e3000 x20: 0000000000000000 [ 8.031335] x19: 0000000000000000 x18: 0000000000087ffc [ 8.031336] x17: 2fe48d76a78303f0 x16: 0000000000087ffc [ 8.031337] x15: ffff000000000000 x14: 0000000000000000 [ 8.031339] x13: 0000000000000000 x12: 0000000000000018 [ 8.031340] x11: 0000000000000018 x10: 0101010101010101 [ 8.031342] x9 : 0000000000000000 x8 : 7f7f7f7f7f7f7f7f [ 8.031343] x7 : fefefefeff6b646d x6 : 0000008080808080 [ 8.031345] x5 : 0000000000000000 x4 : 0000000000000001 [ 8.031346] x3 : 0000000000000000 x2 : ffff000008819b64 [ 8.031348] x1 : 0000000000000000 x0 : 0000000000000000 ... [ 8.031393] Call trace: [ 8.031394] Exception stack(0xffff809ef3b13a00 to 0xffff809ef3b13b30) [ 8.031395] 3a00: 0000000000000000 0001000000000000 ffff809ef3b13bd0 ffff000008899450 [ 8.031397] 3a20: ffff809f7e1f9a10 ffff000008f60be0 0000000000000001 ffff809ef3b13b7c [ 8.031398] 3a40: ffff809f7e1f9a10 0000000000000000 ffff000009091000 0000000000000003 [ 8.031399] 3a60: ffff000009091000 0000000000000003 ffff809ef3b13a80 ffff0000084e0794 [ 8.031400] 3a80: ffff809ef3b13a90 ffff00000850bb64 ffff809ef3b13ad0 ffff00000850bf34 [ 8.031402] 3aa0: 0000000000000000 0000000000000000 ffff000008819b64 0000000000000000 [ 8.031403] 3ac0: 0000000000000001 0000000000000000 0000008080808080 fefefefeff6b646d [ 8.031404] 3ae0: 7f7f7f7f7f7f7f7f 0000000000000000 0101010101010101 0000000000000018 [ 8.031405] 3b00: 0000000000000018 0000000000000000 0000000000000000 ffff000000000000 [ 8.031406] 3b20: 0000000000087ffc 2fe48d76a78303f0 [ 8.031409] [] pcc_mbox_request_channel+0x8c/0x160 [ 8.031410] [] xgene_slimpro_i2c_probe+0x1c0/0x378 [ 8.031413] [] platform_drv_probe+0x50/0xbc [ 8.031414] [] driver_probe_device+0x21c/0x2d0 [ 8.031416] [] __driver_attach+0xac/0xb0 [ 8.031417] [] bus_for_each_dev+0x58/0x98 [ 8.031418] [] driver_attach+0x20/0x28 [ 8.031419] [] bus_add_driver+0x1c8/0x22c [ 8.031421] [] driver_register+0x60/0xf4 [ 8.031422] [] __platform_driver_register+0x4c/0x54 [ 8.031425] [] xgene_slimpro_i2c_driver_init+0x18/0x20 [ 8.031426] [] do_one_initcall+0x38/0x124 [ 8.031429] [] kernel_init_freeable+0x190/0x22c [ 8.031431] [] kernel_init+0x10/0xfc [ 8.031432] [] ret_from_fork+0x10/0x50 [ 8.031434] Code: cb030e63 8b030013 b140067f 54fffda8 (f9400a61) [ 8.031448] ---[ end trace 14eb48a4e1e1f9fb ]--- Signed-off-by: Hoan Tran Acked-by: Prashanth Prakash --- drivers/mailbox/pcc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index ac91fd0..cbca5e5 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -92,7 +92,7 @@ */ static struct mbox_chan *get_pcc_channel(int id) { - if (id < 0 || id > pcc_mbox_ctrl.num_chans) + if (id < 0 || id >= pcc_mbox_ctrl.num_chans) return ERR_PTR(-ENOENT); return &pcc_mbox_channels[id];