Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp493720lqb; Wed, 17 Apr 2024 02:35:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2sKSF4Q9J4Ggg3VLzbitSG0dJT0M5UI2glUuBF2Ay6U4R/YBwPgIotbcn4PSpvLaNQGLKvIXBn4LREmXoWzblK0hWcoEUvyURiIJKhQ== X-Google-Smtp-Source: AGHT+IFL0RGPjDBliJCirSsdl9DlQQOylRQElXApVeF1C1ztOXBpHCodKeD1zLPqKn2N5N2/0K16 X-Received: by 2002:a05:6214:3206:b0:69b:51d7:b97d with SMTP id qj6-20020a056214320600b0069b51d7b97dmr23384614qvb.0.1713346502820; Wed, 17 Apr 2024 02:35:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713346502; cv=pass; d=google.com; s=arc-20160816; b=CvbingvQQtPkJs2Fbus3qmD8HDVq7FLgjbi4PDjQ3FOXR1xZDXyoZbsi+trQvg9VVT tqcztC8WnqlbvUaVBO5M1DS2rr/mkb6b6k+fL2IyB+7U6OjmSArqJ4JkPa3a66GC8wgg 65qZ9q1R/KfgZPdpGIyVhRs/r+18lQbKgg0TUBddzeIIT/yxvMzNm3AAFbsRHeQmZ+IP nLjI/MvVb203fnzfWK/h5NVgk7Rzmjuv3XsMMcGR19g5tKBfO5L0XfxNEehnNulwGL2X lSP7b+rvSAneK9fnZ8xkwXnM0i9wbhL9ygW/UHkJApZR3dzeZcI+4kG535t0ICF/WqSa 9i1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=o2HMxMyBUkocSmEwLbQzJ8wYnRk7I7+CeeaeUnX21Gg=; fh=k15yWD4ZltoIGsKlbGcsGeIaHes0BFY8NEK3tQ/9pa0=; b=fFIGoWrCNLX7xb8stx08b699N/GVLU9xyXyUmE48KA9WguPVFNZ632aeLZWCbiHYFh MZw30yJCSN2TqtfxzD9ongM1P4DfuZ7M2fRSvbbZNe7Ft1IDap24R4ztV1Iaix2zE9Ys jIANtBqhl0p9aAYrNNbAegkApGPUjUgskbmZawu6FPiSs9x5Ddr6TwZUW4iZUbhVV4Eg EjS0fkSraT6HRrARNdkEEYL+gtnYhfWYfBWgmrQsCNJZT8JCCyC4hSHGTtimoFO1fhLZ YWUhE/5DGGvaorFq7IzE4p7znAIn0I6rGEm2AM6UY3UxsgwOh+tgy5uRHy9ekj/RKu2f nHyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="mMvunL/u"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-wireless+bounces-6435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 3-20020a0562140dc300b0069eb725bf87si4113223qvt.158.2024.04.17.02.35.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:35:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="mMvunL/u"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-wireless+bounces-6435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 64E621C217C9 for ; Wed, 17 Apr 2024 09:35:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60AAB13AD22; Wed, 17 Apr 2024 09:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="mMvunL/u" X-Original-To: linux-wireless@vger.kernel.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5462213328A; Wed, 17 Apr 2024 09:34:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346464; cv=none; b=oD2eid9jXCki6HwWYLvoYrblog5Fq2PpE6rPknrOUjqqSVkm2/q+XMlIaa48TXzNcIxUaA0m+44HJMK23giyHxlL+aYRgINH2g8CBxHsCja0jd8E7Eas4Sxn7ZRYSfzF9zA1FSkPpR+DfGAHFA7yh62viaAJpWAKjP7vqSmnpFs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346464; c=relaxed/simple; bh=OPIN8Oscgip6y7sWgfOIst8fCpHSWskiwXQR9mF0fbs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eii8i7tmsvt7zNVeF3Y5EWjVoqHcECLKw2gkLMSoTeySSjjyIjJhmW4Z6TrNSAO/VAA/sDDWD4elOx2sHIV5oejSLFhBHyGQtMvQGuuJuiLPKw3T2rpfXopUjfk+RhC+oATACZov9BQo8OD0vjNA0NLHWkPc5NeBEiCBV9XKRYI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=mMvunL/u; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id E79DEFF80A; Wed, 17 Apr 2024 09:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713346455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o2HMxMyBUkocSmEwLbQzJ8wYnRk7I7+CeeaeUnX21Gg=; b=mMvunL/uLZ3ybm/BwSxNaOAGaljDD6RHCijtR0UXA8ivFIykX99BI9ke6/qKnm+86oa8LG Wg5S1FeG5Lh74597eIhLHTzSfKuBI1W6WGkKb9LYO95qpIcTlXOmVQOvtuex0SGNZ2Cgoc 7juxQ7/tMLqVudE0jip3p5guC6MQbAwCadOnOKFbeboKSuMt+vM8mvBZPxGzSwlFcMyaxf 0uwdeWbT4vPDGlphPdsJUMK09XOVyL34FuXG8uC07Cp1pGp0CK1fzKjOLoIbIHUj4du5y7 lvujVuul4+6hvo8S3G2BjPcs1SLsU5IqYgJGg7k1/07T5/kGC6C6SsRbWokFwQ== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Wed, 17 Apr 2024 11:34:09 +0200 Subject: [PATCH 2/6] wifi: wilc1000: register net device only after bus being fully initialized Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240417-mac_addr_at_probe-v1-2-67d6c9b3bc2b@bootlin.com> References: <20240417-mac_addr_at_probe-v1-0-67d6c9b3bc2b@bootlin.com> In-Reply-To: <20240417-mac_addr_at_probe-v1-0-67d6c9b3bc2b@bootlin.com> To: Ajay Singh , Claudiu Beznea , Kalle Valo Cc: Thomas Petazzoni , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com SDIO/SPI probes functions automatically add a default wlan interface on top of registered wiphy, through wilc_cfg80211_init which in turn calls wilc_netdev_ifc_init. However, bus is still not fully initialized when we register corresponding net device (for example we still miss some private driver data pointers), which for example makes it impossible to retrieve MAC address from chip (which is supposed to be set on net device before its registration) before registering net device. More generally, net device registration should not be done until driver has fully initialized everything and is ready to handle any operation on the net device. Prevent net device from being registered so early by doing it at the end of probe functions. Apply this logic to both sdio and spi buses. Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 10 ---------- drivers/net/wireless/microchip/wilc1000/sdio.c | 14 ++++++++++++-- drivers/net/wireless/microchip/wilc1000/spi.c | 11 +++++++++-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c index 7d9fb9f2d527..f716981f62ad 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1773,7 +1773,6 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, const struct wilc_hif_func *ops) { struct wilc *wl; - struct wilc_vif *vif; int ret, i; wl = wilc_create_wiphy(dev); @@ -1802,18 +1801,9 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, ret = -ENOMEM; goto free_cfg; } - vif = wilc_netdev_ifc_init(wl, "wlan%d", WILC_STATION_MODE, - NL80211_IFTYPE_STATION, false); - if (IS_ERR(vif)) { - ret = PTR_ERR(vif); - goto free_hq; - } return 0; -free_hq: - destroy_workqueue(wl->hif_workqueue); - free_cfg: wilc_wlan_cfg_deinit(wl); diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index 52a770c5e76f..a841dad08410 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -136,9 +136,11 @@ static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd) static int wilc_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { + struct wilc_sdio *sdio_priv; + struct wilc_vif *vif; struct wilc *wilc; int ret; - struct wilc_sdio *sdio_priv; + sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL); if (!sdio_priv) @@ -176,9 +178,17 @@ static int wilc_sdio_probe(struct sdio_func *func, } clk_prepare_enable(wilc->rtc_clk); + vif = wilc_netdev_ifc_init(wilc, "wlan%d", WILC_STATION_MODE, + NL80211_IFTYPE_STATION, false); + if (IS_ERR(vif)) { + ret = PTR_ERR(vif); + goto clk_disable_unprepare; + } + dev_info(&func->dev, "Driver Initializing success\n"); return 0; - +clk_disable_unprepare: + clk_disable_unprepare(wilc->rtc_clk); dispose_irq: irq_dispose_mapping(wilc->dev_irq_num); wilc_netdev_cleanup(wilc); diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c index 61c3572ce321..add0e70a09ea 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -206,9 +206,10 @@ static void wilc_wlan_power(struct wilc *wilc, bool on) static int wilc_bus_probe(struct spi_device *spi) { - int ret; - struct wilc *wilc; struct wilc_spi *spi_priv; + struct wilc_vif *vif; + struct wilc *wilc; + int ret; spi_priv = kzalloc(sizeof(*spi_priv), GFP_KERNEL); if (!spi_priv) @@ -250,6 +251,12 @@ static int wilc_bus_probe(struct spi_device *spi) goto power_down; wilc_wlan_power(wilc, false); + vif = wilc_netdev_ifc_init(wilc, "wlan%d", WILC_STATION_MODE, + NL80211_IFTYPE_STATION, false); + if (IS_ERR(vif)) { + ret = PTR_ERR(vif); + goto power_down; + } return 0; power_down: -- 2.44.0