From patchwork Thu Jul 14 11:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 12917723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F214C433EF for ; Thu, 14 Jul 2022 11:23:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238706AbiGNLXI (ORCPT ); Thu, 14 Jul 2022 07:23:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238707AbiGNLWu (ORCPT ); Thu, 14 Jul 2022 07:22:50 -0400 Received: from sinsgout.his.huawei.com (sinsgout.his.huawei.com [119.8.179.247]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE9FB558C8; Thu, 14 Jul 2022 04:22:37 -0700 (PDT) Received: from sinmsgout03.his.huawei.com (unknown [172.28.115.130]) by sinsgout.his.huawei.com (SkyGuard) with ESMTP id 4LkBt164VLz5Rt2W; Thu, 14 Jul 2022 19:22:33 +0800 (CST) Received: from fraeml735-chm.china.huawei.com (unknown [172.18.156.148]) by sinmsgout03.his.huawei.com (SkyGuard) with ESMTP id 4LkBrf1MBCz9xGQ7; Thu, 14 Jul 2022 19:21:22 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml735-chm.china.huawei.com (10.206.15.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Jul 2022 13:22:26 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Jul 2022 12:22:22 +0100 From: John Garry To: , , , , , , , CC: , , , , , , John Garry Subject: [PATCH v6 6/6] ata: libata-scsi: Cap ata_device->max_sectors according to shost->max_sectors Date: Thu, 14 Jul 2022 19:15:29 +0800 Message-ID: <1657797329-98541-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1657797329-98541-1-git-send-email-john.garry@huawei.com> References: <1657797329-98541-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org ATA devices (struct ata_device) have a max_sectors field which is configured internally in libata. This is then used to (re)configure the associated sdev request queue max_sectors value from how it is earlier set in __scsi_init_queue(). In __scsi_init_queue() the max_sectors value is set according to shost limits, which includes host DMA mapping limits. Cap the ata_device max_sectors according to shost->max_sectors to respect this shost limit. Signed-off-by: John Garry Acked-by: Damien Le Moal Acked-by: Martin K. Petersen --- drivers/ata/libata-scsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 86dbb1cdfabd..24a43d540d9f 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1060,6 +1060,7 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) dev->flags |= ATA_DFLAG_NO_UNLOAD; /* configure max sectors */ + dev->max_sectors = min(dev->max_sectors, sdev->host->max_sectors); blk_queue_max_hw_sectors(q, dev->max_sectors); if (dev->class == ATA_DEV_ATAPI) {