Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3645392pxb; Mon, 24 Jan 2022 14:17:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoalMz9JxMQ25Ba/l2O0tNk5LXWNvp/zHN41FZAY5dhOtZj6XqC6MCI2VCqtiJMU4y03JN X-Received: by 2002:a63:4e24:: with SMTP id c36mr12970197pgb.499.1643062676640; Mon, 24 Jan 2022 14:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062676; cv=none; d=google.com; s=arc-20160816; b=lqTaiKcQe7v7JJRJiyqGNEDMNxVnRasZZLkXl73X4oVJd1pBS0NbnPBglsI57BRcXR F8t9RAphXj7DiNyxU5dzWjQbbQdjdk6IvTyGAYPphpyVWXKtBvF9H+fDsMCykgfrPASY n/PkEdZ8KPEVTFzCo9xbwaJ9O2+btty5+Slv+8Q/Z7CbeURxz9y4eDM6qbOe4z6Rk2rB 9MDsBWW56cvK5IFyJ+SVGDsDPxwvf+f5Fh8M5rDo92+bcz8atJqVDs84Hn7tj1gIHTO8 yImo4fQpp5adt0D4dTxWt+YLazhA9Px4ik2jxMF517Ua2NqetFW+V/OxPoA7EqVvkyTW 0v1w== 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=f1WTAMAa3XbwS+JUW63jaQIvyoK6nvVfYwNgo4PZZKg=; b=E5Rta3VuGQRcOpmH7zE9CvZGrtDi44nfexuyQ0T2kEQHo3tmIg8p8JmurhV3900/KO Gg77xnna2hmv4GNYVbs5qNv8NtBjB959aLtEGNIRXiFPg5+SOXJsqStslKlZ3GNRQTVQ JytIcH+ogKooVfFNw1ru71MO4RrbaVjfchIOkud8RpAhU1EWOfkFSm+9bWUw6Jp2JLyo XndsOVTzo6PTiTlbo/pDc+ibKH6nAyLo4ehxsN3P/nySJS54Los8vpYWaqsaJHTP8sJt kEEIsRN20TQRNgyelYjkC9GWeOK3sLK3EH0GPj0PBxM2kSWJcrVW3v5PxKid55ne+m8c 93HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vi6H6O2u; 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 n6si13784773pgp.485.2022.01.24.14.17.43; Mon, 24 Jan 2022 14:17:56 -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=vi6H6O2u; 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 S1346412AbiAXWMz (ORCPT + 99 others); Mon, 24 Jan 2022 17:12:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1450638AbiAXV3l (ORCPT ); Mon, 24 Jan 2022 16:29:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C358C0A8880; Mon, 24 Jan 2022 12:19:22 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id D80C061371; Mon, 24 Jan 2022 20:19:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8640C340E5; Mon, 24 Jan 2022 20:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055561; bh=hrXnK3lSnVgSWEh61IIYjmLnsYStkmB0E0ezQOBT4ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vi6H6O2uQEJVEFpsoze8Q38HOI7z7UBoZ34NAUOUHzhEKlXNZASFgBeFo1HksdFnV mlMS5yiu31mn83pPUfkDa6/BAHOesx81rlCmzCscJBZkLnw62hDKcZkWCS+Ni5JK3E 5xrKXfj4i2R8rADsKi4OjQ0zl36VlMl7nQhKuPK0= 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.15 192/846] serial: amba-pl011: do not request memory region twice Date: Mon, 24 Jan 2022 19:35:09 +0100 Message-Id: <20220124184107.573846609@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 52518a606c06a..b831d4d64c0a2 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2183,32 +2183,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); - } } /* @@ -2223,6 +2204,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; } @@ -2275,8 +2258,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 @@ -2306,8 +2287,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