Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3580930pxb; Mon, 24 Jan 2022 12:44:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAKwhmMH8fEW5atvTF29aiKdUWh2EIE2vHdeygUz15lxnTk1A8jb9uuUlbU5l3mxGkszt3 X-Received: by 2002:a17:903:110c:b0:149:8018:e9d4 with SMTP id n12-20020a170903110c00b001498018e9d4mr15509290plh.117.1643057060065; Mon, 24 Jan 2022 12:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057060; cv=none; d=google.com; s=arc-20160816; b=IPAK8moOHyD76h5zO0BwbkPnh+dPRDgF2WzQ3zOV+kwC3Y2mFlYu9SYeawTkCn/98y hUV5XUgscQcmAv8IIT7bp2KXDqIOEfsfoVzzcv26Of/vJELjtv1C5UbMcjCYbv60pcvX Vqbqt3BTqafWiJZKzovMCemv27IFfURFrT7UgWSPKNuRDUXRR9H1D7XYh2IARsGyqXnB V/6vyyUk/9y5S3zwq8VsLLHXADV193iJlVl46OjdrwSnFwyCNANJUzFGqA7gBTBjfSe+ i/8kRTiqIUo03uiIuq8uMn9dI8sJauIcJlPTPF8e4/z8MBBCduMtUvO7YV3uwIVBvxaj +ZaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bID/Kpp6iBmhnqc8qlxnZ3Xg9lvnaqrpfwixxIkMGNg=; b=E5WI+VTAPeoyyo3hvCBsdfC2VquZ30KFe2VDow4SbPT7vO/SYMF2zfKGNgXbjrKvhx 41GBE+B71cjrGhRVlpkf8fwfk2GXnEIwD9WhBsh2H6A/cnBEs5bj60zOEv5cTk262rn9 Y/LfWq/ECbKOJ61dF1UWY3C5T4DHlumlqspKB99Acd4afgkHfYGVuxi2iWB1v6fy+QAW 40vFNqGjD/YuC9sFIU6H7QCP9/9vOCFWf3/zYR3p/nedA7qfC6ZnCpdbZ7V6ZV8vRMqA PDi8zekqGNwnuYu5+U8vVg3DpPUJBeTyGyZ2NRMywyNLkYkkHv+R1EzPWDsk0VoiiV8L b3cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B5171Y+6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h126si13875135pgc.42.2022.01.24.12.44.03; Mon, 24 Jan 2022 12:44:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B5171Y+6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359771AbiAXUCc (ORCPT + 99 others); Mon, 24 Jan 2022 15:02:32 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:52022 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351979AbiAXT3Z (ORCPT ); Mon, 24 Jan 2022 14:29:25 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 390DFB81215; Mon, 24 Jan 2022 19:29:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EE1DC340E8; Mon, 24 Jan 2022 19:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052561; bh=24dK8aJynKW8UzRARZZ9LbUpGPtlKnYUFP2ad0kgR6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B5171Y+625JkClYzYTXaRyQ8sBAP6hwT3oaobyt4pz+VQ3hLiEBPeQEsrgEEIRxbk mCktEIcbjwLEVQ+duoXmVyH3tMMkFUo45pKB3j6i2nLvb6H6MRwHE734qdKD3BQO7B NZzdwymd8j1Xcxa8TmmwFCCa10YcZIFCuTCJ+cWQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lino Sanfilippo , Sasha Levin Subject: [PATCH 5.4 067/320] serial: amba-pl011: do not request memory region twice Date: Mon, 24 Jan 2022 19:40:51 +0100 Message-Id: <20220124183956.008990956@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lino Sanfilippo [ Upstream commit d1180405c7b5c7a1c6bde79d5fc24fe931430737 ] With commit 3873e2d7f63a ("drivers: PL011: refactor pl011_probe()") the function devm_ioremap() called from pl011_setup_port() was replaced with devm_ioremap_resource(). Since this function not only remaps but also requests the ports io memory region it now collides with the .config_port() callback which requests the same region at uart port registration. Since devm_ioremap_resource() already claims the memory successfully, the request in .config_port() fails. Later at uart port deregistration the attempt to release the unclaimed memory also fails. The failure results in a “Trying to free nonexistent resource" warning. Fix these issues by removing the callbacks that implement the redundant memory allocation/release. Also make sure that changing the drivers io memory base address via TIOCSSERIAL is not allowed any more. Fixes: 3873e2d7f63a ("drivers: PL011: refactor pl011_probe()") Signed-off-by: Lino Sanfilippo Link: https://lore.kernel.org/r/20211129174238.8333-1-LinoSanfilippo@gmx.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/amba-pl011.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 6741d0f3daf94..0bd8c05d72d60 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2094,32 +2094,13 @@ static const char *pl011_type(struct uart_port *port) return uap->port.type == PORT_AMBA ? uap->type : NULL; } -/* - * Release the memory region(s) being used by 'port' - */ -static void pl011_release_port(struct uart_port *port) -{ - release_mem_region(port->mapbase, SZ_4K); -} - -/* - * Request the memory region(s) being used by 'port' - */ -static int pl011_request_port(struct uart_port *port) -{ - return request_mem_region(port->mapbase, SZ_4K, "uart-pl011") - != NULL ? 0 : -EBUSY; -} - /* * Configure/autoconfigure the port. */ static void pl011_config_port(struct uart_port *port, int flags) { - if (flags & UART_CONFIG_TYPE) { + if (flags & UART_CONFIG_TYPE) port->type = PORT_AMBA; - pl011_request_port(port); - } } /* @@ -2134,6 +2115,8 @@ static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser) ret = -EINVAL; if (ser->baud_base < 9600) ret = -EINVAL; + if (port->mapbase != (unsigned long) ser->iomem_base) + ret = -EINVAL; return ret; } @@ -2151,8 +2134,6 @@ static const struct uart_ops amba_pl011_pops = { .flush_buffer = pl011_dma_flush_buffer, .set_termios = pl011_set_termios, .type = pl011_type, - .release_port = pl011_release_port, - .request_port = pl011_request_port, .config_port = pl011_config_port, .verify_port = pl011_verify_port, #ifdef CONFIG_CONSOLE_POLL @@ -2182,8 +2163,6 @@ static const struct uart_ops sbsa_uart_pops = { .shutdown = sbsa_uart_shutdown, .set_termios = sbsa_uart_set_termios, .type = pl011_type, - .release_port = pl011_release_port, - .request_port = pl011_request_port, .config_port = pl011_config_port, .verify_port = pl011_verify_port, #ifdef CONFIG_CONSOLE_POLL -- 2.34.1