Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3332513imj; Tue, 19 Feb 2019 01:24:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IauP+lxvCMUyAYAixhTUgli0JZ5fXBzsHVQvzBMFdLw16AZ7pRCT2UIFSES0YvfYhOEnN0C X-Received: by 2002:a63:2bc6:: with SMTP id r189mr22556909pgr.201.1550568291215; Tue, 19 Feb 2019 01:24:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568291; cv=none; d=google.com; s=arc-20160816; b=ol+Cgxey7o0wX0a3Cp/LCSNz3230obluGjNh2gEkP6VBr52ZPYmkuQMxWjgU+2OpNu gnYafxQOvP0J5WnSWuStrZDHoShy/1fEPpsSJchJEniIy/fWPbYwZPzQJs/8LuhAeFMk W9WdY46+r9k2kaCvnDhu1ntVL3Ty+RJzAmJoH+/oz18QsfaQm9Eia2AkTe+YqfR3EgNs XO85Xw0Oj0I2QibxLnOU69cEQaA5DYNSNZnq3Z6mIAGTdjLh7Pp1FgxsDhdZGrby9pql p4shTyMIJNnrlBOsbudxqco6Gh+2yLaaOWKyzDak+UpLPOG9KRlTWik0XQNbensIeTXl LvGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=2FLtFcjIIK2xLjBEyP/pTqaNZHAhsrDXN/UCTzIRei8=; b=fSItF1sxAjoaY9NWWuaX0N+WETQFpHq2A/+F5oxe2fJ/vmJYi9zBY9C2jr9c3SgScw 1u+F5hiysnBRpfOhg6irB8UiH9Q8GISxu5E6DkXWsEtmG0shs7fmBBfNDnje7bFrocjT lh4Npv9lMa6WWMuUKMb54fGtzh3DPPMA7QcQy6kmvYJ6QtD5OEVImr3dO1x0piB2sk9G nirXHT8xKvQl6Uqukb6TSeUHgUWCYEeXkL9vILLcJWw7nGyKTQvrDAD03uVuilvRxpdh k+zIBlPrQxkefQjKm7VXwprIF7B8xioPI0ndf2mL931zons1xd6fFlcJqYEUgllHFPHR +l4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k194si8272629pgc.94.2019.02.19.01.24.36; Tue, 19 Feb 2019 01:24:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728136AbfBSJWa (ORCPT + 99 others); Tue, 19 Feb 2019 04:22:30 -0500 Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.164]:48768 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727961AbfBSJWa (ORCPT ); Tue, 19 Feb 2019 04:22:30 -0500 X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id C5D1EB00067; Tue, 19 Feb 2019 09:22:28 +0000 (UTC) Received: from hgk-desktop.uk.solarflarecom.com (10.17.20.82) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 19 Feb 2019 09:22:23 +0000 Subject: Re: [PATCH AUTOSEL 3.18 12/16] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe To: Sasha Levin , , CC: Edward Cree , "David S . Miller" , References: <20190215021546.179605-1-sashal@kernel.org> <20190215021546.179605-12-sashal@kernel.org> From: Bert Kenward Message-ID: <33b60bdb-8336-7ac0-4795-8cb3ceac167c@solarflare.com> Date: Tue, 19 Feb 2019 09:22:19 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190215021546.179605-12-sashal@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.17.20.82] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24438.003 X-TM-AS-Result: No-12.197600-8.000000-10 X-TMASE-MatchedRID: L8tZF6zWW2oOwH4pD14DsPHkpkyUphL9UAjrAJWsTe91/q26L79bTIiL OGSrOVCj0/tq6TtYaL2C0c/BwxTs6eF7Pq0Toovm9UVHiwLx0/IoUVkB7ifJnlIEge/2lT8AiqO LrgHmwxVOFu8ssjxG81dTP5dw4GERSOWjYlTyoLGiAZ3zAhQYgpHUt5D5WmclJLfQYoCQHFbX/y R7HIDNarOT0m5mbI8apcCRA28drskZ7Eu9TqPx8J4CIKY/Hg3AtOt1ofVlaoLUHQeTVDUrItRnE QCUU+jz9xS3mVzWUuA152LecOHHI58gti1SV0NX9KrZ3KtM1PrbI0PAS1eQZU2j09lMnQLQ09mI 728lYDE= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--12.197600-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24438.003 X-MDID: 1550568149-yxAu7RJMKLbO Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/02/2019 02:15, Sasha Levin wrote: > From: Edward Cree > > [ Upstream commit 3366463513f544c12c6b88c13da4462ee9e7a1a1 ] > > Use a bitmap to keep track of which partition types we've already seen; > for duplicates, return -EEXIST from efx_ef10_mtd_probe_partition() and > thus skip adding that partition. > Duplicate partitions occur because of the A/B backup scheme used by newer > sfc NICs. Prior to this patch they cause sysfs_warn_dup errors because > they have the same name, causing us not to expose any MTDs at all. > > Signed-off-by: Edward Cree > Signed-off-by: David S. Miller > Signed-off-by: Sasha Levin I don't think this particularly needs to go to stable, but if it does it should be accompanied by: c65285428b6e ("sfc: initialise found bitmap in efx_ef10_mtd_probe") Bert. > --- > drivers/net/ethernet/sfc/ef10.c | 29 +++++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c > index 010009d64017..84a17b41313c 100644 > --- a/drivers/net/ethernet/sfc/ef10.c > +++ b/drivers/net/ethernet/sfc/ef10.c > @@ -3407,22 +3407,25 @@ static const struct efx_ef10_nvram_type_info efx_ef10_nvram_types[] = { > { NVRAM_PARTITION_TYPE_LICENSE, 0, 0, "sfc_license" }, > { NVRAM_PARTITION_TYPE_PHY_MIN, 0xff, 0, "sfc_phy_fw" }, > }; > +#define EF10_NVRAM_PARTITION_COUNT ARRAY_SIZE(efx_ef10_nvram_types) > > static int efx_ef10_mtd_probe_partition(struct efx_nic *efx, > struct efx_mcdi_mtd_partition *part, > - unsigned int type) > + unsigned int type, > + unsigned long *found) > { > MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_METADATA_IN_LEN); > MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_METADATA_OUT_LENMAX); > const struct efx_ef10_nvram_type_info *info; > size_t size, erase_size, outlen; > + int type_idx = 0; > bool protected; > int rc; > > - for (info = efx_ef10_nvram_types; ; info++) { > - if (info == > - efx_ef10_nvram_types + ARRAY_SIZE(efx_ef10_nvram_types)) > + for (type_idx = 0; ; type_idx++) { > + if (type_idx == EF10_NVRAM_PARTITION_COUNT) > return -ENODEV; > + info = efx_ef10_nvram_types + type_idx; > if ((type & ~info->type_mask) == info->type) > break; > } > @@ -3435,6 +3438,13 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx, > if (protected) > return -ENODEV; /* hide it */ > > + /* If we've already exposed a partition of this type, hide this > + * duplicate. All operations on MTDs are keyed by the type anyway, > + * so we can't act on the duplicate. > + */ > + if (__test_and_set_bit(type_idx, found)) > + return -EEXIST; > + > part->nvram_type = type; > > MCDI_SET_DWORD(inbuf, NVRAM_METADATA_IN_TYPE, type); > @@ -3463,6 +3473,7 @@ static int efx_ef10_mtd_probe_partition(struct efx_nic *efx, > static int efx_ef10_mtd_probe(struct efx_nic *efx) > { > MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX); > + DECLARE_BITMAP(found, EF10_NVRAM_PARTITION_COUNT); > struct efx_mcdi_mtd_partition *parts; > size_t outlen, n_parts_total, i, n_parts; > unsigned int type; > @@ -3491,11 +3502,13 @@ static int efx_ef10_mtd_probe(struct efx_nic *efx) > for (i = 0; i < n_parts_total; i++) { > type = MCDI_ARRAY_DWORD(outbuf, NVRAM_PARTITIONS_OUT_TYPE_ID, > i); > - rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type); > - if (rc == 0) > - n_parts++; > - else if (rc != -ENODEV) > + rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type, > + found); > + if (rc == -EEXIST || rc == -ENODEV) > + continue; > + if (rc) > goto fail; > + n_parts++; > } > > rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts)); >