Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752494AbbHEPLx (ORCPT ); Wed, 5 Aug 2015 11:11:53 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:35434 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657AbbHEPLv (ORCPT ); Wed, 5 Aug 2015 11:11:51 -0400 Subject: [RFC] sdhci: fix DMA leaks [was: [SHDCI] Heavy (thousands) DMA leaks] To: Chen Bough , Ulf Hansson References: <55B9EF02.7040404@suse.cz> <55BF36D6.4080504@suse.cz> <55C1F919.4080002@suse.cz> Cc: "linux-mmc@vger.kernel.org" , Linux kernel mailing list From: Jiri Slaby Message-ID: <55C227B4.3030102@suse.cz> Date: Wed, 5 Aug 2015 17:11:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55C1F919.4080002@suse.cz> Content-Type: multipart/mixed; boundary="------------020103000507070906010301" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9927 Lines: 160 This is a multi-part message in MIME format. --------------020103000507070906010301 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 08/05/2015, 01:52 PM, Jiri Slaby wrote: >> Yes, I see: >> sdhci-pci 0000:02:00.0: swiotlb buffer is full (sz: 65536 bytes) >> after some time. The driver falls back to non-DMA transfers after that. >> It also generates a warning about that: >> WARNING: CPU: 0 PID: 0 at drivers/mmc/host/sdhci.c:857 >> sdhci_prepare_data+0x8ec/0x900 [sdhci]() > > I am attaching a debug patch and a debug log. You can see where > 0x00000000fffb0000 and 0x00000000fffe0000 is leaked. It is when 'invalid > cookie' error happens. And you could see the cookie handling is totally bogus. With this rewrite, I no longer see the problems. Could you confirm it still does the good job with respect to performance -- the numbers you mentioned in your commit. Ulf, what do you think about the attached patch? (Do not look at the commented info prints.) thanks, -- js suse labs --------------020103000507070906010301 Content-Type: application/mbox; name="fix.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="fix.patch" ZGlmZiAtLWdpdCBhL2RyaXZlcnMvbW1jL2hvc3Qvc2RoY2kuYyBiL2RyaXZlcnMvbW1jL2hv c3Qvc2RoY2kuYwppbmRleCAxZGJlOTMyMzIwMzAuLjFmMjhmYWFiOTkxMyAxMDA2NDQKLS0t IGEvZHJpdmVycy9tbWMvaG9zdC9zZGhjaS5jCisrKyBiL2RyaXZlcnMvbW1jL2hvc3Qvc2Ro Y2kuYwpAQCAtNDUsNiArNDUsMTIgQEAKIAogI2RlZmluZSBNQVhfVFVOSU5HX0xPT1AgNDAK IAorZW51bSBzZGhjaV9jb29raWUgeworCUNPT0tJRV9VTk1BUFBFRCwKKwlDT09LSUVfTUFQ UEVELAorCUNPT0tJRV9HSVZFTiwKK307CisKIHN0YXRpYyB1bnNpZ25lZCBpbnQgZGVidWdf cXVpcmtzID0gMDsKIHN0YXRpYyB1bnNpZ25lZCBpbnQgZGVidWdfcXVpcmtzMjsKIApAQCAt NTQsOCArNjAsNyBAQCBzdGF0aWMgdm9pZCBzZGhjaV9maW5pc2hfY29tbWFuZChzdHJ1Y3Qg c2RoY2lfaG9zdCAqKTsKIHN0YXRpYyBpbnQgc2RoY2lfZXhlY3V0ZV90dW5pbmcoc3RydWN0 IG1tY19ob3N0ICptbWMsIHUzMiBvcGNvZGUpOwogc3RhdGljIHZvaWQgc2RoY2lfZW5hYmxl X3ByZXNldF92YWx1ZShzdHJ1Y3Qgc2RoY2lfaG9zdCAqaG9zdCwgYm9vbCBlbmFibGUpOwog c3RhdGljIGludCBzZGhjaV9wcmVfZG1hX3RyYW5zZmVyKHN0cnVjdCBzZGhjaV9ob3N0ICpo b3N0LAotCQkJCQlzdHJ1Y3QgbW1jX2RhdGEgKmRhdGEsCi0JCQkJCXN0cnVjdCBzZGhjaV9o b3N0X25leHQgKm5leHQpOworCQkJCQlz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z dXBwb3J0ZWQuCmRpZmYgLS1naXQgYS9kcml2ZXJzL21tYy9ob3N0L3NkaGNpLmggYi9kcml2 ZXJzL21tYy9ob3N0L3NkaGNpLmgKaW5kZXggNTUyMWQyOTM2OGU0Li5iNThmMjI2MDBiMTEg MTAwNjQ0Ci0tLSBhL2RyaXZlcnMvbW1jL2hvc3Qvc2RoY2kuaAorKysgYi9kcml2ZXJzL21t Yy9ob3N0L3NkaGNpLmgKQEAgLTMwOSwxMSArMzA5LDYgQEAgc3RydWN0IHNkaGNpX2FkbWEy XzY0X2Rlc2MgewogICovCiAjZGVmaW5lIFNESENJX01BWF9TRUdTCQkxMjgKIAotc3RydWN0 IHNkaGNpX2hvc3RfbmV4dCB7Ci0JdW5zaWduZWQgaW50CXNnX2NvdW50OwotCXMzMgkJY29v a2llOwotfTsKLQogc3RydWN0IHNkaGNpX2hvc3QgewogCS8qIERhdGEgc2V0IGJ5IGhhcmR3 YXJlIGludGVyZmFjZSBkcml2ZXIgKi8KIAljb25zdCBjaGFyICpod19uYW1lOwkvKiBIYXJk d2FyZSBidXMgbmFtZSAqLwpAQCAtNTAzLDcgKzQ5OCw2IEBAIHN0cnVjdCBzZGhjaV9ob3N0 IHsKIAl1bnNpZ25lZCBpbnQJCXR1bmluZ19tb2RlOwkvKiBSZS10dW5pbmcgbW9kZSBzdXBw b3J0ZWQgYnkgaG9zdCAqLwogI2RlZmluZSBTREhDSV9UVU5JTkdfTU9ERV8xCTAKIAotCXN0 cnVjdCBzZGhjaV9ob3N0X25leHQJbmV4dF9kYXRhOwogCXVuc2lnbmVkIGxvbmcgcHJpdmF0 ZVswXSBfX19fY2FjaGVsaW5lX2FsaWduZWQ7CiB9OwogCg== --------------020103000507070906010301-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/