From patchwork Thu Aug 30 09:08:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 145533 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp575517ljw; Thu, 30 Aug 2018 02:10:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ77Wx6djml/l0qmsZsStcx46tT59mdzNBDXcJeOK93Q2qaWJgRP4w6ljtX9Z7/RuzkZgrj X-Received: by 2002:a63:c00b:: with SMTP id h11-v6mr8882803pgg.279.1535620243494; Thu, 30 Aug 2018 02:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535620243; cv=none; d=google.com; s=arc-20160816; b=QFeMI8EqJLQy5PlwYwqIiEDu+xrnPFskslCZGNLMZibTNsbv1ZzsDclfCKcCt9hG6x kJKV/kdpayycavWxqVTY4PBisAEENyYTuY/VQbqRYx6h9HqVBSKSHO6Qy39ELwdddQYn bzvWNyUbi4FIp4XlY8TNoheNd1du5l2i04sRvHfX7BGyngSBr61JIcNWAQWEv8dg9j2k KNTRMvmHTYaUyO5yNq3X2/BsW3lctckXv+41kwUO7AfCNj6Z7yy6oijSHmDZq3hKebkY dmV1G3iypSrit3OCGN7Xw8Nu2rBbX4xkZKu7qIV7Trpg4dBwHSrhxFZDiurVkXuKQSn9 2q/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=aVZhQar6YP1qPhWuO3y72C2g+RGg4kDtbWpnqFsMFNY=; b=MOU2d2tSKb0XEJkWd7kVDTY+s5kAIwLOGFI56OSFW0HHyDSBcrJSkbF1x6VRQcO9wv mVelW03qTot/UYRjHv2YvOaqLaV6GwD0iWEvcc+bkcP4XRTf3Apabh/2jc0m3MipDj+V 65Q19p5pRyfkTGBb2hJ4/JFzcduYR+cai5/tGRn/+w/Qr0b9l25eBcSvYREWw9cVWZ11 P4iJZvfphTykJnVg6bBNfPIYFLLg6SZolkeJ3mgaKdWvxO0CKLyLH6XH3LROmsHI+BUb RkdHmi77mDf5DrQds11JOkvjCwSQmsIG2Vp4H1sps/biykra8cSM3uHzW0jQ0S/rR/91 c0sQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h27-v6si6262154pgh.245.2018.08.30.02.10.43; Thu, 30 Aug 2018 02:10:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727728AbeH3NLv (ORCPT + 2 others); Thu, 30 Aug 2018 09:11:51 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:11207 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727089AbeH3NLv (ORCPT ); Thu, 30 Aug 2018 09:11:51 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 41F4EEF2349F9; Thu, 30 Aug 2018 17:10:39 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.399.0; Thu, 30 Aug 2018 17:10:34 +0800 From: John Garry To: CC: , , , , , , , , , John Garry Subject: [PATCH v2] serial: 8250_of: Fix for lack of interrupt support Date: Thu, 30 Aug 2018 17:08:50 +0800 Message-ID: <1535620130-199328-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org In commit c58caaab3bf8 ("serial: 8250: of: Defer probe on missing IRQ"), a check was added for the UART driver being probed prior to the parent IRQ controller. Unfortunately this breaks certain boards which have no interrupt support, like Huawei D03. Indeed, the 8250 DT bindings state that interrupts should be supported - not must. To fix, switch from irq_of_parse_and_map() to of_irq_get(), which does relay whether the IRQ host controller domain is not ready, i.e. defer probe, instead of assuming it. Fixes: c58caaab3bf8 ("serial: 8250: of: Defer probe on missing IRQ") Signed-off-by: John Garry --- Change in v2: - fix check on irq value Note: I think that it would better if we could try to get the interrupt before clk+pm enabling, so we don't need to disable later when deferring, but this is not a fix. -- 1.9.1 Reviewed-by: Rob Herring diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index af8beef..877fd7f 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -58,7 +58,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev, struct resource resource; struct device_node *np = ofdev->dev.of_node; u32 clk, spd, prop; - int ret; + int ret, irq; memset(port, 0, sizeof *port); @@ -143,21 +143,27 @@ static int of_platform_serial_setup(struct platform_device *ofdev, if (ret >= 0) port->line = ret; - port->irq = irq_of_parse_and_map(np, 0); - if (!port->irq) { - ret = -EPROBE_DEFER; - goto err_unprepare; + irq = of_irq_get(np, 0); + if (irq < 0) { + if (irq == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto err_unprepare; + } + /* IRQ support not mandatory */ + irq = 0; } + port->irq = irq; + info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); if (IS_ERR(info->rst)) { ret = PTR_ERR(info->rst); - goto err_dispose; + goto err_unprepare; } ret = reset_control_deassert(info->rst); if (ret) - goto err_dispose; + goto err_unprepare; port->type = type; port->uartclk = clk; @@ -184,8 +190,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev, port->handle_irq = fsl8250_handle_irq; return 0; -err_dispose: - irq_dispose_mapping(port->irq); err_unprepare: clk_disable_unprepare(info->clk); err_pmruntime: