From: Bert Kenward <bkenward@solarflare.com>
To: Sasha Levin <sashal@kernel.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Cc: Edward Cree <ecree@solarflare.com>,
"David S . Miller" <davem@davemloft.net>,
<netdev@vger.kernel.org>
Subject: Re: [PATCH AUTOSEL 3.18 12/16] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe
Date: Tue, 19 Feb 2019 09:22:19 +0000 [thread overview]
Message-ID: <33b60bdb-8336-7ac0-4795-8cb3ceac167c@solarflare.com> (raw)
In-Reply-To: <20190215021546.179605-12-sashal@kernel.org>
On 15/02/2019 02:15, Sasha Levin wrote:
> From: Edward Cree <ecree@solarflare.com>
>
> [ 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 <ecree@solarflare.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
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));
>
next prev parent reply other threads:[~2019-02-19 9:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 2:15 [PATCH AUTOSEL 3.18 01/16] drm/msm: Unblock writer if reader closes file Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 02/16] ASoC: Intel: Haswell/Broadwell: fix setting for .dynamic field Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 03/16] ALSA: compress: prevent potential divide by zero bugs Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 04/16] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 05/16] usb: gadget: Potential NULL dereference on allocation error Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 06/16] ASoC: imx-audmux: change snprintf to scnprintf for possible overflow Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 07/16] mac80211: fix miscounting of ttl-dropped frames Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 08/16] libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive() Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 09/16] serial: fsl_lpuart: fix maximum acceptable baud rate with over-sampling Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 10/16] scsi: csiostor: fix NULL pointer dereference in csio_vport_set_state() Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 11/16] net: altera_tse: fix connect_local_phy error path Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 12/16] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe Sasha Levin
2019-02-19 9:22 ` Bert Kenward [this message]
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 13/16] ibmveth: Do not process frames after calling napi_reschedule Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 14/16] mac80211: don't initiate TDLS connection if station is not associated to AP Sasha Levin
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 15/16] cfg80211: extend range deviation for DMG Sasha Levin
2019-02-15 12:31 ` Johannes Berg
2019-02-15 2:15 ` [PATCH AUTOSEL 3.18 16/16] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1 Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=33b60bdb-8336-7ac0-4795-8cb3ceac167c@solarflare.com \
--to=bkenward@solarflare.com \
--cc=davem@davemloft.net \
--cc=ecree@solarflare.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®