From patchwork Tue Aug 27 08:10:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172269 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp5452746ily; Tue, 27 Aug 2019 01:10:56 -0700 (PDT) X-Received: by 2002:a19:5218:: with SMTP id m24mr13788357lfb.164.1566893456577; Tue, 27 Aug 2019 01:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893456; cv=none; d=google.com; s=arc-20160816; b=R1Fs6Le5oYCiwIrKV1j+3NnCpDJrLVzWS/IiQ3Lf918S8qjFNyJQ6X0/dNncBhEfmT 0E6v0XnpOARCLvniN/WVZCe/mxI3OLI+DHkRPQABxswCm3c9alPjgvJ7U1/R93nLBuu8 iA3Fe2zCSeaU6vqK55mX6bXnheJwktcJqPhWsWX9WQuiRBhZaWw//RJheS9hMsqmlq50 eQhzZuPpZxLMUHeBExybvIPz1baa5OFzCpne/s6kbLkkd2gwoAgbn0g0aTU32DAcPkFF VXGjEEgary8GC7R3XT/+E3hOwDpeFyDhaahgmCC3HGxVupzhM9U/6oDfo7iXtC4oSQ9+ csCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=3qJR3eEbPiVz2FmPYzrydbvTqAWbk/i6kmfbf4e8EHY=; b=dJQcZuOxPG4cAEN7dzLcDO57bhqRTDRD7ilAAD4rtlMyfdgaLaUo5xg+LAayA4lJfW x9TcmSUXH2CTogurA8dJLhnjXAh5LJuegbhLRYzrOdHJ96KO8rFLEBzNzR0fBv5zijkv MCm1gQpGEHDDuI/plTvjo4gMkXcCyvUow3AA4Ww8DRQ2t8mr4AHa9zzh9FuZ8xQPnLW3 MCWySxP1f8NwZWNYJ1Raen788b2wS4dcZnaoWpZkdtBsDFa8aWtEwur44fuXnz5IGR9S ivbDpsd9C0AA20IKLekFnPUVLJn1WayGSMMrsLOVhz1DJBq92+uhmjA+qV5fSfhAWyNQ SUaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H+4s7dvO; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s6sor6477043ljg.41.2019.08.27.01.10.56 for (Google Transport Security); Tue, 27 Aug 2019 01:10:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H+4s7dvO; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3qJR3eEbPiVz2FmPYzrydbvTqAWbk/i6kmfbf4e8EHY=; b=H+4s7dvOeTvfYb55PRAH5Y5ZCJygQG/+kqSWkCuD033l49fUNYRFbCDQpudfRST/kq 3MHjCMIkI4SFayn4WqxvDP9zZ2RN0ND5N62qYl9ZhLpb8LHQGVRUvw5RzKlnMbnedFe3 PZUBEWOrebrs7Y+Hgl3c8GOD+wPorNsxtKA1fvgaq5CAPexwHdNddc/brDaA3k4Lh9j/ HSvxbP5ZbDa9s7S+9w26ifrBZZioCaas1MwzR/knXIBBwjTTjsTgFq0Wkc6vCxeK6aH9 Q/ohGfy0alTHZpjHpBLBuYoe1ZBLTLQYv+eG2JvIwkj4yJ1j4SN418JQtWRPLYyNmuH0 xIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3qJR3eEbPiVz2FmPYzrydbvTqAWbk/i6kmfbf4e8EHY=; b=hy2fUORV2OkXbQVkAfkiOAqUAQ8cDWO2hBG9V6Dl3QoRqq9imOVToDMoTDZlApHxVx Z/o/Tndu9ER78Lf1jlN5cWzxkVPztlliqDlsJF/btnRL29MyVfFt/UYsIDZCM92a5uqT KFSJrtreR3DQaKQvqVM0vwRxlEoLXpTNGQ1hIqrD8Hla2mSp2Ewf4IvZ2Z2MSDPDcaID 5DcrSN9S3DimKxHphm/5yfuX41pZe8cuIYZcQI5JLXfl9wrbARvZE3dQNkelu6NUR2r2 NRvcltmmuyv0rrI5jkQul9KLrsGMQ5b75jzpYBDSADk5/NuO3zOthXJWTsnSVOTfU9Ow DtHw== X-Gm-Message-State: APjAAAWpSXzYji9DTZS2b6pz9DyQuz6RWcp5tE1TdTgxwd5G7Q+n2fQh hW5YmHar9E1YUdix2b5opc281jrUL+CIcA== X-Google-Smtp-Source: APXvYqwyKOIvWgGr3RxKI7Y+eCD9AFakDDHYYy4/gF1Ke3Idl9WgYlkpcfYEjNsDxF4x2MBARyow2g== X-Received: by 2002:a05:651c:153:: with SMTP id c19mr13031829ljd.152.1566893455891; Tue, 27 Aug 2019 01:10:55 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id o20sm2373942ljg.31.2019.08.27.01.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:10:55 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Philip Langdale Cc: stable@vger.kernel.org Subject: [PATCH] mmc: core: Fix init of SD cards reporting an invalid VDD range Date: Tue, 27 Aug 2019 10:10:43 +0200 Message-Id: <20190827081043.15443-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 The OCR register defines the supported range of VDD voltages for SD cards. However, it has turned out that some SD cards reports an invalid voltage range, for example having bit7 set. When a host supports MMC_CAP2_FULL_PWR_CYCLE and some of the voltages from the invalid VDD range, this triggers the core to run a power cycle of the card to try to initialize it at the lowest common supported voltage. Obviously this fails, since the card can't support it. Let's fix this problem, by clearing invalid bits from the read OCR register for SD cards, before proceeding with the VDD voltage negotiation. Cc: stable@vger.kernel.org Reported-by: Philip Langdale Signed-off-by: Ulf Hansson --- drivers/mmc/core/sd.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 Reviewed-by: Philip Langdale diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index d681e8aaca83..fe914ff5f5d6 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1292,6 +1292,12 @@ int mmc_attach_sd(struct mmc_host *host) goto err; } + /* + * Some SD cards claims an out of spec VDD voltage range. Let's treat + * these bits as being in-valid and especially also bit7. + */ + ocr &= ~0x7FFF; + rocr = mmc_select_voltage(host, ocr); /*