From patchwork Sat Mar 2 00:15:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 777617 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8896883D for ; Sat, 2 Mar 2024 00:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338619; cv=none; b=ZJfJhl1uqyecmXz62cUWNPHia7jh36tMb/X/HogdjI7oFzSZs6ckOmnSaGOIEhjXzot0GxfZJfqyielbVPPgHAnCE4ewnRlAWivXotit3OphTpormB+obratpUcMl/Z+9AhAjn7klPWWpkYvqRPgwcle0ksk/p3QjQdGa54kfAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338619; c=relaxed/simple; bh=Dr1gHME6UhZzljl3CDtFvx0fMB3rr1EwYhk4f6Q7U3s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=q83xIlwMvI4DpIrBMXR9gjOwSAHEnuAmUOzQsDcpIYezJ6TIs6j6M+Oh4QubPjraP161r8Qm84SVRstMYYpMNnv1H11SlG/OHDxD216cTKB5oa7LgxHrapsxeRiGjD3CiLt3V1hCk0Yh2WHvXMnPl7wdymBjLry9+tY+Eyl/8cE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=INwPm8bn; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="INwPm8bn" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-60948e99cd4so40136977b3.1 for ; Fri, 01 Mar 2024 16:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709338616; x=1709943416; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=z4qRVCwUT6U2lE1it/3KAP9Dql1inh3yxdaUzH18pmU=; b=INwPm8bnvPkpvRrvkTM4Bblov2tYt9jMtyrcQhRMME/0Fz5GeeRBGncU9ZoF28hIuF 5DGNPwVvqhYp6t9zBgFcsuN0+xxWQYMhxze4ITYrtc2z5it9uWV7j3RGYCXhlPJkkOuH M+1shUfmIMPPQfRufboRWNyn4mLsKPzs/ScAtzHy19dCVr3az0hLlzLL41KuAmhwHOjP t1jVjfDGvVqV4QSGqmDtz8yVtrr357ydZN275emYt8bzfXymD50QNTwO11WRROLed5Uv 7UuFu9pLZD+bUyE8qknXj2flGc3wMLB4JIn5UYPo2u8oD8VhCVuaRkuGUbTS04jXNDYP VatA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709338616; x=1709943416; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z4qRVCwUT6U2lE1it/3KAP9Dql1inh3yxdaUzH18pmU=; b=hnAP14dFvMjYW1HG7OY9JzdR7QxSdSMINHfjo33Z5F01waXJOzAwPgnBd0DfnyB/6M k6qLJdCXS5LiYOpYjHSQw9bfRLjVraeHUZoy2NZddi7Pi3ySIquPmo6nCLPOjWzmBi97 ImCgu8YRYKFTBLcnNLX8syoyC67OCFaNs7CHqRIjs18v0R6tUqrMLGi18lxVwDyIqvzN Fc7iECWI/s/RnjpYkwfPzPZ5ta9BF2DZP/FKktU6RXOMwwLr0yAcB030TzqhHHPE41aT Oq6woTF8YiBGaz1LjZJhL0wJximdyozWkRWDo+p/zwKr1EbcJ8kFiwVUXrcdDeyT8Am6 neNw== X-Forwarded-Encrypted: i=1; AJvYcCWH1BmSRSTY0T4kcv3DhAG+RcnLLNAmfeptjOS1VT99sIhU+WCmA2sz8v49Ut4YGnyeTZwoilZPrZU8MvWn7Z4y7GZfgaQBOQYNOw== X-Gm-Message-State: AOJu0YyBaGPsHozLA+EXHHbflO+P/5jFeHzLZ1gTF3xyiTai7vWCRTi3 tU9ikGh+FLIVw4BWT6Wz+3Ng+7Zz6sIbaGRXzRXI4gEd50BG5qywGtY/leLPjRajdUDnI5nemWG 6fHcrM6SjQw== X-Google-Smtp-Source: AGHT+IECx6PpDaRn3lWCO4kqH6mkOTlKcZ2HgzcSoL7uxuJwnrYEOtuQSx0/r4Fj2I8xm3fPVt4EsAa7ObBmsQ== X-Received: from ipylypiv.svl.corp.google.com ([2620:15c:2c5:13:2afe:1a8e:f846:999f]) (user=ipylypiv job=sendgmr) by 2002:a05:690c:3612:b0:607:a30d:8cf with SMTP id ft18-20020a05690c361200b00607a30d08cfmr636509ywb.4.1709338615938; Fri, 01 Mar 2024 16:16:55 -0800 (PST) Date: Fri, 1 Mar 2024 16:15:58 -0800 In-Reply-To: <20240302001603.1012084-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302001603.1012084-1-ipylypiv@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240302001603.1012084-2-ipylypiv@google.com> Subject: [PATCH v2 1/5] ata: libata-sata: Factor out NCQ Priority configuration helpers From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Hannes Reinecke Cc: TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv Export libata NCQ Priority configuration helpers to be reused for libsas managed SATA devices. Signed-off-by: Igor Pylypiv --- drivers/ata/libata-sata.c | 139 +++++++++++++++++++++++++++----------- include/linux/libata.h | 4 ++ 2 files changed, 103 insertions(+), 40 deletions(-) diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c index 0fb1934875f2..a8d5e36d5211 100644 --- a/drivers/ata/libata-sata.c +++ b/drivers/ata/libata-sata.c @@ -848,29 +848,73 @@ DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, ata_scsi_lpm_show, ata_scsi_lpm_store); EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); +/** + * ata_ncq_prio_supported - Check if device supports NCQ Priority + * @ap: ATA port of the target device + * @sdev: SCSI device + * + * Helper to check if device supports NCQ Priority feature, + * usable with both libsas and libata. + */ +int ata_ncq_prio_supported(struct ata_port *ap, struct scsi_device *sdev) +{ + struct ata_device *dev; + unsigned long flags; + int rc; + + spin_lock_irqsave(ap->lock, flags); + dev = ata_scsi_find_dev(ap, sdev); + if (!dev) + rc = -ENODEV; + else + rc = !!(dev->flags & ATA_DFLAG_NCQ_PRIO); + spin_unlock_irqrestore(ap->lock, flags); + return rc; +} +EXPORT_SYMBOL_GPL(ata_ncq_prio_supported); + static ssize_t ata_ncq_prio_supported_show(struct device *device, struct device_attribute *attr, char *buf) { struct scsi_device *sdev = to_scsi_device(device); struct ata_port *ap = ata_shost_to_port(sdev->host); + int rc; + + rc = ata_ncq_prio_supported(ap, sdev); + if (rc < 0) + return rc; + + return sysfs_emit(buf, "%d\n", rc); +} + +DEVICE_ATTR(ncq_prio_supported, S_IRUGO, ata_ncq_prio_supported_show, NULL); +EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_supported); + +/** + * ata_ncq_prio_enabled - Check if NCQ Priority is enabled + * @ap: ATA port of the target device + * @sdev: SCSI device + * + * Helper to check if NCQ Priority feature is enabled, + * usable with both libsas and libata. + */ +int ata_ncq_prio_enabled(struct ata_port *ap, struct scsi_device *sdev) +{ struct ata_device *dev; - bool ncq_prio_supported; - int rc = 0; + unsigned long flags; + int rc; - spin_lock_irq(ap->lock); + spin_lock_irqsave(ap->lock, flags); dev = ata_scsi_find_dev(ap, sdev); if (!dev) rc = -ENODEV; else - ncq_prio_supported = dev->flags & ATA_DFLAG_NCQ_PRIO; - spin_unlock_irq(ap->lock); - - return rc ? rc : sysfs_emit(buf, "%u\n", ncq_prio_supported); + rc = !!(dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLED); + spin_unlock_irqrestore(ap->lock, flags); + return rc; } - -DEVICE_ATTR(ncq_prio_supported, S_IRUGO, ata_ncq_prio_supported_show, NULL); -EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_supported); +EXPORT_SYMBOL_GPL(ata_ncq_prio_enabled); static ssize_t ata_ncq_prio_enable_show(struct device *device, struct device_attribute *attr, @@ -878,50 +922,45 @@ static ssize_t ata_ncq_prio_enable_show(struct device *device, { struct scsi_device *sdev = to_scsi_device(device); struct ata_port *ap = ata_shost_to_port(sdev->host); - struct ata_device *dev; - bool ncq_prio_enable; - int rc = 0; + int rc; - spin_lock_irq(ap->lock); - dev = ata_scsi_find_dev(ap, sdev); - if (!dev) - rc = -ENODEV; - else - ncq_prio_enable = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLED; - spin_unlock_irq(ap->lock); + rc = ata_ncq_prio_enabled(ap, sdev); + if (rc < 0) + return rc; - return rc ? rc : sysfs_emit(buf, "%u\n", ncq_prio_enable); + return sysfs_emit(buf, "%d\n", rc); } -static ssize_t ata_ncq_prio_enable_store(struct device *device, - struct device_attribute *attr, - const char *buf, size_t len) +/** + * ata_ncq_prio_enable - Enable/disable NCQ Priority + * @ap: ATA port of the target device + * @sdev: SCSI device + * @enable: true - enable NCQ Priority, false - disable NCQ Priority + * + * Helper to enable/disable NCQ Priority feature, usable with both + * libsas and libata. + */ +int ata_ncq_prio_enable(struct ata_port *ap, struct scsi_device *sdev, + bool enable) { - struct scsi_device *sdev = to_scsi_device(device); - struct ata_port *ap; struct ata_device *dev; - long int input; + unsigned long flags; int rc = 0; - rc = kstrtol(buf, 10, &input); - if (rc) - return rc; - if ((input < 0) || (input > 1)) - return -EINVAL; + spin_lock_irqsave(ap->lock, flags); - ap = ata_shost_to_port(sdev->host); dev = ata_scsi_find_dev(ap, sdev); - if (unlikely(!dev)) - return -ENODEV; - - spin_lock_irq(ap->lock); + if (unlikely(!dev)) { + rc = -ENODEV; + goto unlock; + } if (!(dev->flags & ATA_DFLAG_NCQ_PRIO)) { rc = -EINVAL; goto unlock; } - if (input) { + if (enable) { if (dev->flags & ATA_DFLAG_CDL_ENABLED) { ata_dev_err(dev, "CDL must be disabled to enable NCQ priority\n"); @@ -934,9 +973,29 @@ static ssize_t ata_ncq_prio_enable_store(struct device *device, } unlock: - spin_unlock_irq(ap->lock); + spin_unlock_irqrestore(ap->lock, flags); + return rc; +} +EXPORT_SYMBOL_GPL(ata_ncq_prio_enable); + +static ssize_t ata_ncq_prio_enable_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct ata_port *ap = ata_shost_to_port(sdev->host); + bool enable; + int rc; + + rc = kstrtobool(buf, &enable); + if (rc) + return rc; + + rc = ata_ncq_prio_enable(ap, sdev, enable); + if (rc) + return rc; - return rc ? rc : len; + return len; } DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR, diff --git a/include/linux/libata.h b/include/linux/libata.h index 26d68115afb8..f3ff2bf3ec6b 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1157,6 +1157,10 @@ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth); extern int ata_change_queue_depth(struct ata_port *ap, struct scsi_device *sdev, int queue_depth); +extern int ata_ncq_prio_supported(struct ata_port *ap, struct scsi_device *sdev); +extern int ata_ncq_prio_enabled(struct ata_port *ap, struct scsi_device *sdev); +extern int ata_ncq_prio_enable(struct ata_port *ap, struct scsi_device *sdev, + bool enable); extern struct ata_device *ata_dev_pair(struct ata_device *adev); extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap); From patchwork Sat Mar 2 00:15:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 777704 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05023BA45 for ; Sat, 2 Mar 2024 00:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338620; cv=none; b=ATNWg+NubG7oYP7aXQ15t+CtPbPvc+JzbbScO8+WiPiMgaSyNhjDJyAfVkIki7QDXPkPMwjGOFoZ2SyLHm6bdX1xjvKM+kAht5PVYJ8TIOx6vt3ERhDJXZQEUp3AG/thGeWuJgI5ZwxZvh6nQST6c8AQx+B6D64EsHXiYw8oY1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338620; c=relaxed/simple; bh=0GrvhQMeDiqnvSKKSLm4FXuympZbNYitH8oNM1c1K2M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l9y5zRsVzEpcUd2/QD4AFSO+G+5H+itKdZIw490nmbhvIgP5rS5zMOdZhuGomMiZiMjfCFVTXtzhTOTTbiXIxJ4GMpVhIipWey+LKyaKTVEdIlNfg6i055eZpXFpIbV4u4TysmQu3/iPtGTbFe+5aI+JfmGWxMNqaNbcfMk2TNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=0yuguYux; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="0yuguYux" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc743cc50a6so3600505276.2 for ; Fri, 01 Mar 2024 16:16:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709338618; x=1709943418; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SBbBICcO6IvwKDEiRI+I7rx8MULu52MOhujWx/5/qGw=; b=0yuguYux9axl8wuUNIB9ZYosscBR4VWPmEC2qpbpdU39IR/aOzgFxhOxA53xi652js yBK94hTwqpCWRIcmMDEUVyuyT2INDr+TSi8LuQqOfKC1DGFUeOAWDZcbIHjTg2xctgBs WdoHq76TAc/zd9WdTH2bQ5NdmNRPDbUa2ZTLzoBrxP0q7GDXexrANykLO0i5CGA0MvJh NimvdR+BTk2FvChV8tsQpZAkPJ+B4jAgHUhdcEDLAEcv5OTCj03yLLB4wWbG5/k6zSAb bV0z4iamg2qGPFGReNKFRXLaWeRtRKylW/dzAeBy1HtQL++B4QKMXjr7bth+dFofVUEs eEuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709338618; x=1709943418; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SBbBICcO6IvwKDEiRI+I7rx8MULu52MOhujWx/5/qGw=; b=hpmsa/5C/4JgS+BSBVdwZOJ9lqMOphDCNHbNM7qN2HJjHA5aWOECMe47UC0bYrcecl 3UpESVHWKlc4vW3LeBHSxPruFx6ZY2Yi532+q3ldcEuAYa3t0GZ1rQ3yfZOu1BHUJqxG nZz8W8EjwsDjSpqwrxb1SLTLrCAep04R6FgPvgy9ryK9vIAKmuh6qX/BmWPAy0/StJGw 2hklWWN416wO1Gp9aE0qYiFNxoL45uzbVUuw4LyXNyfObctzIyNVn9Mi7coT1KKcDRTO yzZ9XtTPuPxkXb5GqRg8cUI0N9mSQNWX1YZZ6ABlftRCXeZd36xuR0GF1y3XcyU4Ut6s VlJA== X-Forwarded-Encrypted: i=1; AJvYcCUhq4aGDhPl8w4BvthfRUQ3PCoV9TR71/6dhiuWS6LmZjsF3aWyZ+ZWXZUQfvurngvcRex35gKkan0oY/sJFsXmVpJ+gSfmQ+y4RA== X-Gm-Message-State: AOJu0Yx4NCP+gRuPjlHuu38agiCcGekQA6HAfYZjjXGBTBfn0p/EPfn9 9f4xbJw4vLFifZY1XnkANtIf3ljqJyGXj5sSsTKwv7ItOnXL+dbM5PizgJMtT2NyVpfPqPddHHp 83GS9Hj9Npg== X-Google-Smtp-Source: AGHT+IEYOP1+6p+cLu9IXpIv81WnNvWYnNfOJaVjXrtSXfWTSKL/ab0M4h6xW8oYE9Vs5fjooC1s26l67OhuZg== X-Received: from ipylypiv.svl.corp.google.com ([2620:15c:2c5:13:2afe:1a8e:f846:999f]) (user=ipylypiv job=sendgmr) by 2002:a05:6902:18d3:b0:dc7:865b:22c6 with SMTP id ck19-20020a05690218d300b00dc7865b22c6mr117555ybb.8.1709338618166; Fri, 01 Mar 2024 16:16:58 -0800 (PST) Date: Fri, 1 Mar 2024 16:15:59 -0800 In-Reply-To: <20240302001603.1012084-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302001603.1012084-1-ipylypiv@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240302001603.1012084-3-ipylypiv@google.com> Subject: [PATCH v2 2/5] scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Hannes Reinecke Cc: TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv Libata sysfs attributes cannot be used for libsas managed SATA devices because the ata_port location is different for libsas. Defined sysfs attributes (visible for SATA devices only): - /sys/block/sda/device/ncq_prio_enable - /sys/block/sda/device/ncq_prio_supported The newly defined attributes will pass the correct ata_port to libata helper functions. Signed-off-by: Igor Pylypiv --- drivers/scsi/libsas/sas_ata.c | 92 +++++++++++++++++++++++++++++++++++ include/scsi/sas_ata.h | 6 +++ 2 files changed, 98 insertions(+) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 12e2653846e3..e4d07134a0e4 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -964,3 +964,95 @@ int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id) force_phy_id, &tmf_task); } EXPORT_SYMBOL_GPL(sas_execute_ata_cmd); + +static ssize_t sas_ncq_prio_supported_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + int rc; + + /* This attribute shall be visible for SATA devices only */ + if (WARN_ON(!dev_is_sata(ddev))) + return -EINVAL; + + rc = ata_ncq_prio_supported(ddev->sata_dev.ap, sdev); + if (rc < 0) + return rc; + + return sysfs_emit(buf, "%d\n", rc); +} + +DEVICE_ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL); + +static ssize_t sas_ncq_prio_enable_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + int rc; + + /* This attribute shall be visible for SATA devices only */ + if (WARN_ON(!dev_is_sata(ddev))) + return -EINVAL; + + rc = ata_ncq_prio_enabled(ddev->sata_dev.ap, sdev); + if (rc < 0) + return rc; + + return sysfs_emit(buf, "%d\n", rc); +} + +static ssize_t sas_ncq_prio_enable_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + bool enable; + int rc; + + /* This attribute shall be visible for SATA devices only */ + if (WARN_ON(!dev_is_sata(ddev))) + return -EINVAL; + + rc = kstrtobool(buf, &enable); + if (rc) + return rc; + + rc = ata_ncq_prio_enable(ddev->sata_dev.ap, sdev, enable); + if (rc) + return rc; + + return len; +} + +DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR, + sas_ncq_prio_enable_show, sas_ncq_prio_enable_store); + +static struct attribute *sas_ata_sdev_attrs[] = { + &dev_attr_ncq_prio_supported.attr, + &dev_attr_ncq_prio_enable.attr, + NULL +}; + +static umode_t sas_ata_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int i) +{ + struct device *dev = kobj_to_dev(kobj); + struct scsi_device *sdev = to_scsi_device(dev); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + + if (!dev_is_sata(ddev)) + return 0; + + return attr->mode; +} + +const struct attribute_group sas_ata_sdev_attr_group = { + .attrs = sas_ata_sdev_attrs, + .is_visible = sas_ata_attr_is_visible, +}; +EXPORT_SYMBOL_GPL(sas_ata_sdev_attr_group); diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index 2f8c719840a6..cded782fdf33 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h @@ -39,6 +39,8 @@ int smp_ata_check_ready_type(struct ata_link *link); int sas_discover_sata(struct domain_device *dev); int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, struct domain_device *child, int phy_id); + +extern const struct attribute_group sas_ata_sdev_attr_group; #else static inline void sas_ata_disabled_notice(void) @@ -123,6 +125,10 @@ static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *p sas_ata_disabled_notice(); return -ENODEV; } + +static const struct attribute_group sas_ata_sdev_attr_group = { + .attrs = NULL, +}; #endif #endif /* _SAS_ATA_H_ */ From patchwork Sat Mar 2 00:16:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 777616 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 695CF10A12 for ; Sat, 2 Mar 2024 00:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338622; cv=none; b=PVI/rvjWdFlshJzXYBwInPjPpuqUnUAnr3ZcmPCrOAVwugSTZafF27K9nbs49tSzLAj1D+u5BNJoewK/QZv4EQPNTEusEiDzw/XcMdPJNSYEHld9VNxInOgkGCMW0GzdkZJkL1XRpHkClyzNDPbL27cYIwFRAxLVixq1oNl0bZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338622; c=relaxed/simple; bh=KWCF/wRFo5DDf67uvUwFxQaljHz80tfPANfuy0kjn8k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GJNo8aTxB0r6kIUk+6jZgR14bq3RDLdVnGEbyMVh7wmSeoCPBhzc11qPESozzfD1jdSoYeV+AeNou0gULFFZQl+RwQFY28LyaQULL5r0DovX1Ca8PqHImoJbbn+wyCIndc5UrsqHNFnz7dIB0abgqyJQVIhZyCWghg0GdT20QBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PPcCR5CE; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PPcCR5CE" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5f38d676cecso49623867b3.0 for ; Fri, 01 Mar 2024 16:17:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709338620; x=1709943420; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jZVgry90rEYwnQ29s3Mz+RKBDNtmCmbKQoUc6PEOd2Y=; b=PPcCR5CEhwa0igG15qOeDKade+YVH33V+GStmueu6YH5qGA3tH4ZqBlo2/XdZ+EJUv WG8rglQlpML/1MyFJXYK1W7r4FeX+GhaGDeAPyHqpNPNjuBTamFp1gzMJWI5YZ8zV0w1 mZ4KJsmXNkuinhEXPO4WmRrHF04fS//fG+ZFHdZpPB0KgyrBM6Vn0W6IUBzRMR5vtuxi DyfiqEKujt3wn1Wua03zsYWpp5weiXFdED7VRifzic0u8GZbni1HD4UTDn3bbUDyEDhp TMwkLekUaYUSyUgF3WMZB8ASjvk4hPTwyz/0jhLOYo1qHNtInjtBHDy8/yp+xqaz/o7l rq/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709338620; x=1709943420; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jZVgry90rEYwnQ29s3Mz+RKBDNtmCmbKQoUc6PEOd2Y=; b=D/dyqoX5MT7/cs83rFzui0ZwCg3rXzb/Yvum4R8fNJ6XNWlVtFAUEqpyiky7wACC/t r1g7uthehq9NratJlHrqmdlTgpewcCwDhVWAf72w+8jQwDPV3QyVg1ZgD0tStw8l5zpw JigJKU5kEM2PrM9p5bZ/gt8sT19N4F2pg2lYv8wn4WvKJxJJVWZ5XtN8ZYGLRuSPF8RR ORUjzk+vVuW1SdTmHO37+DHLrC1lH2O28iJjZ1LxtaVEnwZuQ4BD8f6+rhuDPTDXt80R WUOOef6p5NYN4dSwY1wPmxmdDeZlAc8R/uJ2/OY0bSOukWibULP1tfDrjjCTmwoRd03m qcZQ== X-Forwarded-Encrypted: i=1; AJvYcCU2Mq29EKKrNhrzc2+yeIm8p7NGINo9K0/31JBoYSM4MwDNbT21LBPO/y0JAl6tY6iOlP0FtWJqN2wjV9/5mTpidwJ4x/JOAJQF6w== X-Gm-Message-State: AOJu0YyD1KzUGBaT/0TFpxyMrZjoJlscQrFZgQlMroJjXzM41BtW9djQ rY6chX2dtP8yFP8PUPpkI0gSADFkQOBsS3K+2NbzcOkHJJt7u/wftn6ewM7vZJqv4dyF96b9KEM +xCm1k6/1Eg== X-Google-Smtp-Source: AGHT+IF844ROWPX3UQs43uVCN1uIg10aXS00abyrZckT+88C0Iv9L0+XF5s4z+na8MnK1JL2LOmk+VVkTvDt+w== X-Received: from ipylypiv.svl.corp.google.com ([2620:15c:2c5:13:2afe:1a8e:f846:999f]) (user=ipylypiv job=sendgmr) by 2002:a05:6902:505:b0:dc7:4ca0:cbf0 with SMTP id x5-20020a056902050500b00dc74ca0cbf0mr1203600ybs.3.1709338620711; Fri, 01 Mar 2024 16:17:00 -0800 (PST) Date: Fri, 1 Mar 2024 16:16:00 -0800 In-Reply-To: <20240302001603.1012084-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302001603.1012084-1-ipylypiv@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240302001603.1012084-4-ipylypiv@google.com> Subject: [PATCH v2 3/5] scsi: pm80xx: Add libsas SATA sysfs attributes group From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Hannes Reinecke Cc: TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Signed-off-by: Igor Pylypiv --- drivers/scsi/pm8001/pm8001_ctl.c | 5 +++++ drivers/scsi/pm8001/pm8001_init.c | 1 + drivers/scsi/pm8001/pm8001_sas.h | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 5c26a13ffbd2..9ffe1a868d0f 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -1039,3 +1039,8 @@ const struct attribute_group *pm8001_host_groups[] = { &pm8001_host_attr_group, NULL }; + +const struct attribute_group *pm8001_sdev_groups[] = { + &sas_ata_sdev_attr_group, + NULL +}; diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index ed6b7d954dda..e6b1108f6117 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -134,6 +134,7 @@ static const struct scsi_host_template pm8001_sht = { .compat_ioctl = sas_ioctl, #endif .shost_groups = pm8001_host_groups, + .sdev_groups = pm8001_sdev_groups, .track_queue_depth = 1, .cmd_per_lun = 32, .map_queues = pm8001_map_queues, diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 3ccb7371902f..ced6721380a8 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -717,6 +717,7 @@ int pm80xx_fatal_errors(struct pm8001_hba_info *pm8001_ha); void pm8001_free_dev(struct pm8001_device *pm8001_dev); /* ctl shared API */ extern const struct attribute_group *pm8001_host_groups[]; +extern const struct attribute_group *pm8001_sdev_groups[]; #define PM8001_INVALID_TAG ((u32)-1) From patchwork Sat Mar 2 00:16:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 777703 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABC3D125A9 for ; Sat, 2 Mar 2024 00:17:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338625; cv=none; b=fBWhql0/uFW3c2DuKSdoWRwGIuqLx6fCSIptc9oD81iRp5hZU+P6m3NYIlXQyoKdf0rKyuJJRvak6DT2bTvJ5ABuA+N1WkJhJ6TLH328I1OEPPBa5p0h5UX7w+lSryLuGS+UpjZ9xEk+dwvVR+JlkEeYUuoRRfX9wuXeURuik/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338625; c=relaxed/simple; bh=bjPtSxZSirainXwWirJU3J0oe9KNdxmW81tZ+T9YgIw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VpFk0TyqV5+/RV0qZz2Tvu6qjGD0jQV05QoAVmb1hIQ1Gln4A6VgwZ49MAhnBho8IUbn7w8jrApCyCceHsRc0a5WFT/nXd3gajwV/fIgR6ETxqU3sxroMX0kwghwJsjjTPac3qlkYQUmVmCQtV5ZSTeWSdU09/QiB4ngvSy2FqM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NqBmaVw+; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NqBmaVw+" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-608d6ffc64eso37936607b3.0 for ; Fri, 01 Mar 2024 16:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709338623; x=1709943423; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cz+zzq0hSSZv+LNtbHhOy76RrAuTvZz0C7UUtpPGk5c=; b=NqBmaVw+4RQgYIfxwns4Hj+hw6aLAd179C/AdDV+zJb5Ml9Ia8IoMrgg/bTv7AGBOh TdaCIHLiwFDjLEdIL0k9rTHyTAzlnyvZKETtyaw6u681mM0tX1Eke+jo+M5fsjYJd9qd SSp3zJ/+BDfWcqU4/gMgvAzgzc5ddKPIKQ1s12C2gA37TQ4xN8AIIZOfv0TUix8cgZ9y YGDZnAS2GI/0/oZ9Jty2qxx6H2C3e7cZ6kZKnQuwnietELKVpPoxjng86RCHx2+BS5eg YQDWzvo/qX+gL49oA8MTSylTKwAvcUSLqCO8qCZvvMdoC1AoYqSFplW9VcsBcgqaFeP9 goig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709338623; x=1709943423; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cz+zzq0hSSZv+LNtbHhOy76RrAuTvZz0C7UUtpPGk5c=; b=k+VSzYEHH/CjfIigQV+a6INiEqv2Q/Czkej2GktMuxvaqp+gboULyFnk3OqOK6rgud b2kv00KwhGf11FUyJoW0lvgGdvDL5a30qkzEyne2ZAEh8AsLpibatz2YqRD1c1vTEifS /i405t/jw7lL0e2BmEqYwwDgogYZ88vZnzuUncA5w4xpCno6dS1EWuVklk1jOWZsBgeS St0Jf8vcyVSRKlPVUDm2HFo+pzUM2WSiT4uO8J5ky8yS+NqKIm6glNIGqY+fDXur+Ufj iEBiUCJfzIGVvrxl8ercjbyHcC3jTUYBU2nhLSExgseZOya+Cc9zFqWnBB93UgVfnZsi YVvA== X-Forwarded-Encrypted: i=1; AJvYcCVjEoRI+/FR3HJJrtC4wTAZZNs40pzAlM9HbAdXr8YaIu4hWLKvlMQA55BZNHVVbjn+jEfTx650g52BTi1dO3zA6hTMKHCe5cH9CQ== X-Gm-Message-State: AOJu0Yz98kQmVYtjWyYaovh4AYwYaXfGOjBkurDR+8JrHL4uwFMHw4Dz QWg53ZKkECcpklL16wcpVK34OVNUE2V6fMktmox+ucmXHDVMv1YRNVhlWqSNKCD1TkAZlwPOSj2 V+B6aqXBb/g== X-Google-Smtp-Source: AGHT+IG+aso8DlILFFU3hOZkQxoXGg0/2rizQ7SMEtEdYiKh5yDyTO6FrayYjPmqaZro4E9t7cvjrUqndk6pUg== X-Received: from ipylypiv.svl.corp.google.com ([2620:15c:2c5:13:2afe:1a8e:f846:999f]) (user=ipylypiv job=sendgmr) by 2002:a81:9808:0:b0:607:8f65:5433 with SMTP id p8-20020a819808000000b006078f655433mr688164ywg.4.1709338622812; Fri, 01 Mar 2024 16:17:02 -0800 (PST) Date: Fri, 1 Mar 2024 16:16:01 -0800 In-Reply-To: <20240302001603.1012084-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302001603.1012084-1-ipylypiv@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240302001603.1012084-5-ipylypiv@google.com> Subject: [PATCH v2 4/5] scsi: mvsas: Add libsas SATA sysfs attributes group From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Hannes Reinecke Cc: TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Signed-off-by: Igor Pylypiv --- drivers/scsi/mvsas/mv_init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 43ebb331e216..80cbe030ac53 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -26,6 +26,7 @@ static const struct mvs_chip_info mvs_chips[] = { }; static const struct attribute_group *mvst_host_groups[]; +static const struct attribute_group *mvst_sdev_groups[]; #define SOC_SAS_NUM 2 @@ -53,6 +54,7 @@ static const struct scsi_host_template mvs_sht = { .compat_ioctl = sas_ioctl, #endif .shost_groups = mvst_host_groups, + .sdev_groups = mvst_sdev_groups, .track_queue_depth = 1, }; @@ -779,6 +781,11 @@ static struct attribute *mvst_host_attrs[] = { ATTRIBUTE_GROUPS(mvst_host); +static const struct attribute_group *mvst_sdev_groups[] = { + &sas_ata_sdev_attr_group, + NULL, +}; + module_init(mvs_init); module_exit(mvs_exit); From patchwork Sat Mar 2 00:16:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Pylypiv X-Patchwork-Id: 777615 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D161E134DE for ; Sat, 2 Mar 2024 00:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338627; cv=none; b=d/vC7EAgNhw4DM6ANkr7M9pE1QZfLPLD+RQUOS/wyY6MJGjCCaK3xyJ3cSvJKyAPMm53pCxEbFqWVx/zMrjqyu3AQtfZc7/i4dQJ00NbMex6CdSQ8U8yCe6bgnJcyhV1OdlM8hq+i3tzO1bayBfqx6ADFYyz3QP5zVXqWCNkbf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338627; c=relaxed/simple; bh=oCEOlszWbRebAJRFgYlHh9o1ZpJRj0ce/17rkZ3A3M8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=V520abw8mtFRt408K06VoOEo6vq4LFXOa+dN5zJ1p0UNzQv5UqMw6H91/7m3XPT7matsFKOsc38rN+4Y9nFrQ0Dq6sYoY9gkU6kaWl3KQGqSXpi389twVWmB6gwVptOdJP3i1KLsnKvd8NLAgQmMAiaYEcYuQUoQqodOuXNaWEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jYVAZdBK; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jYVAZdBK" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc64f63d768so4871973276.2 for ; Fri, 01 Mar 2024 16:17:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709338625; x=1709943425; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=aUX3zhIus5O92bJYySj4+GAcqh6w/58AkwOdnSqPEQ8=; b=jYVAZdBKuXRtcp4BjBWfmc5UDZO96hwuu7bUwh+4e/ozYcVOBeE0yUhlatuICmexaR BL3rGl6HsgBqVKrB+MqxxcTwmo4qCZsv6aSA4/Tb4r1gLOOfdzCc45r0bmVaPwDMeXyy cd6pKDsC5vyHpFXQ0EpPcwMTtUP6iftDzMP9wDKX1BZcoepB90aKJMZJV6Cf7imyJPWE u4RDK1vYJn0Ca0PXvbKMVbCzsJVl06PhL8y9Qho92KAjibmuXYKqMb87lftrISsQNNXu OfLw4dIpo+tywywhLbYXmcdTHJnGaPqm+vXQC12rdBspVUFKlAwIK3U19QC288L6YXx6 4M7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709338625; x=1709943425; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aUX3zhIus5O92bJYySj4+GAcqh6w/58AkwOdnSqPEQ8=; b=QJ1MZg4b28qFwpVAzYurY/n7CfsQDElmWe6OgQGpKVBnYDXNtTU0/dTg4k6eaKTmXt lxETKDDyT7vBe4qcuCRlSi0vlSlEwMGxmHkYbFLdsYJKrRj29geuDsSiIoHuRIfSBAgA 8B8qneJOOP34HktRXCe4k1G0KYUTROL0SHRNfIdP43JmCXLbmcpiGnDtswUO3awYwV8S FBu3fIAuvCYeftVlRf4JUevgTdVd2/Gn7TrJWagQ+lzStAzbXH9f4hy/ydXEmR8e1xT7 YcOY5AgT1R52RDb4m5ZPptFr9WaSO3nSczeZ8u3nRnHZSkEsAZKTV7imgZ19foMjfj+h oKog== X-Forwarded-Encrypted: i=1; AJvYcCW4mjIN9BxENNG3/1RrytwlMwsoQfOa3+po6mdLJkCfYCqXsEgJ+T9scuabd8AaNogZMOGGasJSQzpPfuBz0/FTvKpn34HkQG/oXQ== X-Gm-Message-State: AOJu0YwpkKXy2aA4vT4ySTmymMEKeoOOrWeV25LsgtrwLorcBV30V9mV IhhfTgtDdIA/D1k9JF9eC5v8WzeQ7xwiRpQSOc6N6HRc0fG81StlUymhXfGeSv4A0xJWR0hrH0f Qz/chDLalpg== X-Google-Smtp-Source: AGHT+IGpYFdkSZO93d6Cb08S6RbmCk+UgL9HtoRDFxC19PmO95Bu0m/cSiB1RLQRMZ3KLzRi+Dc+F4zpVgTKYw== X-Received: from ipylypiv.svl.corp.google.com ([2620:15c:2c5:13:2afe:1a8e:f846:999f]) (user=ipylypiv job=sendgmr) by 2002:a05:6902:2492:b0:dcb:b9d7:2760 with SMTP id ds18-20020a056902249200b00dcbb9d72760mr751756ybb.13.1709338624882; Fri, 01 Mar 2024 16:17:04 -0800 (PST) Date: Fri, 1 Mar 2024 16:16:02 -0800 In-Reply-To: <20240302001603.1012084-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302001603.1012084-1-ipylypiv@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240302001603.1012084-6-ipylypiv@google.com> Subject: [PATCH v2 5/5] scsi: hisi_sas: Add libsas SATA sysfs attributes group From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Hannes Reinecke Cc: TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv The added sysfs attributes group enables the configuration of NCQ Priority feature for HBAs that rely on libsas to manage SATA devices. Signed-off-by: Igor Pylypiv --- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 6 ++++++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 ++++++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 3c555579f9a1..97864b56a71f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1734,6 +1734,11 @@ static struct attribute *host_v1_hw_attrs[] = { ATTRIBUTE_GROUPS(host_v1_hw); +static const struct attribute_group *sdev_groups_v1_hw[] = { + &sas_ata_sdev_attr_group, + NULL +}; + static const struct scsi_host_template sht_v1_hw = { .name = DRV_NAME, .proc_name = DRV_NAME, @@ -1758,6 +1763,7 @@ static const struct scsi_host_template sht_v1_hw = { .compat_ioctl = sas_ioctl, #endif .shost_groups = host_v1_hw_groups, + .sdev_groups = sdev_groups_v1_hw, .host_reset = hisi_sas_host_reset, }; diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 73b378837da7..b5d379ebe05d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3544,6 +3544,11 @@ static struct attribute *host_v2_hw_attrs[] = { ATTRIBUTE_GROUPS(host_v2_hw); +static const struct attribute_group *sdev_groups_v2_hw[] = { + &sas_ata_sdev_attr_group, + NULL +}; + static void map_queues_v2_hw(struct Scsi_Host *shost) { struct hisi_hba *hisi_hba = shost_priv(shost); @@ -3585,6 +3590,7 @@ static const struct scsi_host_template sht_v2_hw = { .compat_ioctl = sas_ioctl, #endif .shost_groups = host_v2_hw_groups, + .sdev_groups = sdev_groups_v2_hw, .host_reset = hisi_sas_host_reset, .map_queues = map_queues_v2_hw, .host_tagset = 1, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index b56fbc61a15a..9b69ea16a1e6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2929,6 +2929,11 @@ static struct attribute *host_v3_hw_attrs[] = { ATTRIBUTE_GROUPS(host_v3_hw); +static const struct attribute_group *sdev_groups_v3_hw[] = { + &sas_ata_sdev_attr_group, + NULL +}; + #define HISI_SAS_DEBUGFS_REG(x) {#x, x} struct hisi_sas_debugfs_reg_lu { @@ -3340,6 +3345,7 @@ static const struct scsi_host_template sht_v3_hw = { .compat_ioctl = sas_ioctl, #endif .shost_groups = host_v3_hw_groups, + .sdev_groups = sdev_groups_v3_hw, .tag_alloc_policy = BLK_TAG_ALLOC_RR, .host_reset = hisi_sas_host_reset, .host_tagset = 1,