Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2281762pxb; Thu, 3 Feb 2022 03:24:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxknVEhalfZbrCsadbn2hXYn44H9Ud8b9FP38RUaBAvuW+2UcjKPEdmmEZTCJA/DG2PW8cd X-Received: by 2002:a17:90b:4a86:: with SMTP id lp6mr13418793pjb.152.1643887494246; Thu, 03 Feb 2022 03:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643887494; cv=none; d=google.com; s=arc-20160816; b=xCG1RjqtJeBH7bU32WryA+wvYx9NNWFwWHPWePO7847jWnZz9DIJ2g+fXU/PNO6eaF XftUwBd3ReQ3xRFPXjoKDk3QQD2pamMUPpy8sNC1MS2bRBx6ldYoZ5WJX3Op4kUzhnaf iiuKnc5om1m5TS6TF1Gs/Y/qEw/TScQ9rwwQ28c6lZhizG+79wdgc2ETKGPfbB7rq+pk noTcoGxprwr/b9n7hM1mORaEmqwshOKZzZYYX3/MqRhkQ32/qpde8TMXymDoFJ4avCxP gYv11jZuQI6xnkcyuDHpmWsi4HkbHSMzwzIKTlcChtRhTgCvonpsK9ZEvxlc955dVAuK bZ5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=iMY4xACVH1ZVzXNVrArRuI/nzp9/lpfiTMhEXpjkBcM=; b=mx35s8GAqPSAKJv8pxPxUjQPXTcj/RyTwEqY/TR7S6tCnBdpxMwpYspZDs1CcFLX4z 5sjShUapy2iqF76n1DZLeRkOR3HcJQOFbl/D4zYx/x4nwUrLOvuxCSoTPaz+QEGsdzzj 5S6BP1d/mluvIk6xtmehwQJc+ZfukVN/sfl7mh0f3zpBnpaOg4xfoH+t1JTTDiWRd14X oABZYBD4+2Q3PtT1ShaHaENdzGrlPF+SvZ6SBkFS6W8mHRUwJCV3Qyg/XmfD4GKtAo4F ZbBS+P2TKyQHVBVYy8rh7kXf+IimPOoX+NGeagOeiDbvhZCKwqEnf5W2LN9j7eOplIbA qRlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Igzek+jN; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14si22800815pgh.42.2022.02.03.03.24.37; Thu, 03 Feb 2022 03:24:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Igzek+jN; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238677AbiBCIQK (ORCPT + 72 others); Thu, 3 Feb 2022 03:16:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234443AbiBCIQK (ORCPT ); Thu, 3 Feb 2022 03:16:10 -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 4E3E5C061714 for ; Thu, 3 Feb 2022 00:16:09 -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 EA878617F0 for ; Thu, 3 Feb 2022 08:16:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEA0EC340E4; Thu, 3 Feb 2022 08:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643876168; bh=2vnm1AHkcWOA7A+zVzTxeHC8nUwJkepDiAdNzZnm5fY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Igzek+jNvDspq73TzovZUU2IGSaohBQxw+ezBLayf1PWArm1KeV+p+pC7iJNc7/ia RmVtaXavxR1PeGo06FnWR2xN94BM+cvf3nadd3UUCS7omYx9ZXOWGd1N/gmNMHsdyk onMQRACy4ZBB62ZdHildSEFlTq2vSbr61Cd0QJuXBSaJcasuQ17siaxK6EftUvppT8 zIlJTTrpYXkmg9m5vOY7Z5A36f4tIyJ4L6XdDbzf5HwMuYz5MTTxIYgOJn+5uPGlBR RU2IeQcK9hGKuEDnFTphfwXuedh5H8sqU9kzxHlkDCLTv9qes51byEC68C6zlm77wR AHCwX6BhH4IUg== From: Kalle Valo To: Luca Coelho Cc: linux-wireless@vger.kernel.org Subject: Re: [PATCH for v5.17 6/8] iwlwifi: mei: retry mapping the shared area References: <20220128123057.524038-1-luca@coelho.fi> Date: Thu, 03 Feb 2022 10:16:03 +0200 In-Reply-To: (Luca Coelho's message of "Fri, 28 Jan 2022 14:30:55 +0200") Message-ID: <87leyscqm4.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Luca Coelho writes: > From: Emmanuel Grumbach > > The shared area is a DMA memory allocated in the host and > mapped so that the host and the CSME firmware can > exchange data. It is mapped through a dedicated PCI device > that is driven by the mei bus driver. > > The bus driver is in charge of allocating and mapping this > memory. It also needs to configure the CSME firmware with > a specific set of commands, so that the CSME firmware will > know that this memory is meant to be used by its internal > WLAN module. > > For this, the CSME firmware first needs to completely > initialize its WLAN module and only then get the mapping > request. > > The problem is that the mei bus enumeration completes > before the WLAN is completely ready. This means that > the WLAN module's initialization is racing with iwlmei's > allocation and mapping flow. > > Testing showed a problem in resume flows where iwlmei > was too fast and the DMA mapping failed. > > Add a retry mechanism to make sure that we will succeed > to map the memory. > > Fixes: 2da4366f9e2c ("iwlwifi: mei: add the driver to allow cooperation with CSME") > Signed-off-by: Emmanuel Grumbach > Fixes: bcbddc4f9d02 ("iwlwifi: mei: wait before mapping the shared area") I'll move the latter Fixes before s-o-b tag. > - /* > - * The CSME firmware needs to boot the internal WLAN client. Wait here > - * so that the DMA map request will succeed. > - */ > - msleep(20); > + do { > + ret = iwl_mei_alloc_shared_mem(cldev); > + if (!ret) > + break; > + /* > + * The CSME firmware needs to boot the internal WLAN client. > + * This can take time in certain configurations (usually > + * upon resume and when the whole CSME firmware is shut down > + * during suspend). > + * > + * Wait a bit before retrying and hope we'll succeed next time. > + */ > > - ret = iwl_mei_alloc_shared_mem(cldev); > - if (ret) > + dev_dbg(&cldev->dev, > + "Couldn't allocate the shared memory: %d, attempt %d / %d\n", > + ret, alloc_retry, ALLOC_SHARED_MEM_RETRY_MAX_NUM); > + msleep(100); > + alloc_retry--; > + } while (alloc_retry); Nitpicking, but this could have been: while (alloc_retry--); But no need to resend because of this. -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches