Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2437380pxu; Sat, 28 Nov 2020 14:07:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuaZPba1mp1rmUMQypKRQIhDNPY3hssiK1AC2YjKA4JT3UwL+NkXZ+mITZ3oSMAbuAZPOH X-Received: by 2002:a17:907:447d:: with SMTP id oo21mr11791698ejb.367.1606601220111; Sat, 28 Nov 2020 14:07:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606601220; cv=none; d=google.com; s=arc-20160816; b=NNreTPNU9z3UAggBT4Ce7+CJQ0fKLKa0qJFFmbSeiAY/zSgvE8T3Gu+ezz9X2QAeeF Z18Fx3VAsAEv0M6jyANoxyRwYscT2Z7EwpYWhdzdlQvw5VJIg3XCOSEnjuRlFpVvECzK Rj3tF6IwO080UPc04IThRwQmktmVD2W7RVIJVOCE75PR37TDPStqIfTigwiubESB0fl+ GOAlzNbCnPkfMGX3Q3I121ENaFTjvziu3t+Ra5U9XcIdCIDjHS35L0yzPWkSbMT35rAF jLomND0MGJTV8s0Byy8yMCjYpbUpKqxM68eIC8X+FWz6+doRLvzE7OqwNFyDO2AkIRae T3SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dkZK75RDOqVvghIzMCSRWV8KKsXjayA5613tB1J4VCY=; b=gbFcPhdCyDLtn13Tb+OmYom9QNFt5e0ZST4yitDO5iLiK9TrfrvmO7SMEyM082cHZ1 1F2mib5voq2n2aG+1RcayTfJjHczXl/vDh7Nn0qpiW5Sf+LbAivxjlsCVKeCUkaSipLB +4xkoc0AymOUH1T/QDt3S3tFxpKz1f/IfFJUDj4fhSJUP7AkSuvFzM+OkCTSQcA931Mw qgQwZ+pWJVTR4VNBuTWbOkZ6Q7YJy6/KzntfWuRohYg84fuVwJceQLZkMowfNY5Cq5JQ 4ce5K6MeO2qOpq1o70r1KRg2stA2R4GjkIk+PEPf0M4FaRPBx01pw8+IR7hlw0M8N0LN vPpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cecqxIdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p62si8033704edd.213.2020.11.28.14.06.37; Sat, 28 Nov 2020 14:07:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cecqxIdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731247AbgK1Vud (ORCPT + 99 others); Sat, 28 Nov 2020 16:50:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733296AbgK1SRx (ORCPT ); Sat, 28 Nov 2020 13:17:53 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CFDCC0258DE; Sat, 28 Nov 2020 07:49:04 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id s63so6698201pgc.8; Sat, 28 Nov 2020 07:49:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dkZK75RDOqVvghIzMCSRWV8KKsXjayA5613tB1J4VCY=; b=cecqxIdtNnXvYHZvKvSn+cJXABfzKkTd/GDrzvYRbiHDb1BP6cgaR7272scbX2PZDc s66qMOjTi5VEweErH+bMB1Pj8cjOqt25SzDMIlrVeGTpanXxTB5mJgNvRvPP694wmVss qg7iiVp+pUApFLXHQwv4ryBbj9qKQwxt/B8Z+e/KKQJxs3lXn3gQEn07+vDXsFiGTPRI sRjHUmIRtEsC4mMUdZka+dgHGh7mVTPLsE/NLNEKybr2y6OnxMm7mTlJssmKQdqfRox5 oUdKAHsRIFzpD9vvII/060Sr2DeTQWOkGcNTyRCT8+AluWdxESQb3hETpkyh4XtkWtyE HKrA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=dkZK75RDOqVvghIzMCSRWV8KKsXjayA5613tB1J4VCY=; b=LixzY83ScElPUx+fjFaxjrup9IhUOmaxEe548wMseQA0+zhSbcsM0CzBBokWa2RsOR F9JyflgUFAtIn8z3rjJwd0XQMOpGrxz25VSP+NBdvhp/9M5Iq9av8Y7uFTgK345i675B /9mjqgK+K7tQ8kcA7aeWLhWvSSZtPplLF1AGKftRfCjJhX+YKPs+JsH4qZds+Lsh+5s5 X6uambP2skDksGmrQVveKhEGRexFRQ4DrGjkjcFFse7NR/zycdv1TJ4fgSYQKGZrSj19 EcWdaQ6zkO6RWhd8bHCwmTC796o5eFIexF2Y8yg95moyP4kgLHNg1ogEVrOpv3EDreIZ VahQ== X-Gm-Message-State: AOAM531DlqC2hk5o+ZeY/C1sflW1kjmrVw3V9lSaTosqlC3Q2QSrD7WA YOzBz1m/21SrLgxSH4XGvKQ= X-Received: by 2002:a17:90b:19cf:: with SMTP id nm15mr15844023pjb.63.1606578543746; Sat, 28 Nov 2020 07:49:03 -0800 (PST) Received: from localhost.localdomain ([161.81.68.216]) by smtp.gmail.com with ESMTPSA id r15sm15633028pjp.51.2020.11.28.07.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2020 07:49:03 -0800 (PST) From: Tom Yan To: hdegoede@redhat.com, hch@lst.de, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: mathias.nyman@intel.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, baolu.lu@linux.intel.com, Tom Yan Subject: [PATCH 1/2] uas: revert from scsi_add_host_with_dma() to scsi_add_host() Date: Sat, 28 Nov 2020 23:48:48 +0800 Message-Id: <20201128154849.3193-1-tom.ty89@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <09992cec-65e4-2757-aae6-8fb02a42f961@redhat.com> References: <09992cec-65e4-2757-aae6-8fb02a42f961@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apparently the former (with the chosen dma_dev) may cause problem in certain case (e.g. where thunderbolt dock and intel iommu are involved). The error observed was: XHCI swiotlb buffer is full / DMAR: Device bounce map failed For now we retain the clamp for hw_max_sectors against the dma_max_mapping_size. Since the device/size for the clamp that is applied when the scsi request queue is initialized/allocated is different than the one used here, we invalidate the early clamping by making a fallback blk_queue_max_hw_sectors() call. Signed-off-by: Tom Yan --- drivers/usb/storage/uas.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index c8a577309e8f..5db1325cea20 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -843,18 +843,21 @@ static int uas_slave_alloc(struct scsi_device *sdev) static int uas_slave_configure(struct scsi_device *sdev) { struct uas_dev_info *devinfo = sdev->hostdata; - struct device *dev = sdev->host->dma_dev; + struct usb_device *udev = devinfo->udev; if (devinfo->flags & US_FL_MAX_SECTORS_64) blk_queue_max_hw_sectors(sdev->request_queue, 64); else if (devinfo->flags & US_FL_MAX_SECTORS_240) blk_queue_max_hw_sectors(sdev->request_queue, 240); - else if (devinfo->udev->speed >= USB_SPEED_SUPER) + else if (udev->speed >= USB_SPEED_SUPER) blk_queue_max_hw_sectors(sdev->request_queue, 2048); + else + blk_queue_max_hw_sectors(sdev->request_queue, + SCSI_DEFAULT_MAX_SECTORS); blk_queue_max_hw_sectors(sdev->request_queue, min_t(size_t, queue_max_hw_sectors(sdev->request_queue), - dma_max_mapping_size(dev) >> SECTOR_SHIFT)); + dma_max_mapping_size(udev->bus->sysdev) >> SECTOR_SHIFT)); if (devinfo->flags & US_FL_NO_REPORT_OPCODES) sdev->no_report_opcodes = 1; @@ -1040,7 +1043,7 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) shost->can_queue = devinfo->qdepth - 2; usb_set_intfdata(intf, shost); - result = scsi_add_host_with_dma(shost, &intf->dev, udev->bus->sysdev); + result = scsi_add_host(shost, &intf->dev); if (result) goto free_streams; -- 2.29.2