Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2659275pxj; Mon, 14 Jun 2021 04:15:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW6051x2tjr2vA+QW1wBybOTmNxOF/iJgi8EBl5hQr5GUYVFsGBPd9HJ8l4g/XdVCTkpJl X-Received: by 2002:aa7:d34a:: with SMTP id m10mr16524683edr.57.1623669322888; Mon, 14 Jun 2021 04:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669322; cv=none; d=google.com; s=arc-20160816; b=WisRUQRYyZNJiIdSg4HQy/PwGOE+bWePhes+aPtsO8/YZhc3HZHhHfYaihwTGxpxJw dlx7bWZMs1zY0NuBfZhvD+bTgdp1mbn/KQ6XeyfZ41s1l2ixYn5adp9U5V9an9YYxr8b lVL8OYl8mOsJnqjBkYjxznhebVZRi5f3PRLdPHoI655to3K5GhZMuq7reGX5AFvv6Tfi TiEV8vh+u2GfqxDZD5jbEsTtmgWiUmumbTDAR6pte35VMlw8fkycn9X2BJFW13voCr8O 3ywBZvH/EMdTyjJPmIr9BpgaDy0nQB9PGP5sljSBlo2vz6Pjb1wK7KxMglQGRhvy8FSA UIIQ== 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=nxSjuOi5wu5Muv0cx5BHCS5Oz6MhPPeLF7MW1jYnFdc=; b=YsBulE11A8ib2mCRHZiHABHhltKTXF8cCgrr4gkphq2wUnJVg+ZrzYLB+DAgrNFOsv 4cV4hwV2wUq+V5AVG+PsGwzFM0GYuBLL85woThwHiwx5xaB2y6iaf3YlGQcp9uimFwPp UXWqkF3OXLeCpME0k3y1T1q6vBQNDXy7V+yKrb3OyvO7LrhriErkWxXAAS+RdzsiktqY h/GOpjzHfKdgEr6X0TINQWt9aA5DpCv0O1bzqFN8ExtIyimMpkmSMjDS0MhAWBbAq7/J 76IXtylipkU3RR4ykjvcKErYIKHNkmQGspxKbfduiOvEs84TcMzifq0E4uxEVc82CgUp bLcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="j4J/GydK"; 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 dg2si10308139edb.424.2021.06.14.04.15.00; Mon, 14 Jun 2021 04:15:22 -0700 (PDT) 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="j4J/GydK"; 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 S234234AbhFNLPj (ORCPT + 99 others); Mon, 14 Jun 2021 07:15:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:36098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234657AbhFNLCl (ORCPT ); Mon, 14 Jun 2021 07:02:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 597B661883; Mon, 14 Jun 2021 10:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667438; bh=ZcfdP4wZpIkbwOWLzuaTBwIoeeY2OSRxS/uPiLlq+MI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j4J/GydKwOyA4a+rtFLz9xxrTZJBjkqq2jgcIpJP3ISreTBF+VKTZhrjuqgHuCEVy Ccsm8c9nW2AwJEg69b77qtDWPg2ItCFjfIQQ7rU5BRZ+CWzwbGIRj5kmOFtqsfZhnk DYT7Upfpb8fp+YboY9LZ6cxVjUVGispt83gM/Yfs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Blumenstingl , Neil Armstrong Subject: [PATCH 5.10 070/131] usb: dwc3-meson-g12a: fix usb2 PHY glue init when phy0 is disabled Date: Mon, 14 Jun 2021 12:27:11 +0200 Message-Id: <20210614102655.412498127@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@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: Neil Armstrong commit 4d2aa178d2ad2fb156711113790dde13e9aa2376 upstream. When only PHY1 is used (for example on Odroid-HC4), the regmap init code uses the usb2 ports when doesn't initialize the PHY1 regmap entry. This fixes: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 ... pc : regmap_update_bits_base+0x40/0xa0 lr : dwc3_meson_g12a_usb2_init_phy+0x4c/0xf8 ... Call trace: regmap_update_bits_base+0x40/0xa0 dwc3_meson_g12a_usb2_init_phy+0x4c/0xf8 dwc3_meson_g12a_usb2_init+0x7c/0xc8 dwc3_meson_g12a_usb_init+0x28/0x48 dwc3_meson_g12a_probe+0x298/0x540 platform_probe+0x70/0xe0 really_probe+0xf0/0x4d8 driver_probe_device+0xfc/0x168 ... Fixes: 013af227f58a97 ("usb: dwc3: meson-g12a: handle the phy and glue registers separately") Reviewed-by: Martin Blumenstingl Signed-off-by: Neil Armstrong Cc: stable Link: https://lore.kernel.org/r/20210601084830.260196-1-narmstrong@baylibre.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/dwc3-meson-g12a.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -651,7 +651,7 @@ static int dwc3_meson_g12a_setup_regmaps return PTR_ERR(priv->usb_glue_regmap); /* Create a regmap for each USB2 PHY control register set */ - for (i = 0; i < priv->usb2_ports; i++) { + for (i = 0; i < priv->drvdata->num_phys; i++) { struct regmap_config u2p_regmap_config = { .reg_bits = 8, .val_bits = 32, @@ -659,6 +659,9 @@ static int dwc3_meson_g12a_setup_regmaps .max_register = U2P_R1, }; + if (!strstr(priv->drvdata->phy_names[i], "usb2")) + continue; + u2p_regmap_config.name = devm_kasprintf(priv->dev, GFP_KERNEL, "u2p-%d", i); if (!u2p_regmap_config.name)