From patchwork Thu Nov 5 15:30:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 11884641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C11DC55179 for ; Thu, 5 Nov 2020 15:32:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B80A420735 for ; Thu, 5 Nov 2020 15:32:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="q/WyghDV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="oNo00lrp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B80A420735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=w5MQ4dAJdfD+eMoezyPvNbo5VqdRgtOyj4ivCh99phU=; b=q/WyghDVhU6+5YosZgfecCNgU Nf/DTUlumRknrZBOSOzEinur83kjeFC5rIQeWr3BH/QiJ1pd7B2JoSNvurKNZpVAVqAHOyhiOwl3A a8yUuEKjWt/NZwggWIaqG2xWCaiDQxODr2W33jTjmAxQgRMsp+iUEKuhja8wF5hZONmNlFrsyqrL7 ONS2cFP6sB8T96OOBUcAXmFOUcvFvhLcCt6NhgU6htm9BLaBKnSwLFdtxl+MtUTNWIMgo2te3S1wY bTN/DkGtWNxk8IggcuUY2HV+q8q4jeunJ8V5fHWDhR902KFq39wt+E6/PHMMvoRx3GfafwDUCaf2T ZTodGbyOw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kahEh-00069P-Ax; Thu, 05 Nov 2020 15:31:39 +0000 Received: from mail-eopbgr40049.outbound.protection.outlook.com ([40.107.4.49] helo=EUR03-DB5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kahEc-00066l-0n for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2020 15:31:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oTpUNgBmpHVJLghOXrvJjlUAJvK0eQEB79kR3eJM/Y6kROlqh15MaX6tWcEHbPcp/jPbQThbdZvrNTpOkr+5tRY+Lr+qSQTyE5PyDDiwAQq76EzNdy+AQ5XhRz2nJZgmn89J7WPZeSPTgu9pyWm8IXcpcd1pEJx4gkV0CyvKRT/4go0ZViWyhUdKqz0W8n4aHzdP3oGmcTy4nSibCeA42tbynFs1K3sz+mugtrGIymXQx+9UMvYc81kFCfosALn6MQOyqZAlAhD4k3syzpTf2lAVWLJ2ISgqjXflIVygndfSGWKtb8aNj40ydEL2CZ6t9URgeSaax5PwyhKnWUYaLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c9ihSKSrfVzlscsicDMm/B1wRv7SydQXYhPbQFdOLR8=; b=YtQKoO16EtjqKyUatFMuqUrT/efP7cqiOtNppXVmToX0bI4yikAgx8aXyiAepwx1OHztsWEJHeL8tNB0uU/WcvTeXTwpnqNKiILUy4xpJVbFSRHQpXI8/9z/0C5mlUmaY1Tu9UQb3N+AbiLY3u1nP12o200CS+fiZ9WZHXbVItm4DIkGmGgIapT5kbtJDEtetk6VhKBTIp1LrcKlBA9o5nTbxDQJojf8FlHLV7Nr+4h4Km9OZ4aoOys51uUH/T3vrGf/2W/fhqu1pXElNuNNe7EgaGXqQpxDpt1AD30FTSPx1ohnIaPIHB+Gshmd0hraC029QGSdZiLgVgj5Xh/x/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c9ihSKSrfVzlscsicDMm/B1wRv7SydQXYhPbQFdOLR8=; b=oNo00lrppmdig1LAmKwJ9msLyWJmOgC/FXvCU6dHQ/EGzhcXGNcTz2fJeMIdr8g28trqzX4Vg6XdpWjO7M/6hDh2eSCHe0bXWkf5CC62LLb1sXWVjCSISTwb4by3cNauxGFJeCXqefmubd9DAdzNSsZU6r5xjExSEdMqDtjDtMs= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) by VI1PR04MB4895.eurprd04.prod.outlook.com (2603:10a6:803:56::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Thu, 5 Nov 2020 15:31:30 +0000 Received: from VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f557:4dcb:4d4d:57f3]) by VI1PR0402MB3405.eurprd04.prod.outlook.com ([fe80::f557:4dcb:4d4d:57f3%2]) with mapi id 15.20.3499.032; Thu, 5 Nov 2020 15:31:30 +0000 From: Laurentiu Tudor To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] bus: fsl-mc: make sure MC firmware is up and running Date: Thu, 5 Nov 2020 17:30:50 +0200 Message-Id: <20201105153050.19662-2-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201105153050.19662-1-laurentiu.tudor@nxp.com> References: <20201105153050.19662-1-laurentiu.tudor@nxp.com> X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM3PR05CA0156.eurprd05.prod.outlook.com (2603:10a6:207:3::34) To VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from fsr-ub1864-101.ea.freescale.net (83.217.231.2) by AM3PR05CA0156.eurprd05.prod.outlook.com (2603:10a6:207:3::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21 via Frontend Transport; Thu, 5 Nov 2020 15:31:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 51d75d31-9f08-4327-f4e4-08d8819fddff X-MS-TrafficTypeDiagnostic: VI1PR04MB4895: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VuaI4pzsPNlCQGKIr6gNJ6xIRRu4L4BmXGBqqTOC3Dk/L43SSbCPtf3uKrb99NsB0QLCvM7aUSj5W0wN6XJHVri2837AhHUE7RHOZb/eScUswY6K07i3tGygJ3sYaIFBXJAjgPqN+Djt8gCC6nIMvqMGclWgroGpMWmWYf2f+ZnMg3TpuhCNj+9C1nI4gw9uPqt2p44XLPFGU7S0grsA6qQOEsC6qr79MTpvfEFPCNYEpGrKzOqNVKINfWgOPZNt3mRvf0Vl1h9zZMMcnGpT0fHR2kcMD+xLQBmBn4M7YJdHTpvr8/+njPCOa4XokRG8 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3405.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(366004)(136003)(346002)(8936002)(956004)(52116002)(66946007)(36756003)(66556008)(66476007)(2616005)(26005)(316002)(5660300002)(6506007)(1076003)(6666004)(4326008)(86362001)(8676002)(2906002)(186003)(44832011)(16526019)(83380400001)(6486002)(478600001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aZZeY4jrvWWZE0JbaCitlZ1i/aE3bWBsnT5sm7iQXu/+H/ZRoheb2TvcCW6YsPGmZfpse+3bCIyvJkSJG3w4ixOPXEbXOxh9x48OyrJFdR2h6H3AL9XItK2jjlGpMXatXg1lA6izTT2kfnIJ001g8CRyUh2BZeeGGaQRw3GKNINQtBZ5Dw9VkKbNUp0n0AuvYA/y1glzvR37HnQ4JbpndZvXx7wcxb9IOfD8LaxXP5IHUJcvQlM4XXAdUAs2NI5N/VWhGQkMwzuomJAdnfej3AjSF4Ict3/ZMz9ZR2Bc3PaWJ9BtjqMx+LH0FVDD8mBuGmNLY8zsdcPsH92QGIm4UWNmc5e8OGmqYFoHRMzWUsRRxnx7KM5GmjQogc37KJcy9VczOzRU/2ia3kzfgd1D1mQkVqWElmAwWErkyPsytZcWGXIGybLho14gxG741nAQQxkkr629uy1X+WwiIgckMgrosefxhBWbFqpuJFfOTYi6Khcb4QDEytWNv1w0/bnA0X3tQ9T7J6+PRcIHabyhZOsz/j9llUtfIEeNuOC9FcLEhFumzX/8TUlUqUiul5U52B4mzo1XJ48w85gyrO1yWJh77+vt1hHMbTPFK5EGeu9jsHGfINZMVusHzovF1VkbBkCE3/1lxI+zYITfQfXnjg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51d75d31-9f08-4327-f4e4-08d8819fddff X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3405.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2020 15:31:29.9106 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /Bi0xYF7XKScMUAWKhjkAk8Lq/3exdaj9e8g1po0A237WZph9YV7xCSYhUcFtDqcaLNSm4rrTt0OmtUWExbxSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4895 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201105_103134_096377_DE10DF05 X-CRM114-Status: GOOD ( 18.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ioana.ciornei@nxp.com, Laurentiu Tudor , diana.craciun@oss.nxp.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some bootloaders might pause the MC firmware before starting the kernel to ensure that MC will not cause faults as soon as SMMU probes due to no configuration being in place for the firmware. Make sure that MC is resumed at probe time as its SMMU setup should be done by now. Also included, a comment fix on how PL and BMT bits are packed in the StreamID. Signed-off-by: Laurentiu Tudor --- drivers/bus/fsl-mc/fsl-mc-bus.c | 42 +++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 806766b1b45f..b8e6acdf932e 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -60,6 +60,9 @@ struct fsl_mc_addr_translation_range { phys_addr_t start_phys_addr; }; +#define FSL_MC_GCR1 0x0 +#define GCR1_P1_STOP BIT(31) + #define FSL_MC_FAPR 0x28 #define MC_FAPR_PL BIT(18) #define MC_FAPR_BMT BIT(17) @@ -973,21 +976,36 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) return PTR_ERR(mc->fsl_mc_regs); } - if (mc->fsl_mc_regs && IS_ENABLED(CONFIG_ACPI) && - !dev_of_node(&pdev->dev)) { - mc_stream_id = readl(mc->fsl_mc_regs + FSL_MC_FAPR); + if (mc->fsl_mc_regs) { /* - * HW ORs the PL and BMT bit, places the result in bit 15 of - * the StreamID and ORs in the ICID. Calculate it accordingly. + * Some bootloaders pause the MC firmware before booting the + * kernel so that MC will not cause faults as soon as the + * SMMU probes due to the fact that there's no configuration + * in place for MC. + * At this point MC should have all its SMMU setup done so make + * sure it is resumed. */ - mc_stream_id = (mc_stream_id & 0xffff) | + writel(readl(mc->fsl_mc_regs + FSL_MC_GCR1) & (~GCR1_P1_STOP), + mc->fsl_mc_regs + FSL_MC_GCR1); + + if (IS_ENABLED(CONFIG_ACPI) && !dev_of_node(&pdev->dev)) { + mc_stream_id = readl(mc->fsl_mc_regs + FSL_MC_FAPR); + /* + * HW ORs the PL and BMT bit, places the result in bit + * 14 of the StreamID and ORs in the ICID. Calculate it + * accordingly. + */ + mc_stream_id = (mc_stream_id & 0xffff) | ((mc_stream_id & (MC_FAPR_PL | MC_FAPR_BMT)) ? - 0x4000 : 0); - error = acpi_dma_configure_id(&pdev->dev, DEV_DMA_COHERENT, - &mc_stream_id); - if (error) - dev_warn(&pdev->dev, "failed to configure dma: %d.\n", - error); + BIT(14) : 0); + error = acpi_dma_configure_id(&pdev->dev, + DEV_DMA_COHERENT, + &mc_stream_id); + if (error) + dev_warn(&pdev->dev, + "failed to configure dma: %d.\n", + error); + } } /*