From patchwork Wed Jul 24 19:21:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 169673 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11170600ilk; Wed, 24 Jul 2019 22:46:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjUk16rEHdrBRdDkF3XDOBZC0HK29ZUHoKAMaQIBocCROg9+D7mCjERthBfbJ2ocTFqce0 X-Received: by 2002:a63:f50d:: with SMTP id w13mr84566752pgh.411.1564033590896; Wed, 24 Jul 2019 22:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033590; cv=none; d=google.com; s=arc-20160816; b=qxVND85XBfjdLVsEW+PF00dJTHlf8XabaIaLb/YncythAsMpZsf/0D75iw7ltBJvbD AYK74aI/e9LecZnEtzwMSO4/UjS60NKa+XFVwf0awE7rHkn8zSJ25wiQafmVP2L7sk5T 4HAjbDwVN2T/oziSMv6Vgx65AK0DyVFA1aLYuZh+ff2E6g1gzZ2x855705R42A3fpxIZ meDaM188Mp7F0QWHm0hOBIts+TsYpVjgk4I42ee2R6t7qFwDNpkqaFvOlo0rh17Esam9 /d50maSE760Jw/JKjP5n+R8eeIVhgS1ubxuOI4+++HqS8Z4fwMG8DMaKV5RE4I2hvd8j sI8w== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0/UKbwIuFHQ3mfCpX6ILnCubS1oqmLxYvgFQLsm0+9c=; b=zD1beqM1upFYVBhoMu5OoyUrAtg5qMjXF+3qj5vH/9NYeEGLuDxVxORCFprb88YJdB jMzpPP9bc6qpGiKjh3+OjNgGTeoeAEe4UQtZuIDt/tlVuOQMRu+5GnaZJR4AgaQyPjLR Sf1G03Nmw+jOIz23s+sh8UGP3IlohNNRrBcPFAq6P2O6KNvVdz+AHMYMjb2BRgvl+a5O +z2VTm0Y+XXikMu+D7dP9bDl4EwcKAAsJTw/12UltIlElFdHQblteCrP6KMXqqO4RolL UMaL8uHhRno00LG4WG3hjkbfoxpshadMVg22bcILtJnRMHeU7d4rGJr/3PfEI6IK7gOm HCZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mDHn7Uqd; 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 l143si15839593pfd.162.2019.07.24.22.46.30; Wed, 24 Jul 2019 22:46:30 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=mDHn7Uqd; 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 S2391432AbfGYFq3 (ORCPT + 29 others); Thu, 25 Jul 2019 01:46:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:33940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388195AbfGYFqW (ORCPT ); Thu, 25 Jul 2019 01:46:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 79CBC22C7C; Thu, 25 Jul 2019 05:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033581; bh=Di+Vnnjcv2z3OJWnd6Bl1AN461okmRL8JV+YUHzutw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mDHn7Uqdz9LxiaV+bsdKqNgBMKfgwe1HB2Mnpj2ZelZwlBqQtFXKoduCSqLyPsUzq gKASt8+3GPcniJH0QaIRcQvWzKFSDqXnAIhPyV7TURoGP4Kf5dspHHV+yJSxfTbQMl ObGkfn3pCAlqVufMoc+1TLAtZLA+5Ru80TyCG3pQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Joonas_Kylm=C3=A4l=C3=A4?= , Masahiro Yamada Subject: [PATCH 4.19 216/271] kconfig: fix missing choice values in auto.conf Date: Wed, 24 Jul 2019 21:21:25 +0200 Message-Id: <20190724191713.598185041@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada commit 8e2442a5f86e1f77b86401fce274a7f622740bc4 upstream. Since commit 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing"), Kconfig creates include/config/auto.conf in the defconfig stage when it is missing. Joonas Kylmälä reported incorrect auto.conf generation under some circumstances. To reproduce it, apply the following diff: | --- a/arch/arm/configs/imx_v6_v7_defconfig | +++ b/arch/arm/configs/imx_v6_v7_defconfig | @@ -345,14 +345,7 @@ CONFIG_USB_CONFIGFS_F_MIDI=y | CONFIG_USB_CONFIGFS_F_HID=y | CONFIG_USB_CONFIGFS_F_UVC=y | CONFIG_USB_CONFIGFS_F_PRINTER=y | -CONFIG_USB_ZERO=m | -CONFIG_USB_AUDIO=m | -CONFIG_USB_ETH=m | -CONFIG_USB_G_NCM=m | -CONFIG_USB_GADGETFS=m | -CONFIG_USB_FUNCTIONFS=m | -CONFIG_USB_MASS_STORAGE=m | -CONFIG_USB_G_SERIAL=m | +CONFIG_USB_FUNCTIONFS=y | CONFIG_MMC=y | CONFIG_MMC_SDHCI=y | CONFIG_MMC_SDHCI_PLTFM=y And then, run: $ make ARCH=arm mrproper imx_v6_v7_defconfig You will see CONFIG_USB_FUNCTIONFS=y is correctly contained in the .config, but not in the auto.conf. Please note drivers/usb/gadget/legacy/Kconfig is included from a choice block in drivers/usb/gadget/Kconfig. So USB_FUNCTIONFS is a choice value. This is probably a similar situation described in commit beaaddb62540 ("kconfig: tests: test defconfig when two choices interact"). When sym_calc_choice() is called, the choice symbol forgets the SYMBOL_DEF_USER unless all of its choice values are explicitly set by the user. The choice symbol is given just one chance to recall it because set_all_choice_values() is called if SYMBOL_NEED_SET_CHOICE_VALUES is set. When sym_calc_choice() is called again, the choice symbol forgets it forever, since SYMBOL_NEED_SET_CHOICE_VALUES is a one-time aid. Hence, we cannot call sym_clear_all_valid() again and again. It is crazy to repeat set and unset of internal flags. However, we cannot simply get rid of "sym->flags &= flags | ~SYMBOL_DEF_USER;" Doing so would re-introduce the problem solved by commit 5d09598d488f ("kconfig: fix new choices being skipped upon config update"). To work around the issue, conf_write_autoconf() stopped calling sym_clear_all_valid(). conf_write() must be changed accordingly. Currently, it clears SYMBOL_WRITE after the symbol is written into the .config file. This is needed to prevent it from writing the same symbol multiple times in case the symbol is declared in two or more locations. I added the new flag SYMBOL_WRITTEN, to track the symbols that have been written. Anyway, this is a cheesy workaround in order to suppress the issue as far as defconfig is concerned. Handling of choices is totally broken. sym_clear_all_valid() is called every time a user touches a symbol from the GUI interface. To reproduce it, just add a new symbol drivers/usb/gadget/legacy/Kconfig, then touch around unrelated symbols from menuconfig. USB_FUNCTIONFS will disappear from the .config file. I added the Fixes tag since it is more fatal than before. But, this has been broken since long long time before, and still it is. We should take a closer look to fix this correctly somehow. Fixes: 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing") Cc: linux-stable # 4.19+ Reported-by: Joonas Kylmälä Signed-off-by: Masahiro Yamada Tested-by: Joonas Kylmälä Signed-off-by: Greg Kroah-Hartman --- scripts/kconfig/confdata.c | 7 +++---- scripts/kconfig/expr.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -834,11 +834,12 @@ int conf_write(const char *name) "#\n" "# %s\n" "#\n", str); - } else if (!(sym->flags & SYMBOL_CHOICE)) { + } else if (!(sym->flags & SYMBOL_CHOICE) && + !(sym->flags & SYMBOL_WRITTEN)) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE)) goto next; - sym->flags &= ~SYMBOL_WRITE; + sym->flags |= SYMBOL_WRITTEN; conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } @@ -1024,8 +1025,6 @@ int conf_write_autoconf(int overwrite) if (!overwrite && is_present(autoconf_name)) return 0; - sym_clear_all_valid(); - conf_write_dep("include/config/auto.conf.cmd"); if (conf_split_config()) --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -141,6 +141,7 @@ struct symbol { #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400 /* ? */ +#define SYMBOL_WRITTEN 0x0800 /* track info to avoid double-write to .config */ #define SYMBOL_NO_WRITE 0x1000 /* Symbol for internal use only; it will not be written */ #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ #define SYMBOL_WARNED 0x8000 /* warning has been issued */ From patchwork Wed Jul 24 19:21:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 169671 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11169314ilk; Wed, 24 Jul 2019 22:45:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhAHCzZo+fQZL2jdsWgcz7kghuCJTZYp6dKLLyGkx7wXbkZE4OC8mwDXqJYkZGVY3GOoeZ X-Received: by 2002:a62:ae02:: with SMTP id q2mr14544108pff.1.1564033509126; Wed, 24 Jul 2019 22:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033509; cv=none; d=google.com; s=arc-20160816; b=TwtdL/miJplaZZlgh/jWpKLbMHMb7iT3StlUA8gX9lln8w0joMGm9WQ2JTMpG+Gs0r zLg6QUR049vKdSaSISx/QPp+ioB5biP8VV4Ngb4A136XX0i0XX2yGOyEtxDDw5V4Gutc Rgtht1FGfFOOPKMsdY4DFeQPBZohxF2H5HMzewZU7eUN2EpJK2RrYItKKZiR+iDfoMHG vMolBJSI8qZTFuMWgCBIgti8Ci8DA3YW1OC4QdWrkddKHr8WhM0/T3IztOanZRYoFnGO gEr5enuJxrS1hkhCUc8cutGKKHj+m4D5uPWCzo8RgKiGoKTNS3PVZZqQGAqmEF1Of/ZN CUuA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ki+0q5T6jfoMGjMnsQGlnJ7pr0iqH5Nxbna9Rfk6Y7o=; b=MyeLadvrTwHIOwmJYsretngMqlUWnBgzijathQx0zd6W0lA/bSMSNqc81iYlOeU3r7 Ja/ZuP7MH5OdqIUC+Q7gNwn6FKVU2mk/zxDgZYANkNkwrG9SYJNsP3tin95k837ht09x fX8q7zq1y/k8fbZJAesrhNARjpuE6PqUoUjZhzxrdCmumiBYah60WtItexSnRRAH0ggl U2WAWm8gaT905z3Ux18SCEU9JB9ja/epkQukzELtOzjNESEb5HY1od/DbwiMTaXclIH6 sBzGYQbYM1h1d5W5NPr121l7HTU6xA4Aw9fYstO0oHsycgNumOSnl2ICc7EgzXkZ1jHW AbLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1t6jvnpV; 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 6si16647262pgt.13.2019.07.24.22.45.08; Wed, 24 Jul 2019 22:45:09 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=1t6jvnpV; 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 S2405103AbfGYFpH (ORCPT + 29 others); Thu, 25 Jul 2019 01:45:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:60452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405083AbfGYFpD (ORCPT ); Thu, 25 Jul 2019 01:45:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7866922CB8; Thu, 25 Jul 2019 05:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033503; bh=hdPiwWOIh86sapnLw0u7XiSoH7Kj3zi5jtTPZLDP9H0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1t6jvnpVxzGIRwt2wJYbSmBcqdB0wPhGqZudihKryKeEKUD8/vVY2JFXlr/jPecYM ZgfiUCIZAEPDHTO9/EFJILfnaVcD9nnrV6nBarxVj1kh/enCb7nw/47NzTtg94alAd SbIfGFn5yScJ0tmXOoH7GokS29aZ4CH2WE1yO/9Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , Lorenzo Pieralisi , Stanimir Varbanov Subject: [PATCH 4.19 231/271] PCI: qcom: Ensure that PERST is asserted for at least 100 ms Date: Wed, 24 Jul 2019 21:21:40 +0200 Message-Id: <20190724191714.957798561@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niklas Cassel commit 64adde31c8e996a6db6f7a1a4131180e363aa9f2 upstream. Currently, there is only a 1 ms sleep after asserting PERST. Reading the datasheets for different endpoints, some require PERST to be asserted for 10 ms in order for the endpoint to perform a reset, others require it to be asserted for 50 ms. Several SoCs using this driver uses PCIe Mini Card, where we don't know what endpoint will be plugged in. The PCI Express Card Electromechanical Specification r2.0, section 2.2, "PERST# Signal" specifies: "On power up, the deassertion of PERST# is delayed 100 ms (TPVPERL) from the power rails achieving specified operating limits." Add a sleep of 100 ms before deasserting PERST, in order to ensure that we are compliant with the spec. Fixes: 82a823833f4e ("PCI: qcom: Add Qualcomm PCIe controller driver") Signed-off-by: Niklas Cassel Signed-off-by: Lorenzo Pieralisi Acked-by: Stanimir Varbanov Cc: stable@vger.kernel.org # 4.5+ Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/dwc/pcie-qcom.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -178,6 +178,8 @@ static void qcom_ep_reset_assert(struct static void qcom_ep_reset_deassert(struct qcom_pcie *pcie) { + /* Ensure that PERST has been asserted for at least 100 ms */ + msleep(100); gpiod_set_value_cansleep(pcie->reset, 0); usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500); } From patchwork Wed Jul 24 19:22:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 169672 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11170425ilk; Wed, 24 Jul 2019 22:46:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVAOWWoNxr/3yCUXCrRHOK1i9MCEG6mqrXwIZTE6mzz2qw+dsuhZ+hml0sIy27ialWG5A+ X-Received: by 2002:a17:902:383:: with SMTP id d3mr4890242pld.176.1564033579153; Wed, 24 Jul 2019 22:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033579; cv=none; d=google.com; s=arc-20160816; b=CEStvRS2QRv5D0sI+i3pl6M1B1p1pPisPKQ/5zgXnYACOaratveDQPBH09vw56SONg 3MYaoVaRRb8ZfUDvl9PSM7WXDNetQhnITbqYvaLHEph266Oki/A1WGaMDvNa7Exk6NXk cczOeQbURBNSVm+V4saR3wY1ZSoj1bo/saQRZ1262T7If4HvdhbDKyxt84ppaYYHP2Z+ 0yzdqiTWMVJeCtkKT4QfpLGszi9Xwpor6QIGBCX8GxfDTHMX3NyzLIB73d56S01EQ/vT 8gREmqpamyL+dUm7IE7vGXMuAPb2ua4B33c11h9E6HKDkxgFdHCBKbE7IzDpmOdXUUA7 t1Jw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T3yUoNXfQ/JigsL48Nzd3QQu4Xas+AFqHbvXfeL6tOg=; b=S3F7/hcdGJdk9kqevM4nnjerHg9Eok2+kfBxgpHofU25bD++BZfMeCTy10Yz/mq0yY b5HR0y8d6RfcK7Cj4dagc/+i3VWV7d0nY1oE++710cRwtBFZtzhDXDP71Rc+jzItZn9C CrNynpXSdlnlQ8LKd6QMXX2xlwKik3u3f6B96rKbDM/4Iqps1wjkIFL8rFiYxoPm8z4b Cg+2hrVC31VdAjfIHJhY/Y+4Vak0PJj3pQmCDlgw7aRXUQmIFrb1mfbuV/0xRIL2cxyo 47l/jx/eiFh+CRnHuGXvNXaAqGdcw3Jq2uNzwGXxeLxhF5A4Q11pkfjOX8US/B/knVxa RP1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hjOPIiu0; 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 s17si15115181pjq.35.2019.07.24.22.46.18; Wed, 24 Jul 2019 22:46:19 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=hjOPIiu0; 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 S1726941AbfGYFqR (ORCPT + 29 others); Thu, 25 Jul 2019 01:46:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:33742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405324AbfGYFqO (ORCPT ); Thu, 25 Jul 2019 01:46:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85DEF21880; Thu, 25 Jul 2019 05:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033573; bh=mCR6aN+uceSECLUj63ofoTuojhqSJs4eio7FLW/vthU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjOPIiu09eoVIvEWB7Nss+AKOb7EsyCwV+a2hrubsTIhREx/pWCeXGEKT+hKkimR4 iV+7S9AnZYwSGIPJxsZFke8giBCtapty3zlAz/Uv/jlFQNrNg6S1eJRF3v0Agf+7vx tHjf/AyfO9Ftk+8mUBzJM5XYPvoTTESdxDfhHITE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horia Geanta , Iuliana Prodan , Sascha Hauer , Ard Biesheuvel , Herbert Xu Subject: [PATCH 4.19 252/271] crypto: caam - limit output IV to CBC to work around CTR mode DMA issue Date: Wed, 24 Jul 2019 21:22:01 +0200 Message-Id: <20190724191716.805830869@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit ed527b13d800dd515a9e6c582f0a73eca65b2e1b upstream. The CAAM driver currently violates an undocumented and slightly controversial requirement imposed by the crypto stack that a buffer referred to by the request structure via its virtual address may not be modified while any scatterlists passed via the same request structure are mapped for inbound DMA. This may result in errors like alg: aead: decryption failed on test 1 for gcm_base(ctr-aes-caam,ghash-generic): ret=74 alg: aead: Failed to load transform for gcm(aes): -2 on non-cache coherent systems, due to the fact that the GCM driver passes an IV buffer by virtual address which shares a cacheline with the auth_tag buffer passed via a scatterlist, resulting in corruption of the auth_tag when the IV is updated while the DMA mapping is live. Since the IV that is returned to the caller is only valid for CBC mode, and given that the in-kernel users of CBC (such as CTS) don't trigger the same issue as the GCM driver, let's just disable the output IV generation for all modes except CBC for the time being. Fixes: 854b06f76879 ("crypto: caam - properly set IV after {en,de}crypt") Cc: Horia Geanta Cc: Iuliana Prodan Reported-by: Sascha Hauer Cc: Signed-off-by: Ard Biesheuvel Reviewed-by: Horia Geanta Signed-off-by: Herbert Xu [ Horia: backported to 4.14, 4.19 ] Signed-off-by: Horia Geantă Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/caam/caamalg.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -887,6 +887,7 @@ static void ablkcipher_encrypt_done(stru struct ablkcipher_request *req = context; struct ablkcipher_edesc *edesc; struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req); + struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher); int ivsize = crypto_ablkcipher_ivsize(ablkcipher); #ifdef DEBUG @@ -911,10 +912,11 @@ static void ablkcipher_encrypt_done(stru /* * The crypto API expects us to set the IV (req->info) to the last - * ciphertext block. This is used e.g. by the CTS mode. + * ciphertext block when running in CBC mode. */ - scatterwalk_map_and_copy(req->info, req->dst, req->nbytes - ivsize, - ivsize, 0); + if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC) + scatterwalk_map_and_copy(req->info, req->dst, req->nbytes - + ivsize, ivsize, 0); /* In case initial IV was generated, copy it in GIVCIPHER request */ if (edesc->iv_dir == DMA_FROM_DEVICE) { @@ -1651,10 +1653,11 @@ static int ablkcipher_decrypt(struct abl /* * The crypto API expects us to set the IV (req->info) to the last - * ciphertext block. + * ciphertext block when running in CBC mode. */ - scatterwalk_map_and_copy(req->info, req->src, req->nbytes - ivsize, - ivsize, 0); + if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC) + scatterwalk_map_and_copy(req->info, req->src, req->nbytes - + ivsize, ivsize, 0); /* Create and submit job descriptor*/ init_ablkcipher_job(ctx->sh_desc_dec, ctx->sh_desc_dec_dma, edesc, req); From patchwork Wed Jul 24 19:22:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 169674 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11171676ilk; Wed, 24 Jul 2019 22:47:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUw/bwMrcc/uw4JdJiZiCAF8/r5NfI2laQOGVKT9+YYRdyXv3ohKRqELkpQNnp2mZ3X/LS X-Received: by 2002:a17:90a:2567:: with SMTP id j94mr91570638pje.121.1564033658569; Wed, 24 Jul 2019 22:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033658; cv=none; d=google.com; s=arc-20160816; b=Vvvbrq4tHE5mVisac6oY5sBwIIn4tr41g1PRkAjkqwkyZoe4Tmhie+oKs4tynumkDs co8NNYLNAS8a6PuwMc8tUhxkX6vF4AaH6ggq0T7Ao0KTlGZ2Vbj9FEWjkHHghlNL0uqe wIKjekNR5TYqj9a5EnNpFvOFELs00nwFSyLAel+RxJgAKUhZxXjfqgQlOVJaVAthn6eb mcLs4VjtmO/e8GlO2t9yvL6zIvK85M2CmT3V6nloIuhzATOvc1VXzqZYSp4yIdrf1V6n yCqyDxgjsUOQ4gYAqvrjB9jqhP/12+3vOOLi7yQ7wEaz91OfPIfyiE0bGj5fr/NMxWMn tPuQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7FEIjxLsonkDGUEnOWJyr6o80UBaHfel/kIvXaV6MBo=; b=kaJ5RD9sE5VFkqxcOx5i4VEWsWtFa8XTRRMs6ysDMkfj06Cpu7iyuykU1EQESsNSMK hV4+iaLZajBVuOI+nu86wqHdMujPMxBaZGP+f9Ayu4xxElA8B6Pn9FDskHovhZWxOud1 96TonLsmmDNOyDzQSw88zUlnPdNjMLtSs8wtK/LAugWedRxcggdGlRz6olhDLxZCJ+SZ NNXkRj+2XM11TTbv1MKK90cxvderHPNJvS8j+0Lyf22IcCYu2XEqTwkOlfJAWcF4Iat7 W5bXj3Vjib/bRAmPn4d8QicbBBpfllwz85v7MA9naWXyl5oBypXK538xNqrLRdqa+6+J Ujgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ex5yMJoP; 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 e62si19551031pfh.254.2019.07.24.22.47.38; Wed, 24 Jul 2019 22:47:38 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Ex5yMJoP; 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 S2391540AbfGYFrS (ORCPT + 29 others); Thu, 25 Jul 2019 01:47:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:35186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387418AbfGYFrO (ORCPT ); Thu, 25 Jul 2019 01:47:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E1C62075C; Thu, 25 Jul 2019 05:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033633; bh=CRk2HNBwf8Mi7dbxwlf+qzdPfG7rOllCSitcokskcfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ex5yMJoPuRthf/Ij/oNnMVcTZisVKDOsSyVYGI5RfgW+kvqRDmzuBKntZmnqsDjpL q9FdTtjD5Dx4X9/8BtJyBUr8sMycErR0rZpt5JdPCkBFsu7FnoEnLzz82RbTZk6kMs JZCEPcrauLvqjLE/bbBbmBPIfjI9jkgbOrZWjupA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jorge Ramirez-Ortiz , Bjorn Andersson , Vinod Koul , Adrian Hunter , Ulf Hansson Subject: [PATCH 4.19 259/271] mmc: sdhci-msm: fix mutex while in spinlock Date: Wed, 24 Jul 2019 21:22:08 +0200 Message-Id: <20190724191717.395301959@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jorge Ramirez-Ortiz commit 5e6b6651d22de109ebf48ca00d0373bc2c0cc080 upstream. mutexes can sleep and therefore should not be taken while holding a spinlock. move clk_get_rate (can sleep) outside the spinlock protected region. Fixes: 83736352e0ca ("mmc: sdhci-msm: Update DLL reset sequence") Cc: stable@vger.kernel.org Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Bjorn Andersson Reviewed-by: Vinod Koul Acked-by: Adrian Hunter Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-msm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -582,11 +582,14 @@ static int msm_init_cm_dll(struct sdhci_ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); int wait_cnt = 50; - unsigned long flags; + unsigned long flags, xo_clk = 0; u32 config; const struct sdhci_msm_offset *msm_offset = msm_host->offset; + if (msm_host->use_14lpp_dll_reset && !IS_ERR_OR_NULL(msm_host->xo_clk)) + xo_clk = clk_get_rate(msm_host->xo_clk); + spin_lock_irqsave(&host->lock, flags); /* @@ -634,10 +637,10 @@ static int msm_init_cm_dll(struct sdhci_ config &= CORE_FLL_CYCLE_CNT; if (config) mclk_freq = DIV_ROUND_CLOSEST_ULL((host->clock * 8), - clk_get_rate(msm_host->xo_clk)); + xo_clk); else mclk_freq = DIV_ROUND_CLOSEST_ULL((host->clock * 4), - clk_get_rate(msm_host->xo_clk)); + xo_clk); config = readl_relaxed(host->ioaddr + msm_offset->core_dll_config_2);